nsCOMPtr<nsIScriptGlobalObject> ppScriptGlobalObj( do_QueryInterface(window) ); if ( !ppScriptGlobalObj ) {
nsCOMPtr<nsPIDOMWindow> pidomwindow( do_QueryInterface(window) ); if ( !pidomwindow ) {
HWND hwndForDOMWindow( nsISupports *window ) {    nsCOMPtr<nsIScriptGlobalObject> ppScriptGlobalObj( do_QueryInterface(window) );    if ( !ppScriptGlobalObj ) {        return 0;    }    nsCOMPtr<nsIBaseWindow> ppBaseWindow =        do_QueryInterface( ppScriptGlobalObj->GetDocShell() );    if ( !ppBaseWindow ) {        return 0;    }    nsCOMPtr<nsIWidget> ppWidget;    ppBaseWindow->GetMainWidget( getter_AddRefs( ppWidget ) );    return (HWND)( ppWidget->GetNativeData( NS_NATIVE_WIDGET ) );}