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

📄 copyform.pas

📁 Delphi高级开发指南是开发程序的好帮手
💻 PAS
字号:
unit CopyForm;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls;

type
  TForm1 = class(TForm)
    BtnSendCopyData: TButton;
    Button1: TButton;
    procedure BtnSendCopyDataClick(Sender: TObject);
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.BtnSendCopyDataClick(Sender: TObject);
var
  Cds: TCopyDataStruct;
  Hwnd: THandle;
begin
  // small data (32 bits): top of form
  Cds.dwData := Top;
  // size of data
  Cds.cbData := Length (Caption) + 1;
  // allocate memory for the large block and fill it
  GetMem (Cds.lpData, Cds.cbData );
  StrCopy (Cds.lpData, PChar (Caption));
  // get the handle of the target window
  Hwnd := FindWindow ('TFormGetData', 'GetData');
  if Hwnd <> 0 then
  begin
    // send the message
    if SendMessage (
        Hwnd, WM_COPYDATA, Handle, Cardinal(@Cds)) = 1 then
      // received
      Beep;
  end
  else
    // target not found
    ShowMessage ('GetData window not found.');
  FreeMem (Cds.lpData);
end;

procedure TForm1.Button1Click(Sender: TObject);
var
  Hwnd: THandle;
begin
  // get the handle of the target window
  Hwnd := FindWindow ('TFormGetData', 'GetData');
  if Hwnd <> 0 then
    // send the plain string
    SendMessage (Hwnd, WM_USER, 0,
      Integer (PChar (Caption)))
  else
    // target not found
    ShowMessage ('GetData window not found.');
end;

end.

⌨️ 快捷键说明

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