Articles   Members Online:
-Article/Tip Search
-News Group Search over 21 Million news group articles.
-Delphi/Pascal
-CBuilder/C++
-C#Builder/C#
-JBuilder/Java
-Kylix
Member Area
-Home
-Account Center
-Top 10 NEW!!
-Submit Article/Tip
-Forums Upgraded!!
-My Articles
-Edit Information
-Login/Logout
-Become a Member
-Why sign up!
-Newsletter
-Chat Online!
-Indexes NEW!!
Employment
-Build your resume
-Find a job
-Post a job
-Resume Search
Contacts
-Contacts
-Feedbacks
-Link to us
-Privacy/Disclaimer
Embarcadero
Visit Embarcadero
Embarcadero Community
JEDI
Links
How to load a frame from a DLL Turn on/off line numbers in source code. Switch to Orginial background IDE or DSP color Comment or reply to this aritlce/tip for discussion. Bookmark this article to my favorite article(s). Print this article
27-Aug-02
Category
VCL-General
Language
Delphi 5.x
Views
128
User Rating
No Votes
# Votes
0
Replies
0
Publisher:
DSP, Administrator
Reference URL:
DKB
			Author: Tomas Rutkauskas

I want load a TFrame from a DLL in the main program. I always get the error "No 
parent window", although I already have the main form's handle.

Answer:

1   library DLLFrame;
2   
3   uses
4     SysUtils, Classes, Controls, Forms, Windows,
5     DllFrameFrame in 'DllFrameFrame.pas' {Frame1: TFrame};
6   
7   procedure AddFrame(ApplicationHandle, ParentHandle: THandle); stdcall;
8   var
9     Frame1: TFrame1;
10    AppHandle: THandle;
11  begin
12    AppHandle := Application.Handle;
13    Application.Handle := ApplicationHandle;
14    Frame1 := TFrame1.Create(Application);
15    Frame1.ParentWindow := ParentHandle;
16    SetParent(Frame1.Handle, ParentHandle);
17    Frame1.Align := alClient;
18    Frame1.Visible := True;
19    Application.Handle := AppHandle;
20  end;
21  
22  exports
23    AddFrame;
24  
25  begin
26  end.
27  
28  unit DllFrameFrame;
29  
30  interface
31  
32  uses
33    Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, 
34  StdCtrls;
35  
36  type
37    TFrame1 = class(TFrame)
38      Label1: TLabel;
39      Label2: TLabel;
40    private
41      { Private declarations }
42    public
43      { Public declarations }
44    end;
45  
46  implementation
47  
48  {$R *.dfm}
49  
50  end.
51  
52  program LoadDLLFrame;
53  
54  uses
55    Forms, LoadDLLFrameMn in 'LoadDLLFrameMn.pas' {Form1};
56  
57  {$R *.res}
58  
59  begin
60    Application.Initialize;
61    Application.CreateForm(TForm1, Form1);
62    Application.Run;
63  end.
64  
65  unit LoadDLLFrameMn;
66  
67  interface
68  
69  uses
70    Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
71    Dialogs, ExtCtrls, StdCtrls;
72  
73  type
74    TForm1 = class(TForm)
75      Panel1: TPanel;
76      Button1: TButton;
77      procedure Button1Click(Sender: TObject);
78    private
79      { Private declarations }
80    public
81      { Public declarations }
82    end;
83  
84  var
85    Form1: TForm1;
86  
87  procedure AddFrame(ApplicationHandle, ParentHandle: THandle); stdcall;
88  
89  implementation
90  
91  {$R *.dfm}
92  
93  procedure AddFrame(ApplicationHandle, ParentHandle: THandle); stdcall;
94    external 'DLLFrame.dll';
95  
96  procedure TForm1.Button1Click(Sender: TObject);
97  begin
98    AddFrame(Application.Handle, Panel1.Handle);
99  end;
100 
101 end.


			
Vote: How useful do you find this Article/Tip?
Bad Excellent
1 2 3 4 5 6 7 8 9 10

 

Advertisement
Share this page
Advertisement
Download from Google

Copyright © Mendozi Enterprises LLC