如何在DLL中调用MDI child form?(100分)

  • 主题发起人 主题发起人 cowbird
  • 开始时间 开始时间
C

cowbird

Unregistered / Unconfirmed
GUEST, unregistred user!
参考了以往的一些讨论,但是好象没怎么解决。<br>是不是要传递Application, screen?怎么写?
 
1.在DLL定义一个函数传递fsMDIForm<br>2.选择project-options-packages-build with runtime packages
 
不太懂,能不能详细点,
 
不要传递变量,传递函数,例:<br>procedure ShowMDIForm(Sender: TObject);<br>begin<br>&nbsp; if fsMDIForm = nil then<br>&nbsp; &nbsp; &nbsp;fsMDIForm := TfsMDIForm.Create(Application)<br>&nbsp; else<br>&nbsp; &nbsp; with fsMDIForm do<br>&nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp; BringToFront;<br>&nbsp; &nbsp; &nbsp; if WindowState = wsMinimized then WindowState := wsNormal;<br>&nbsp; &nbsp; end;<br>end;<br><br>另外,需要在fsMDIForm的OnClose中添加如下代码<br>fsMDIForm := nil;<br>Action := caFree;<br>
 
能不能讲的详细点,
 
我有详细的代码不过今天忙改天给你讨论一下我已做成功了
 
有谁知道?请告诉我
 
在dll中建立如下一个函数:<br>function callchiForm(chiForm:TForm):Boolean;stdcall;<br>begin<br>&nbsp; &nbsp;showmessage('子窗口名称是:'+chiForm.Name) <br>end;<br><br>&nbsp;exports<br>&nbsp; callchiForm;<br>在主程序中使用:<br>function callchiForm(chiForm:TForm):Boolean;stdcall;external '编译过的dll文件.dll';<br>在一个事件中调用:<br>procedure TForm1.BitBtn1Click(Sender: TObject); &nbsp;//form1为mdiForm<br>begin<br>&nbsp;callchiForm(from2);//form2为主窗口下的一个子窗口<br>end;
 
需要对这两个参数保留,另外要写个DLLProc来释放<br>{Called whenever DLL entry point is called}<br><br>procedure LibraryProc(Reason: Integer);<br>begin<br>&nbsp; Screen:=DllScreen;<br>&nbsp; Application:=DllApplication;<br>end;<br>begin<br>&nbsp; DllApplication:=Application;<br>&nbsp; DllScreen:=Screen;<br>&nbsp; DLLProc:=@LibraryProc;<br>end.
 
接受答案了.
 

Similar threads

后退
顶部