打开dll窗口:
Tsf = function(PluginHandle: THandle; Main: THandle; InitiaData: TInitData): TForm; stdcall;
tab := TRzTabSheet.Create(nil);
tab.Caption := Trim(TButton(Btn).Caption);
tab.PageControl := RzPageControl1;
RzPageControl1.ActivePage := tab;
aform := sf(DLLHandle, frmmain.Handle, InitData);//无需传递宿主句柄
AForm.Width := tab.Width;
AForm.Height := tab.Height;
Windows.SetParent(AForm.Handle, tab.Handle);//(关键点)
AForm.Show;
dll工程文件:
procedure doDLL(Reason: Integer); //入口函数
begin
case Reason of
DLL_PROCESS_ATTACH: begin
dxInitializeGDIPlus;
end;
DLL_PROCESS_DETACH: begin
//----------销毁窗体-----------
if Assigned(frmrcys) then
frmrcys.Free;
dxFinalizeGDIPlus;
end;
end;
end;
function ShowForm(PluginHandle: THandle; Main: THandle; InitiaData: TInitData): TForm; stdcall;
begin
MainHwd := Main;
InitData := InitiaData;
DllHandle := PluginHandle;
//-----------------创建窗体------------
if frmrcys = nil then begin
frmrcys := Tfrmrcys.Create(nil);
frmrcys.Hide;
end else
frmrcys.WindowState := wsNormal;
Result := frmrcys;
end;
exports
ShowForm;
begin
DLLProc := @doDLL;
doDLL(DLL_PROCESS_ATTACH);
end.
纯 dll窗体 终极方法
最新推荐文章于 2021-05-20 03:54:57 发布