⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 clipboardviewer.~pas

📁 本光盘是《Delphi 7应用教程》一书的配套光盘
💻 ~PAS
字号:
unit ClipBoardViewer;

interface

uses
  Windows,Messages,SysUtils, Graphics,Classes, Controls, ExtCtrls,Clipbrd;

type
   TClipBoardTextChangeEvent=Procedure(Sender:Tobject;Text:String) of Object;
  TWeekDayType=(Sunday,Monday,Thuesday,Wednesday,Thirsday,Friday,Saturday);
  TworkdayType=Set of TweekDaytype;
  TClipBoardViewer = class(TCustomPanel)
  private
    { Private declarations }
    FBorderWidth:Integer;
    FWeekDay :TWeekDayType;
    FWorkDay: TWorkDayType;
    FIntarr :Array[0..10] Of integer;
    FImagePic:TBitmap;
    FNextClipBoardViewer:HWND;
    FHandle:HWND;
    FOnClipBoardText:TClipBoardTextChangeEvent;
    Procedure SetBorderWidth(Value:Integer);
    Function GetIntArr(i:integer):Integer;
    Procedure SetIntArr(i,value:integer);
    Procedure SetImagePic(Pic:TBitmap);
    procedure WMDrawClipBoard(var Msg:TMessage);message WM_DRAWCLIPBOARD;
    Procedure WMChangeCBChain(Var Msg:TMessage);Message WM_CHANGECBCHAIN;
  protected
    { Protected declarations }
  public
    { Public declarations }
         Constructor  Create(Comob:TComponent);override;
         Destructor   Destroy;Override;
         property IntArr[i:Integer]:Integer read GetIntArr Write SetIntArr;
  published
     { Published declarations }
     Property BorderWidth:Integer
       read FBorderWidth write SetBorderWidth Default 0;
     Property Caption;
     property Visible;
     property Weekday:TweekDayType Read  FWeekDay write Fweekday;
     property Workday:TworkDayType Read  FWorkDay write Fworkday;
     Property Imagepic:TBitmap Read FImagePic Write SetImagePic;
     property OnClipBoardText:TClipBoardTextChangeEvent read FonClipBoardText
       Write FonClipBoardText;
  end;

  procedure Register;

implementation

procedure Register;
begin
  RegisterComponents('Samples', [TClipBoardViewer]);
end;
procedure TClipBoardViewer.SetBorderWidth(Value:Integer);
   begin
      FBorderWidth:=Value;
      Realign;
      Invalidate;
   end;
Function TClipBoardViewer.GetIntArr(i:integer):integer;
  begin
       result:=FIntArr[i];
  end;

Procedure TClipBoardViewer.SetIntArr(i,Value:Integer);
   begin
       FIntArr[i]:=Value;
   end;
Constructor  TClipBoardViewer.Create(comob:TComponent);
  begin
     inherited;
     FImagepic:=TBitmap.create;
     if not(csDesigning in ComponentState)  then
          begin
             FNextClipBoardViewer:=SetClipBoardViewer(Handle);
             FHandle:=Handle;
          end;
  end;
Destructor  TClipBoardViewer.Destroy ;
   begin
     if assigned(FImagePic)  then
         FImagePic.Free;
     if not(csDesigning in ComponentState)  then
          ChangeClipBoardChain(FHandle,FNextClipBoardViewer);
      inherited;
   end;
Procedure  TClipBoardViewer.SetImagepic(Pic:TBitmap);
  begin
    if assigned(FImagePic)  then
       FImagePic.Free;
    FImagePic:=Pic;
  end;
  Procedure  TClipBoardViewer.WMChangeCBChain(var Msg:TMessage);
   begin
      if FNextClipBoardViewer<>0 then
          sendMessage(FNextClipBoardViewer,Msg.Msg,Msg.Wparam,msg.Lparam);
   end;

   Procedure  TClipBoardViewer.WMDrawClipBoard(var Msg:TMessage);
      begin
         if assigned(FOnClipBoardText) AND ClipBoard.hasFormat(CF_TEXT) then
            FOnClipBoardText(self,ClipBoard.asText);
         If FnextClipBoardViewer<>0 then
            SendMessage(FNextClipBoardViewer,Msg.msg,Msg.Wparam,msg.Lparam);
      end;

end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -