纯 dll窗体 终极方法

打开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.


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值