Форум: "Основная";
Текущий архив: 2002.03.21;
Скачать: [xml.tar.bz2];
ВнизMDIChild в DLL Найти похожие ветки
← →
Awex (2002-03-05 09:48) [4]Если хочешь поместить MDIChild в DLL то нужно ей передать и
TApplication и TScreen
Ну примерно так:
unit DllInterface;
interface
uses Controls,Forms;
type
TAppInterface = record
AppMain: TApplication;
AppScreen: TScreen;
end;
TUnitDLL = procedure(AppInterface: TAppInterface); stdcall;
TResetDLL = procedure; stdcall;
TProcedure = procedure(Control:TWinControl); stdcall;
procedure SetContext(AppInterface: TAppInterface);
function GetContext: TAppInterface;
implementation
procedure SetContext(AppInterface: TAppInterface);
begin
with AppInterface do
begin
Application := AppMain;
Screen := AppScreen;
end;
end;
function GetContext: TAppInterface;
begin
with Result do
begin
AppMain := Application;
AppScreen := Screen;
end;
end;
end.
library UserDLL;
uses
ShareMem,
SysUtils,
Windows,
Controls,
Classes,
Forms,
Dialogs,
DlllFormUnt in "DlllFormUnt.pas" {DLLForm},
DLLInterface;
var
DllInterface: TAppInterface;
DLLForm: TDLLForm = nil;
procedure InitDLL(AppInterface: TAppInterface); stdcall;
begin
DllInterface := GetContext; // Сохраняем констекст
SetContext(AppInterface); // Устанавливаем контекст приложения
end;
procedure ResetDLL; stdcall;
begin
DLLForm.Free;
SetContext(DllInterface); // Востанавливаем контекст
end;
procedure HelloWorld; stdcall;
begin
DLLForm := TDLLForm.Create(Application);
DLLForm.Show;
end;
exports
HelloWorld,
InitDLL,
ResetDLL;
begin
end.
MAIN
.......
var
DLLInstance: THandle;
HelloWorld: TProcedure;
UnitDLL: TUnitDLL;
ResetDLL: TResetDLL;
procedure TForm1.StartClick(Sender: TObject);
begin
DLLInstance := LoadLibrary("UserDLL.dll");
@UnitDLL := GetProcAddress(DLLInstance, "InitDLL");
@ResetDLL := GetProcAddress(DLLInstance, "ResetDLL");
UnitDLL(GetContext);
@HelloWorld := GetProcAddress(DLLInstance, "HelloWorld");
HelloWorld;
end;
procedure TForm1.StopClick(Sender: TObject);
begin
ResetDLL; // УБИВАЕМ ЯВНО !!!!
FreeLibrary(DLLInstance);
end;
Страницы: 1 вся ветка
Форум: "Основная";
Текущий архив: 2002.03.21;
Скачать: [xml.tar.bz2];
Память: 0.44 MB
Время: 0.005 c