Главная страница
    Top.Mail.Ru    Яндекс.Метрика
Форум: "Основная";
Текущий архив: 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
1-66822
Beka
2002-03-05 11:51
2002.03.21
Помогите пожалуйста. Я написалкод который виводит текст под углом


3-66733
Revo
2002-02-15 14:01
2002.03.21
Как конвертировать базу данных из dBase в InterBase?


7-67023
Leviathan
2001-12-17 18:14
2002.03.21
PlaySound


1-66815
kserg@ukr.net
2002-03-07 11:21
2002.03.21
И ещё небольшой вопросик (события формы)


3-66777
Лёша
2002-02-22 14:26
2002.03.21
Реализация post_event.





Afrikaans Albanian Arabic Armenian Azerbaijani Basque Belarusian Bulgarian Catalan Chinese (Simplified) Chinese (Traditional) Croatian Czech Danish Dutch English Estonian Filipino Finnish French
Galician Georgian German Greek Haitian Creole Hebrew Hindi Hungarian Icelandic Indonesian Irish Italian Japanese Korean Latvian Lithuanian Macedonian Malay Maltese Norwegian
Persian Polish Portuguese Romanian Russian Serbian Slovak Slovenian Spanish Swahili Swedish Thai Turkish Ukrainian Urdu Vietnamese Welsh Yiddish Bengali Bosnian
Cebuano Esperanto Gujarati Hausa Hmong Igbo Javanese Kannada Khmer Lao Latin Maori Marathi Mongolian Nepali Punjabi Somali Tamil Telugu Yoruba
Zulu
Английский Французский Немецкий Итальянский Португальский Русский Испанский