应用是MDI结构,同时想做动态模块的添加,所以就把主程序做成MDI窗体,所有其他子模块都以DLL的形式,子模块的窗体都是MDI子窗体,都放在DLL里,但是调用这些DLL中的子窗体的时候,总是提示"没有当前活动的MDI窗体"!怎么解决呀?
将Application和MDIFrame作为参数传递给DLL。
DLL中的Application.Handle默认是0。
多谢了! :) 我用下面的方法试了一下可以:
function _Close: HRESULT; stdcall;
file:
begin
Application := TmpOldApp;
end;
function _Open(Aapp: TApplication): TDModule; stdcall;
var
testM: TDMTempModule;
begin
if Application.Handle = 0 then
TmpOldApp := Application;
Application := Aapp;
frmtemp := TFrmtemp.CreateParented(Aapp.MainForm.Handle);
end;
另外在Help里找到这句话:
Note: When writing a DLL that uses VCL forms, assign the window handle
of the host EXE's main window to the DLL's Application.Handle
property. This makes the DLL's form part of the host application.
Never assign to the Handle property in an EXE.
但是好像没用! :(