Create a new form, put a Button1, a Panel1, and then put a Button2 on the Panel1, test results:
procedureTform1.button1click (sender:tobject);begin ifIsChild (handle, handle) ThenShowMessage ('Yes') ElseShowMessage ('No'); //show no because the form is not its own childifIsChild (handle, Button1.handle) ThenShowMessage ('Yes') //Show Yes ElseShowMessage ('No'); ifIsChild (handle, Panel1.handle) ThenShowMessage ('Yes') //Show Yes ElseShowMessage ('No'); ifIsChild (handle, Button2.handle) ThenShowMessage ('Yes') //Show Yes, to study why ElseShowMessage ('No');End;procedureTform1.button2click (sender:tobject);beginShowMessage (button2. Parent.name); //Display Panel1 End;
Twincontrol.createwindowhandle uses tcreateparams.wndparent as a handle to the parent window, when is the parent window of the Button2 set?
IsChild API is not the same as the parent in Delphi (Windows window itself cannot be its own child window, but Delphi does not necessarily)