你说的是把MDI子窗体写成DLL?

解决方案 »

  1.   

    不知道你要怎么样实现这个东西呢?你说的dll了是用delphi实现的吗?
    如果是这样的话我想其实可不可以这样:
    就是窗口还是由exe来实现,但是这一个窗口的WinProc由你的dll来实现,
    这就差不多是由dll来实现mdi的子窗口了,只不过要如果和exe的菜单
    之间有比较多的交互的话,就比较麻烦了.
      

  2.   

    要修改application.handle,查去年的论坛数据吧。
      

  3.   

    //DLL
    library Func;uses
      ShareMem,
      SysUtils,
      Classes,
      Forms,
      Windows,
      MConnect,
      Child2 in 'Child2.pas' {FormChild2};{$R *.RES}procedure CallModule();stdcall;export;
    begin
        if not Assigned(FormChild2) then
            FormChild2 := TFormChild2.Create(Application);
        FormChild2.Show;
    end;exports
       CallModule;begin
    end;//MDIChild单元:procedure TFormChild2.N9Click(Sender: TObject);
    begin
        Close;
    end;procedure TFormChild2.FormClose(Sender: TObject;
      var Action: TCloseAction);
    begin
        Action := caFree;
    end;procedure TFormChild2.FormDestroy(Sender: TObject);
    begin
        FormChild2 := nil;
    end; 
     
    //主程序:
    type
      TCallModule =  procedure();stdcall;var
        FormMain: TFormMain;
        LibHandle: HModule;
        procedure LoadModule(AModuleName: String);implementation{$R *.DFM}
    procedure LoadModule(AModuleName: String);
    var
        CallModule: TCallModule;
    begin
        LibHandle := LoadLibrary(PChar(AModuleName));
        if LibHandle = 0 then Exit;
            @CallModule := GetProcAddress(LibHandle,'CallModule');
        if @CallModule <> nil then
            CallModule();
    end;procedure TFormMain.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
    var
        iCount: Integer;
    begin
        if MessageDLG('是否退出?',mtConfirmation,[mbYes,mbNO],0) = mrYes then
        begin
            for iCount := 0 to MDIChildCount - 1 do
                MDIChildren[iCount].Close;       
            CanClose := True;
            if not (LibHandle = 0) then
                FreeLibrary(LibHandle);
        end else
            CanClose := False;
    end;关键是无论DLL还是EXE都要带运行时间包VCL50.bpl编译