2013-02-12 96 views
1

我們有一個Delphi應用程序,它也是一個COM服務器,應用程序有一個主窗體。在自動模式下啓動(smAutomation)時,我們需要創建主窗體作爲父模板。由於這個問題範圍之外的一些原因,我們不能創建應用程序,然後執行一個COM方法來重新恢復主窗體,即重建必須在整個過程中儘早完成 - 就在主窗體創建之後。欣賞想法thx。Delphi 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; 
+2

問題是怎麼回事? – 2013-02-12 18:55:35

+0

我的意思是,你不能在你需要知道如何創建主表單的時候測試ComServer.StartMode嗎? – 2013-02-12 19:16:17

+0

感謝您的及時回覆,澄清(希望) – user2046977 2013-02-12 21:19:28

回答

0

我可以看到兩個選項:

  1. 集Form1.ParentWindow:=例WHandle立即Application.CreateForm以下。
  2. 如果這太晚了,那麼你將需要覆蓋TForm1.CreateParams並將其設置在那裏。