Приведенный ниже код создает кнопку на рабочем столе.
Код:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | <b> procedure </b> TForm1 . B_Click(Sender: TObject);
<b> begin </b>
ShowMessage( <font color="RoyalBlue"> 'aaa' </font> );
<b> end </b>;
<b> procedure </b> TForm1 . Button1Click(Sender: TObject);
<b> var </b>
h: HWND;
b: TButton;
<b> begin </b>
h := FindWindow( <font color="royalblue"> 'Progman' </font>, <font color="royalblue"> 'Program Manager' </font> );
b := TButton . Create( Owner );
<i><font color="royalblue">
b . ParentWindow := h;
b . Left := <font color="royalblue"> 10 </font>;
b . Top := <font color="royalblue"> 10 </font>;
b . Caption := <font color="royalblue"> 'Button' </font>;
b . OnClick := B_Click;
Windows . SetParent( b . Handle, h );
<b> end </b>;
|
Проблема в следующем. После смены родителя (
Windows.SetParent( b.Handle, h )) кнопка перестает реагировать на события (в данном случае на Click). Как сменить родителя и при этом сохранить события?