MDI 예제에도 많이 나와있는 그대로입니다.
DLL 에서 아래와 같은 함수를 호출합니다.
procedure OpenForm(AOwner: TApplication);
var
Form2: TForm2;
begin
Form2 := TForm2.Create(AOwner);
Form3 := TForm3.Create(AOwner); <- 새로운 폼을 추가하였습니다.
Form2.FormStyle := fsMDIChild;
Form2.Show;
end;
Form2에서는 정상적으로 Form3의 컴포넌트를 사용합니다.
근데 Form3에서 Form2의 컴포넌트를 사용하지 못합니다.
예를 들면...
procedure TForm3.Button1Click(Sender: TObject);
begin
Form2.Memo1.lines.Text := Memo1.lines.Text; //<- 이것이 먹지 않습니다.
close;
end;
전에 어떻하다가 성공을 했는데 날려먹었습니다.
적어둘껄....ㅜㅜ;;;
아시는 분은 답변 부탁드리겠습니다.
아래는 라이브러리 소스전문입니다.
library MDIChild;
uses
Windows,
Messages,
SysUtils,
Classes,
Forms,
Unit2 in 'Unit2.pas' {Form2},
Unit3 in 'Unit3.pas' {Form3};
var
DLLApp: TApplication;
DLLScreen: TScreen;
procedure Open(AApp: TApplication; AScr: TScreen); stdcall;
begin
if Assigned(DLLProc) then
begin
//
// DLL UnLoad시를 대비한 백업
//
DLLApp := Application;
DLLScreen := Screen;
//
// DLL을 호출한 Application의 인스턴스로 대체
//
Application := AApp;
Screen := AScr;
end;
OpenForm(AApp);
end;
procedure MyDllProc(const Reason: Integer);
begin
if Reason = DLL_PROCESS_DETACH then
begin
if Assigned(DLLApp) then
Application := DLLApp;
if Assigned(DLLScreen) then
Screen := DLLScreen;
end;
end;
exports
Open;
begin
DLLApp := nil;
DLLScreen := nil;
DLLProc := @MyDllProc;
end.
|