日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

Delphi中DLL或Package窗体载入与显示

發(fā)布時間:2024/4/17 编程问答 41 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Delphi中DLL或Package窗体载入与显示 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

Delphi應(yīng)用程序架構(gòu)中有一種模式,采用DLL或Package存儲業(yè)務(wù)窗體,當(dāng)需要時從其中載入到主程序中,這時候需要對DLL或Package中窗體進(jìn)行處理,步驟如下:

1、定義窗體基類

typeTfrmBase = class(TForm)Panel1: TPanel;private{ Private declarations }protectedprocedure Loaded;override;public{ Public declarations }procedure UpdateActions; override;end;TfrmBaseClass = class of TfrmBase;implementation{$R *.dfm}{ TfrmBase }procedure TfrmBase.Loaded; begininherited; //將窗體改變?yōu)榍度牖?/span> align := alClient;BorderStyle := bsNone;BorderIcons := []; end;procedure TfrmBase.UpdateActions; begininherited;//將方法Public化 end; ?

2、創(chuàng)建具體的實例窗體

TfrmDll = class(TfrmBase)

?

3、通過窗體數(shù)據(jù)窗體類

function GetDllFormClass : TfrmBaseClass; beginResult := TfrmDll; end;exportsGetDllFormClass;

?

4、主窗體中動態(tài)載入DLL和創(chuàng)建DLL中的窗體對象

procedure TfrmMain.Button1Click(Sender: TObject); beginif DllHandle > 0 thenExit;DllHandle := LoadLibrary('FormDll.dll');if DllHandle > 0 thenbeginGetDllFormClass := GetProcAddress(DllHandle, 'GetDllFormClass');ifAssigned(GetDllFormClass) thenbegin cfrm := GetDllformClass;vfrm := cfrm.Create(Application); //設(shè)置窗體的Parent,通過ParentWindow方法實現(xiàn),這點很重要vfrm.ParentWindow := TabSheet1.Handle; end;end; end;

5、在主窗體上放置一個TApplicationEvents控件,在OnIdle事件中填寫以下代碼:

procedure TfrmMain.ApplicationEvents1Idle(Sender: TObject; var Done: Boolean); begin//當(dāng)系統(tǒng)空閑時,處理子窗體的ActionUpdate事件if Assigned(vfrm) thenvfrm.UpdateActions; end;

?

6、在OnMessage事件中填寫以下代碼:

procedure TfrmMain.ApplicationEvents1Message(var Msg: tagMSG;var Handled: Boolean); begin//如果窗體變量存在,則需要對消息進(jìn)行判斷和處理,如果是窗體變量的消息,則不進(jìn)一步處理if Assigned(vfrm) thenbeginif IsDialogMessage(vfrm.Handle, Msg) thenHandled := true;end; end; ?

至此完成。

轉(zhuǎn)載于:https://www.cnblogs.com/ChinaEHR/archive/2012/09/30/2709221.html

總結(jié)

以上是生活随笔為你收集整理的Delphi中DLL或Package窗体载入与显示的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。