아래의 샘플은 제가 DLL자료를 찾다가 어느분인지는 기억은 안나지만
예제를 쓰신것을 보고 공부했던 것입니다....
그런데...
아래의 소스데로 dll에서 MDI child form을 넣고 메인(exe) 프로그램에서
dll내의 child window를 생성하고 화면에 띄웠을때에...
이상하게도 Form1.Mdichildcount와 Form1.mdichildren[]이 전형 먹히질
않습니다.....
누가 저좀 도와주세요.....
벌써 4일째 열심히 해매고만 있습니다.................
------------------------------
델파이로 가는 길이 왜 이리도 멀기만 한지....
Listing A. MDIForms.dpr
library MDIForms;
uses
SysUtils,
Classes,
Forms,
Windows,
//MDI Child폼의 실제 unit
ChildU in 'ChildU.pas' {ChildForm};
var
DLLApp : TApplication;
procedure MyDLLProc(Reason: Integer);
begin
if Reason = DLL_PROCESS_DETACH then
{ DLL이 메모리에서 내려갈때}
{ 애플리케이션 포인터를 원위치 시킨다. }
if Assigned(DllApp) then
Application := DllApp;
end;
procedure ShowMDIChildForm(MainApp : TApplication);
var
Child : TChildForm;
begin
if not Assigned(DllApp) then
begin
DllApp := Application;
Application := MainApp;
end;
Child := TChildForm.Create(Application.MainForm);
Child.Show;
end;
exports ShowMDIChildForm;
begin
{ DllApp 변수를 초기화 한다. }
DllApp := nil;
DLLProc := @MyDLLProc;
end.
Listing B. MDIForms.dpr
unit MainAppU;
interface
uses
Windows, Messages, SysUtils, Classes,
Graphics, Controls, Forms, Dialogs, Menus;
type
TForm1 = class(TForm)
MainMenu1: TMainMenu;
Test1: TMenuItem;
ShowMDIChild1: TMenuItem;
N1: TMenuItem;
Exit1: TMenuItem;
procedure ShowMDIChild1Click(Sender: TObject);
procedure Exit1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
{ Import from the DLL. }
procedure ShowMDIChildForm(App : TApplication);
external 'mdiforms.dll';
var
Form1: TForm1;
implementation
{$R *.DFM}
{ Create a child form contained in the DLL. }
procedure TForm1.ShowMDIChild1Click(Sender: TObject);
begin
//DLL함수 호출 부분
ShowMDIChildForm(Application);
end;
procedure TForm1.Exit1Click(Sender: TObject);
begin
Close;
end;
end