全國最多中醫師線上諮詢網站-台灣中醫網
發文 回覆 瀏覽次數:932
推到 Plurk!
推到 Facebook!

用DLL动态调用childform的问题???

尚未結案
bolidehi
一般會員


發表:11
回覆:11
積分:4
註冊:2004-03-10

發送簡訊給我
#1 引用回覆 回覆 發表時間:2004-05-13 14:08:37 IP:218.88.xxx.xxx 未訂閱
在一个MIDFORM中的按钮通过DLL调用一个CHILFORM的程式如下: library childfrm;    { Important note about DLL memory management: ShareMem must be the   first unit in your library's USES clause AND your project's (select   Project-View Source) USES clause if your DLL exports any procedures or   functions that pass strings as parameters or function results. This   applies to all strings passed to and from your DLL--even those that   are nested in records and classes. ShareMem is the interface unit to   the BORLNDMM.DLL shared memory manager, which must be deployed along   with your DLL. To avoid using BORLNDMM.DLL, pass string information   using PChar or ShortString parameters. }    uses   SysUtils,   Classes,   windows,   Dialogs,   forms,   Controls,   child in 'child.pas' {childform};    function test(app:tapplication):Tform;stdcall;export; var  frm:tform; begin    application:=app;    showmessage('123');    frm:=Tchildform.create(app);    result:=frm;    try    frm.ShowModal;    except    showmessage('错误!');    end;    end; exports test; {$R *.res} begin end.        //CHILDFORM的程式: unit child;    interface    uses   Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,   Dialogs;    type   Tchildform = class(TForm)     procedure FormCreate(Sender: TObject);     procedure FormClose(Sender: TObject; var Action: TCloseAction);   private     { Private declarations }   public     { Public declarations }   end;    var   childform: Tchildform;    implementation    {$R *.dfm}    procedure Tchildform.FormCreate(Sender: TObject); begin formstyle:= fsmdichild; end;    procedure Tchildform.FormClose(Sender: TObject; var Action: TCloseAction); begin action:=cafree; childform:=nil; end;    end.     //MDIFORM程式: unit mdiform;    interface    uses   Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,   Dialogs, StdCtrls;    type   tfunc=function (app:Tapplication):Tform;stdcall;   TForm1 = class(TForm)     Button1: TButton;     procedure Button1Click(Sender: TObject);   private     { Private declarations }   public     { Public declarations }   end;    var   Form1: TForm1;    implementation    {$R *.dfm}    procedure TForm1.Button1Click(Sender: TObject); var     Th:Thandle;     Tf:TFunc;    Tp:TFarProc; path:string; begin   path:=extractfilepath(application.ExeName);   showmessage(path);   Th:=LoadLibrary(pchar(path+'childfrm.dll'));   {装载DLL}   if Th>0 then      try          Tp:=GetProcAddress(Th,PChar('test'));       if Tp<>nil then       begin         Tf:=TFunc(Tp);         tf(application);       end      else ShowMessage('TestC函数没有找到');       finally     FreeLibrary(Th); {释放DLL}   end else ShowMessage('childfrm.dll没有找到'); end; end.    在调试时在运行到frm.ShowModal出错,麻烦各位指点指点........
vagrant
一般會員


發表:29
回覆:72
積分:20
註冊:2003-07-04

發送簡訊給我
#2 引用回覆 回覆 發表時間:2004-05-13 17:01:33 IP:219.130.xxx.xxx 未訂閱
對於連接資料庫的,應該如何傳遞 ADOConnection1來進行分享呢?謝謝
bolidehi
一般會員


發表:11
回覆:11
積分:4
註冊:2004-03-10

發送簡訊給我
#3 引用回覆 回覆 發表時間:2004-05-17 12:38:49 IP:218.88.xxx.xxx 未訂閱
这与ADOCONNETION无关,我只是想知道通过dll调用MDI窗口而已.
bolidehi
一般會員


發表:11
回覆:11
積分:4
註冊:2004-03-10

發送簡訊給我
#4 引用回覆 回覆 發表時間:2004-05-17 12:48:06 IP:218.88.xxx.xxx 未訂閱
vagrant:你好! 我现已经能通过调用MDI,但是在关闭时他把整个界面都关闭了. 你能告诉我你E-MAIL吗?我把整个文挡发给你.帮我看看! 谢谢!
系統時間:2024-05-19 9:34:42
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!