【发布时间】:2013-01-28 04:14:30
【问题描述】:
我们有一个 Delphi 应用程序,它也是一个 COM 服务器,该应用程序有一个主窗体。当以自动化模式(smAutomation)启动时,我们需要将主窗体创建为父窗体。由于这个问题范围之外的几个原因,我们无法创建应用程序然后执行 COM 方法来重新设置主窗体,即重新设置必须在该过程的早期完成 - 就在创建主窗体之后。欣赏想法thx。
编辑:澄清
// Initialized as as an Application
if COMserver.startmode = smStandalone
begin
Application.Initialize;
Application.MainFormOnTaskbar := True;
Application.CreateForm(TForm1, Form1);
Application.Run;
End
Else
// Initialized as an automation server
if COMserver.startmode = smAutomation
Begin
// How do I set a Parent window handle property - this is called imediately after the COM client initializes the server
// how do I modify this call to create Form1 with a parent?
Application.CreateForm(TForm1, Form1);
End;
【问题讨论】:
-
我的意思是,你不能只测试
ComServer.StartMode在你需要知道如何创建主窗体的地方吗? -
感谢您的及时回复,澄清(希望)
-
你想设置什么。
ParentWindow还是Parent?为什么在调用CreateForm后不能分配这些属性?我还不清楚。 -
需要设置form1.parentwindow := WHandle,其中Whandle是从COM接口获取的。在应用程序初始化期间视频捕获窗口被放置在窗体上。如果父窗口在放置后更改,这些将无法正常工作。我正在寻找的顺序如下:1. 创建 COM 服务器,2. 设置句柄属性,3. 使用父级创建表单,4. 继续常规初始化。 DPR 中的初始化应该如何改变?非常感谢!
-
为什么不能在
Application.CreateForm之后立即执行ParentWindow := WHandle?如果为时已晚,那么您将需要覆盖TForm1.CreateParams并将其设置在那里。
标签: delphi com automation