nsCOMPtr<nsIScriptGlobalObject> ppScriptGlobalObj( do_QueryInterface(window) ); if ( !ppScriptGlobalObj )
nsCOMPtr<nsPIDOMWindow> win( do_QueryInterface(window) ); if ( !win )
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 ) );}