首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > .NET >

DLL中MDI子窗体有关问题

2013-09-06 
DLL中MDI子窗体问题library BaseInfo{ Important note about DLL memory management: ShareMem must be t

DLL中MDI子窗体问题
library BaseInfo;

{ 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
  ShareMem,
  SysUtils,
  Classes,
  Forms,
  Dialogs,
  Windows,
  Messages,
  UBase in '..\Pubs\UBase.pas' {FBase},
  USupplier in 'USupplier.pas' {FSupplier},
  UTreeCodeSet in '..\Pubs\UTreeCodeSet.pas' {FTreeCodeSet},
  UMember in 'UMember.pas' {FMember},
  UStorage in 'UStorage.pas' {FStorage},
  UCustomer in 'UCustomer.pas' {FCustomer};

{$R *.res}
var
DLLApp: TApplication;

function InitFSupplier(var App: TApplication;ParentForm: TForm): Boolean;export; stdcall;//供应商
begin
  try
    Application:= App;
    if FSupplier=nil then
    begin
      FSupplier:= TFSupplier.Create(ParentForm);
      FSupplier.FormStyle:= fsMDIChild;
      FSupplier.WindowState:=wsMaximized;
      FSupplier.Show;
    end else
    begin
      FSupplier.Show;
      FSupplier.bringToFront;
    end;
  except
  end;
end;

procedure DLLUnloadProc(Reason: Integer); register;
begin
  if Reason = DLL_PROCESS_DETACH then
    Application:=DLLApp;


end;

exports
  InitFSupplier;
begin
  DLLApp:=Application;
  DLLProc := @DLLUnloadProc;
end.

各位大虾,如上创建MDI子窗体第一次是可以的,但如果关掉子窗口第二次就不会显示出来了,子窗体onclose里
Action:=cafree了,按道理上面代码应该会重新创建一个子窗口啊。这是咋会事呀/
[解决办法]
你可以参考我资源里面的这个例子http://download.csdn.net/detail/feiba7288/5094359
[解决办法]
FSupplier在哪儿定义的?

窗体关闭时后, 给变量赋值 : FSupplier := nil;

热点排行