我已閱讀this article如何將按鈕添加到另一個應用程序。當按鈕被添加到父應用程序時,一切似乎都正常,但是當此按鈕被添加到另一個名爲Labform(TLabForm)的應用程序時,單擊後的代碼不會被執行。我還創建了一個後代來實現點擊後的簡單行爲,但沒有成功:在另一個應用程序中添加控件的功能缺失
TButton2 = class (TButton)
public
procedure Click; override;
end;
procedure TButton2.Click;
begin
inherited;
MessageBox(ParentWindow, 'Hello', 'Window', MB_OK);
end;
procedure TForm1.btn1Click(Sender: TObject);
var
Button2 : TButton2 ;
Hand: THandle;
begin
// Hand:= FindWindow('TLabForm', 'Labform'); // button added, but SHOWS NO message after click
Hand:= FindWindow('TForm1', 'Form1'); // button added, and SHOWS message after click
if Hand <> 0 then
begin
Button2 := TButton2.Create(self);
Button2.ParentWindow := hand;
Button2.BringToFront;
end
else
ShowMessage('handle not found');
end;
如何解決它?
感謝名單
謝謝你給我直觀的問題... – lyborko