Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to set parent of object with parent's handle???

1,866 views
Skip to first unread message

LatinaLuva

unread,
Apr 9, 2002, 4:44:36 AM4/9/02
to
I am designing a function to create a form within a DLL. In my function, I
pass the handles of both the application variable and a specified parent
control. After getting the parent control's handle, how do I make the form
that I have created within the DLL a child of the parent that is specified
by the handle passed as a parameter?

Thanks!

Steve Kothenbeutel
skothe...@consultant.com

Biplab De

unread,
Apr 9, 2002, 8:37:40 AM4/9/02
to
Try with the following function
windows.SetParent(hWndChild, hWndNewParent: HWND): HWND


Thanks,
Biplab

"LatinaLuva" <Latin...@mexico.com> wrote in message
news:3cb2ace4_1@dnews...

LatinaLuva

unread,
Apr 9, 2002, 9:07:14 AM4/9/02
to
I tried the function out... but nothing happened... after executing the
"show" method on the form, nothing showed. Here is the sequence of
commands:

Form1 := TFormMisc.Create(nil);
with Form1 do
begin
SetParent(Handle, fParentHandle);
show;
end;

Is these anything else I need to do to get the form to show within a
particular control within my calling exe program?

Thanks!

"Biplab De" <bip...@sysmetricsolutions.com> wrote in message
news:3cb2e0a5_1@dnews...

Biplab De

unread,
Apr 10, 2002, 8:56:31 AM4/10/02
to
Without setting parent handle my program works fine. see below.....

library pdll;
uses
SysUtils,
Windows,
Classes,
forms;

{$R *.RES}

function CreateAForm(AParentHandle: HWND):boolean; stdcall;
var
Form1: TForm;
begin
Form1 := TForm.Create(nil);
with Form1 do
begin
//SetParent(Handle, AParentHandle);
Caption:= 'Creating a form with-in a DLL';
showmodal; // Show;
end;
end;

exports
CreateAForm;
end.
--------------------------------------
DLL Calling program

unit Unit1;

interface

uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
function CreateAForm(AParentHandle:HWND): boolean stdcall; external
'pdll.dll';
var
Form1: TForm1;

implementation
{$R *.DFM}

procedure TForm1.Button1Click(Sender: TObject);
begin
CreateAForm(Application.handle);
end;

end.

Thanks,
Biplab


"LatinaLuva" <Latin...@mexico.com> wrote in message

news:3cb3fcaa_1@dnews...

LatinaLuva

unread,
Apr 10, 2002, 8:54:40 PM4/10/02
to
Thanks for the reply... but what I am trying to accomplish is embedding the
form created within the DLL within a container (ie Panel) within my calling
application. In order to do this, I need to somehow set the parent of the
DLL form. I know how to create a form... that is not a problem... the
problem is that I can't get it to be shown within a panel... for example.

Thanks for the input.


"Biplab De" <bip...@sysmetricsolutions.com> wrote in message

news:3cb43671_1@dnews...

0 new messages