具体代码是这样的.Function Tfrm_frame.CreateChildForm(tLibHandle: THandle; tFormHandle: Integer): Boolean;
Var
Child : TMDIChild;
Begin
{ create a new MDI child window }
//showmessage('准备创建窗体');
Child := TMDIChild.Create(self);
Child.CanSize := true;
self.Delay(100);
//指定DLL窗体的父窗体为MDI的子窗体
TForm(tFormHandle).ParentWindow := Child.Handle;
//设置边界
TForm(tFormHandle).BorderStyle := bsNone;
.
.
.
.
.
.
end;Procedure Tfrm_frame.openModule(dllPath: String);
Var
ModuleCreateProc : TCreateModule;
tmpLibHandle : THandle;
tmpFormHandle : Integer;
showType : Integer; //显示类型,0:模式窗体 1:非模式窗体
c_dllpath : Array[0..255] Of Char;
Begin
StrPCopy(c_dllpath, dllPath);
tmpLibHandle := LoadLibrary(c_dllpath); If (tmpLibHandle <> 0) Then
Begin
tmpFormHandle := Application.Handle;
ModuleCreateProc := GetProcAddress(tmpLibHandle, 'CreateModule');
ModuleCreateProc(tmpFormHandle, Application); CreateChildForm(tmpLibHandle, tmpFormHandle, showType);
End
end
Var
Child : TMDIChild;
Begin
{ create a new MDI child window }
//showmessage('准备创建窗体');
Child := TMDIChild.Create(self);
Child.CanSize := true;
self.Delay(100);
//指定DLL窗体的父窗体为MDI的子窗体
TForm(tFormHandle).ParentWindow := Child.Handle;
//设置边界
TForm(tFormHandle).BorderStyle := bsNone;
.
.
.
.
.
.
end;Procedure Tfrm_frame.openModule(dllPath: String);
Var
ModuleCreateProc : TCreateModule;
tmpLibHandle : THandle;
tmpFormHandle : Integer;
showType : Integer; //显示类型,0:模式窗体 1:非模式窗体
c_dllpath : Array[0..255] Of Char;
Begin
StrPCopy(c_dllpath, dllPath);
tmpLibHandle := LoadLibrary(c_dllpath); If (tmpLibHandle <> 0) Then
Begin
tmpFormHandle := Application.Handle;
ModuleCreateProc := GetProcAddress(tmpLibHandle, 'CreateModule');
ModuleCreateProc(tmpFormHandle, Application); CreateChildForm(tmpLibHandle, tmpFormHandle, showType);
End
end
//指定DLL窗体的父窗体为MDI的子窗体
TForm(tFormHandle).ParentWindow := Child.Handle;
//设置边界
TForm(tFormHandle).BorderStyle := bsNone;
为
SetWindowLong(TForm(tFormHandle).Handle,GWL_STYLE,GetWindowLong(TForm(tFormHandle).Handle,GWL_STYLE) and not (WS_CAPTION or WS_THICKFRAME));
windows.SetParent(TForm(tFormHandle).Handle,Child.Handle);
试试
你看一下这个....
按着你的方法作了.快捷键是可以用了.但DLL窗体显示时,并没有在MDI子窗体中显示.并且,在我点击了MDI窗体的其他地方后,DLL窗体显示在主程序窗体后面了.
你的方法,我暂时无法在我现在的代码上实现,我的程序已经快作完了,马上要交.很感谢你的回复.
这就是用API把子窗体嵌到主窗体中呀
一般在主窗体中放一个panel,然后用
windows.SetParent(panel.Handle,ChildForm.Handle);