Re: Firefox 3.6 : How can I obtain a HWND from the corresponding nsIDOMDocument object?

Alexander Surkov <[email protected]>
Newsgroups gmane.comp.mozilla.accessibility
Organization http://groups.google.com
Message-ID <bb4674a6-a962-4d5b-8d2b-422aa6ecdc6a@s36g2000prh.googlegroups.com>
On Feb 24, 8:25 pm, "Oliveiros C," <[email protected]>
wrote:
> Dear List,
>
> I have this code , in which spiDocument is an nsIDOMDocument.
>
> nsresult lReturnVal;
>
> HWND hWnd=NULL,hParentWindow;
>
> nsCOMPtr<nsIDocument> spiDoc = do_QueryInterface(spiDocument);
>
> nsIPresShell *piShell = spiDoc -> GetPrimaryShell();
>
> if (piShell)
>
> {
>
> // Find hWnd
>
> nsIViewManager* piViewManager = piShell -> GetViewManager();
>
> if (piViewManager)
>
> {
>
> nsCOMPtr<nsIWidget> spiWidget;
>
> piViewManager -> GetWidget(getter_AddRefs(spiWidget));
>
> if (spiWidget)
>
> hWnd = static_cast<HWND> (spiWidget -> GetNativeData(NS_NATIVE_WINDOW));
>
> }//if
> }//if
>
> hParentWindow = GetAncestor(hWnd,GA_ROOT);
>
> return hWnd;
>
> This used to work on previous versions of xulrunner, but on the newest xulrunner 1.9.2 it doesnt work, because the GetWidget() method is no longer supported by the nsIViewManager interface.
>
> Can anyone please kindly point me the correct way to handle this (new) situation?
>
> Thanx in advance,
>
> Best,
>
> Oliveiros d'Azevedo Cristina

You could use GetRootWidget() like we do (see
http://mxr.mozilla.org/mozilla-central/source/accessible/src/base/nsDocAccessible.cpp#111)

Alex.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.