Клубове Дир.бг
powered by diri.bg
търси в Клубове diri.bg Разширено търсене

Вход
Име
Парола

Клубове
Dir.bg
Взаимопомощ
Горещи теми
Компютри и Интернет
Контакти
Култура и изкуство
Мнения
Наука
Политика, Свят
Спорт
Техника
Градове
Религия и мистика
Фен клубове
Хоби, Развлечения
Общества
Я, архивите са живи
Клубове Дирене Регистрация Кой е тук Въпроси Списък Купувам / Продавам 18:00 02.07.24 
Клубове/ Компютри и Интернет / Delphi Пълен преглед*
Информация за клуба
Тема Re: Control ListView has no parent window [re: Eventer]
Автор PhantomASМодератор (няма)
Публикувано08.06.03 22:27  



Ами едно просто нещо - как точно инициализираш Form2 - когато формата е поставена в DLL (не bpl) има една тънкост - предаване на правилния Application обект. А ето ти и един пример.

{ To add a form to a DLL you have to remember these things:
1. assign the calling programs Application.Handle to the DLL's Application.Handle
2. Write one or two exported functions that handles the interaction with the calling program
3. include sharemem as the first unit in the DLL's uses clause if the exported functions uses strings
4. if you are going to show a mode-less form, you should return a handle to your form in the "Show" function and require it as a parameter in the "Close" function
5. always create the form with the Application object as the Owner
6. restore the DLL's Application.Handle after closing the form

You don't have to do anything special to add a form to a DLL: just add the forms filename to the uses clause and Delphi will compile it right into the DLL.

Here's an example with both modal and mode-less invocation. The examples just return an integer value, but you could of course return just about anything:
}

library testDLL;

uses
myTestFrom, SysUtils, Controls;


var
OldApphandle:longint = 0;

{ these functions are used with the mode-less form: }

{ AppHandle is the *calling* applications Handle }
function ShowTestForm(AppHandle:integer):longint;
var F:TmyTestForm;
begin
{ save current handle unless it's already done }
if Application.Handle <> AppHandle then
OldAppHandle := Application.Handle;
{ assign new }
Application.Handle := AppHandle;
{ create and show form }
F := TmyTestForm.Create(Application);
F.Show;
Result := longint(F);
end;

{ the input value, Handle, must be the same value as returned by ShowTestForm }
function CloseTestForm(Handle:longint):integer;
var F:TmyTestForm;
begin
{ typecast back to TForm (some sanity checks here would not be bad...}
F := TmyTestForm(Handle);
Result := F.SomeIntValue;
F.Close;
F.Free;
{ restore previous handle }
Application.Handle := OldAppHandle;
end;

{ this function is used to show the form modally }
function ShowTestFormModal(AppHandle:integer):longint;
var F:TmyTestForm;
begin
OldAppHandle := Application.Handle;
try
Application.Handle := AppHandle;
F := TmyTestForm.Create(Application);
try
if F.ShowModal = mrOK then
Result := F.SomeIntValue
else
Result := -1;
finally
F.Free;
end;
finally
Application.Handle := OldAppHandle;
end;
end;

{ finally export the functions: }

exports ShowTestForm name 'ShowTestForm', CloseTestForm name 'CloseTestForm',
ShowTestFormModal name 'ShowTestFormModal';

begin
end.

---
Е т'ва е живот!


Цялата тема
ТемаАвторПубликувано
* Control ListView has no parent window Eventer   08.06.03 18:14
. * Re: Control ListView has no parent window PhantomAS   08.06.03 22:27
. * The problem is the docking Eventer   09.06.03 09:00
. * Sorry не съм разбрал... PhantomAS   09.06.03 09:37
. * Всичко работи нормално... Eventer   09.06.03 11:01
. * Re: Всичко работи нормално... PhantomAS   09.06.03 11:39
. * Re: Всичко работи нормално... Eventer   09.06.03 12:08
. * Re: Всичко работи нормално... Mandor   10.06.03 15:14
. * Re: Всичко работи нормално... Eventer   11.06.03 20:20
Клуб :  


Clubs.dir.bg е форум за дискусии. Dir.bg не носи отговорност за съдържанието и достоверността на публикуваните в дискусиите материали.

Никаква част от съдържанието на тази страница не може да бъде репродуцирана, записвана или предавана под каквато и да е форма или по какъвто и да е повод без писменото съгласие на Dir.bg
За Забележки, коментари и предложения ползвайте формата за Обратна връзка | Мобилна версия | Потребителско споразумение
© 2006-2024 Dir.bg Всички права запазени.