DLL 的问题!!!(CLX Application) 急!急!急!急!急!(33分)

  • 主题发起人 主题发起人 lordofbinladen
  • 开始时间 开始时间
L

lordofbinladen

Unregistered / Unconfirmed
GUEST, unregistred user!
DLL 部份:<br><br>function fX(h: THandle): boolean; stdcall;<br>var OldH : THandle;<br>begin<br>OldH := Application.Handle;<br>Application.Handle := H;<br>form1 := Tform1.Create(Application);<br>try<br>&nbsp; form1.ShowModal;<br>&nbsp; result := true;<br>finally<br>&nbsp; form1.Free;<br>&nbsp; Application.Handle := OldH;<br>end;<br>end;<br><br>CLX Application 主程序部份:<br><br>fx(Application.Handle); --&gt;[Error]Incompatible types : 'Cardinal' and 'QApplicationH' &nbsp;<br><br>请问该如何是好?<br><br>&nbsp;<br>
 
不要传handle<br>直接传application
 
复上我的源码,供参考<br>var<br>&nbsp; OldApp: TApplication;<br>&nbsp; OldScr: TScreen;<br><br>procedure ShowFrm(P_MainApp: TApplication); StdCall;<br>var<br>&nbsp; V_ChildFrm: TFrm_Register;<br>&nbsp; i: Integer;<br>begin<br>&nbsp; if not Assigned(OldApp) then<br>&nbsp; begin<br>&nbsp; &nbsp; OldApp:= Application;<br>&nbsp; &nbsp; Application:= P_MainApp;<br>&nbsp; end;<br><br>&nbsp; V_ChildFrm:= TFrm_Register.Create(Application.MainForm);<br>&nbsp; V_ChildFrm.Show;<br>end;<br><br>procedure MyLibraryProc(Reason:integer);<br>begin<br>&nbsp; if Reason=DLL_PROCESS_DETACH then<br>&nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp; Application:=OldApp;<br>&nbsp; &nbsp; end;<br>end;<br><br>{$R *.res}<br><br>exports<br>&nbsp; ShowFrm;<br><br>begin<br>&nbsp; DllProc:=@MyLibraryProc;<br>end.
 
可惜分太少
 
还没解决吗
 
gboyjuan: <br>可以e-Mail 个完整的程序给我吗?<br>呵。我暂时没什么分了, 我以后定加给你。
 
DLL 部份:<br><br>function fX(aApp: TApplication): boolean; stdcall;<br>begin<br>form1 := Tform1.Create(aApp);<br>try<br>&nbsp; form1.ShowModal;<br>&nbsp; result := true;<br>finally<br>&nbsp; form1.Free;<br>end;<br>end;<br>可不可以
 
主程序部份如何?<br>主程序部份如何?
 
function ShowCalendar(AHandle: THandle):boolean<br>var<br>&nbsp;DLLForm: TDllForm;<br>begin<br>&nbsp;// Copy application handle to DLL's TApplication object<br>&nbsp;Application.Handle := AHandle;<br>&nbsp;DLLForm := TDLLForm.Create(Application);<br>..... <br>end;<br><br>然后在调用窗体里它就如下调用:<br>ShowCalendar(Application.Handle)<br>
 
后退
顶部