Board index » delphi » HELP: I can't get the SetParent API function to compile

HELP: I can't get the SetParent API function to compile

I am new to programming in Delphi, so please excuse me if this is
a dumb error.  I can't get the SetParent function to compile, it
gives me a type mismatch on the handle property of a form.  However,
if I use the ShowWindow function, the handle property IS accepted
as a HWnd.  What gives?  Try the following code.  I have used setParent
in Visual Basic with no problems.

var
  ftest2: Tftest2;
  { DLL declarations - prototypes only }
  Function Setparent (wndChild: HWnd; wndParent : HWnd): HWnd;
  Function ShowWindow (wnd: HWnd; cmdShow : Integer): bool;
{ end of DLL declarations - prototypes only }

implementation

{ DLL declarations }
Function Setparent (wndChild: HWnd; wndParent : HWnd): HWnd; external 'User';
Function ShowWindow (wnd: HWnd; cmdShow : Integer): bool; external 'User';
{ end of DLL declarations }

{$R *.DFM}

procedure Tftest2.FormCreate(Sender: TObject);
var
  wndChild : Hwnd;
  wndParent : Hwnd;
  retval : Hwnd;
  bretval : bool;
begin
  wndChild := ftest2.handle;
  wndParent := ftest1.handle;
  {bretval := showWindow(wndParent, SW_SHOW);}
  retval := setparent (wndChild, wndParent);
end;

This won't compile, but the showWindow would.  Any ideas are welcome.

Thanks,

Eric J. Lannert
Northwestern University, Evanston, IL.   USA
lann...@ils.nwu.edu

 

Re:HELP: I can't get the SetParent API function to compile


On 31 Jul 1995 20:08:44 GMT, lann...@ils.nwu.edu (Eric J. Lannert)
wrote:

Quote
>I am new to programming in Delphi, so please excuse me if this is
>a dumb error.  I can't get the SetParent function to compile, it
>gives me a type mismatch on the handle property of a form.  However,
>if I use the ShowWindow function, the handle property IS accepted
>as a HWnd.  What gives?  Try the following code.  I have used setParent
>in Visual Basic with no problems.

The reference to SetParent is actually referring to the SetParent
method of TForm.  If you want to call the Windows API, you should use
WinProcs.SetParent.  You don't need to declare it, just use the
WinProcs unit.

You should also look at documentation for the Parent property.
--
Ray Lischner       (li...@tempest-sw.com)
Tempest Software, Corvallis, Oregon

Other Threads