纯 dll窗体 终极方法

来源:互联网 发布:魔法卡片搜卡软件 编辑:程序博客网 时间:2024/05/17 04:37
打开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.


原创粉丝点击