打印本文 打印本文 关闭窗口 关闭窗口
初探Delphi 7 中的插件编程
作者:武汉SEO闵涛  文章来源:敏韬网  点击数4829  更新时间:2009/4/23 18:26:40  文章录入:mintao  责任编辑:mintao
 

var

    DLL_Form:TFormOfficialMain;      //改成MAINFORM的NAME

 

//-----------------------------------------

//Name: ShowDLLForm

//Func: DLL插件调用入口函数

//Para: AHandle 挂靠程序句柄; ACaption 本窗体标题

//Rtrn: N/A

//Auth: CST

//Date: 2005-6-3

//-----------------------------------------

function ShowDLLForm(AHandle: THandle; ACaption: string; AUserID: string):boolean;

begin

    result:=true;

    try

        Application.Handle:=AHandle;    //挂靠到主程序容器

        DLL_Form:=TFormOfficialMain.Create(Application);  //改成MAINFORM的NAME

        try

            with DLL_Form do

            begin

                Caption := ACaption;

                StatusBar.Panels.Items[0].Text := AUserID;

                //Configure UI

                Show ;

            end;

        except

            on e:exception do

            begin

                dll_form.Free;

            end;

        end;

    except

        result:=false;

    end;

end;

 

//-----------------------------------------

//Name: FreeDLLForm

//Func: DLL插件调用出口函数

//Para: AHandle 挂靠程序句柄

//Rtrn: true/false

//Auth: CST

//Date: 2005-6-11

//-----------------------------------------

function FreeDLLForm(AHandle: THandle; ACaption: string; AUserID: string):boolean;

begin

    Application.Handle:=AHandle;    //挂靠到主程序容器

 

    if DLL_Form.Showing then DLL_Form.Close;  //如果窗口打开先关闭,触发FORM.CLOSEQUERY可取消关闭过程

    if not DLL_Form.Showing then

        begin

            DLL_Form.Free;

            result:=true;

        end                                     //仍然打开状态,说明CLOSEQUERY.CANCLOSE=FALSE

    else

        begin

            result:=false;

        end;

end;

 

end.

 

DLL工程文件代码如下:

 

library Official;

 

{ Important note about DLL memory management: ShareMem must be the

  first unit in your library''''s USES clause AND your project''''s (select

上一页  [1] [2] [3] [4] [5] [6] [7]  下一页

打印本文 打印本文 关闭窗口 关闭窗口