Delphi COM服务器初始化

时间:2013-02-12 18:49:29

标签: delphi com automation

我们有一个Delphi应用程序,它也是一个COM服务器,该应用程序有一个主窗体。在自动化模式(smAutomation)中启动时,我们需要将主窗体创建为父级。由于在这个问题范围之外的几个原因,我们无法创建应用程序然后执行COM方法来重新显示主窗体,即重新创建必须在过程的早期完成 - 就在创建主窗体之后。赞赏你的想法。

编辑:澄清

// 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; 

1 个答案:

答案 0 :(得分:0)

我可以看到两个选项:

  1. 在Application.CreateForm之后立即设置Form1.ParentWindow:= WHandle。
  2. 如果为时已晚,那么您需要覆盖TForm1.CreateParams并将其设置在那里。