改变按钮的所有者后,按钮无法响应点击事件~~~晕~~~ ( 积分: 50 )

  • 主题发起人 主题发起人 speari
  • 开始时间 开始时间
S

speari

Unregistered / Unconfirmed
GUEST, unregistred user!
unit Unit1;

interface

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

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

var
Form1: TForm1;

implementation

{$R *.dfm}

// 以下是查找窗口 SysListView32 的代码:
function MyFindWindow : THandle;
const
// 父窗口类名数组
A_szClassName : array [0..2] of PChar = (
'Progman',
'SHELLDLL_DefView',
'SysListView32'
);
// 父窗口标题数组
A_szWinName : array [0..2] of PChar = (
'Program Manager',
'',
'FolderView'
);
var
i : Integer;
hLastWin : THandle;
begin
// 首先求得顶级父窗口
hLastWin := FindWindow(A_szClassName[0], A_szWinName[0]);
// 逐次用FindWindowEx函数求出各级子窗口
for i:=1 to 2 do
begin
hLastWin := FindWindowEx(hLastWin, THandle(nil),
A_szClassName, A_szWinName);
end;
result := hLastWin;
end;
// 举例: hLastWin : THandle;
// hLastWin := MyFindWindow();

procedure TForm1.FormCreate(Sender: TObject);
var deskt:Thandle;
begin
deskt:=MyFindWindow();
windows.setparent(Button1.handle,deskt);
end;

上面的代码给桌面加上了一个按钮,然后按钮无法响应事件,我该怎样才能让按钮响应呢?
 
unit Unit1;

interface

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

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

var
Form1: TForm1;

implementation

{$R *.dfm}

// 以下是查找窗口 SysListView32 的代码:
function MyFindWindow : THandle;
const
// 父窗口类名数组
A_szClassName : array [0..2] of PChar = (
'Progman',
'SHELLDLL_DefView',
'SysListView32'
);
// 父窗口标题数组
A_szWinName : array [0..2] of PChar = (
'Program Manager',
'',
'FolderView'
);
var
i : Integer;
hLastWin : THandle;
begin
// 首先求得顶级父窗口
hLastWin := FindWindow(A_szClassName[0], A_szWinName[0]);
// 逐次用FindWindowEx函数求出各级子窗口
for i:=1 to 2 do
begin
hLastWin := FindWindowEx(hLastWin, THandle(nil),
A_szClassName, A_szWinName);
end;
result := hLastWin;
end;
// 举例: hLastWin : THandle;
// hLastWin := MyFindWindow();

procedure TForm1.FormCreate(Sender: TObject);
var deskt:Thandle;
begin
deskt:=MyFindWindow();
windows.setparent(Button1.handle,deskt);
end;

上面的代码给桌面加上了一个按钮,然后按钮无法响应事件,我该怎样才能让按钮响应呢?
 
后退
顶部