2012-04-12 91 views
2

我只是在它 創造一個雙贏的形式應用 與Gecko.GeckoWebBrowser,當我瀏覽到與具有href屬性設置爲 javascript中的錨頁:打印()並點擊它,打印對話框顯示,但事實證明,當我點擊取消按鈕對話框 Gecko.GeckoWebBrowser被銷燬,我的意思是控制接收WM_DETROY消息 任何線索可能發生的事情在這裏? 我可以如何防止它? 我修改了壁虎FX Gecko.GeckoWebBrowser windows程序和漁獲量和繞過Windows消息,但似乎並沒有幫助 順便說一句,我使用的XULRunner-11.0.en-US.win32和geckofx-11.dll 問候GeckoFX - 的WinForms - 的javascript:打印()

回答

0

看着firefox代碼,它看起來像firefox發送WM_DESTROY消息。

nsPrintingPromptService::ShowPrintDialog(nsIDOMWindow *parent, nsIWebBrowserPrint *webBrowserPrint, nsIPrintSettings *printSettings) 
{ 
    NS_ENSURE_ARG(parent); 

    HWND hWnd = GetHWNDForDOMWindow(parent); 
    NS_ASSERTION(hWnd, "Couldn't get native window for PRint Dialog!"); 

    return NativeShowPrintDialog(hWnd, webBrowserPrint, printSettings); 
} 



nsresult NativeShowPrintDialog(HWND    aHWnd, 
           nsIWebBrowserPrint* aWebBrowserPrint, 
           nsIPrintSettings* aPrintSettings) 
{ 
    PrepareForPrintDialog(aWebBrowserPrint, aPrintSettings); 

    nsresult rv = ShowNativePrintDialog(aHWnd, aPrintSettings); 
    if (aHWnd) { 
    ::DestroyWindow(aHWnd); 
    } 

    return rv; 
} 

我不知道爲什麼它會這樣做。

一些選項來解決這個問題:

  • 打開 「print.always_print_silent」
  • 提供並註冊自己的nsIPrintingPromptService
  • 提供並註冊自己的nsIWindowWatcher服務。

的nsIWindowWatcher方式貌似正確的方式做到這一點看GetHWNDForDOMWindow:

HWND 
nsPrintingPromptService::GetHWNDForDOMWindow(nsIDOMWindow *aWindow) 
{ 
    nsCOMPtr<nsIWebBrowserChrome> chrome; 
    HWND hWnd = NULL; 

    // We might be embedded so check this path first 
    if (mWatcher) { 
     nsCOMPtr<nsIDOMWindow> fosterParent; 
     if (!aWindow) 
     { // it will be a dependent window. try to find a foster parent. 
      mWatcher->GetActiveWindow(getter_AddRefs(fosterParent)); 
      aWindow = fosterParent; 
     } 
     mWatcher->GetChromeForWindow(aWindow, getter_AddRefs(chrome)); 
    } 

    if (chrome) { 
     nsCOMPtr<nsIEmbeddingSiteWindow> site(do_QueryInterface(chrome)); 
     if (site) 
     { 
      HWND w; 
      site->GetSiteWindow(reinterpret_cast<void **>(&w)); 
      return w; 
     } 
    }