mTrayRestart = ::RegisterWindowMessage(TEXT("TaskbarCreated"));
nsNativeAppSupportWin::SetupSysTrayIcon() {    // Messages go to the hidden window.    mIconData.hWnd  = (HWND)MessageWindow();    // Icon is our default application icon.    mIconData.hIcon =  (HICON)::LoadImage( ::GetModuleHandle( NULL ),                                           IDI_APPLICATION,                                           IMAGE_ICON,                                           ::GetSystemMetrics( SM_CXSMICON ),                                           ::GetSystemMetrics( SM_CYSMICON ),                                           NULL );    // Tooltip is the brand short name.    mIconData.szTip[0] = 0;    nsCOMPtr<nsIStringBundleService> svc( do_GetService( NS_STRINGBUNDLE_CONTRACTID ) );    if ( svc ) {        nsCOMPtr<nsIStringBundle> brandBundle;        nsXPIDLString tooltip;        svc->CreateBundle( "chrome://global/locale/brand.properties", getter_AddRefs( brandBundle ) );        if ( brandBundle ) {            brandBundle->GetStringFromName( NS_LITERAL_STRING( "brandShortName" ).get(),                                            getter_Copies( tooltip ) );            ::strncpy( mIconData.szTip,                       NS_LossyConvertUCS2toASCII(tooltip).get(),                       sizeof mIconData.szTip - 1 );        }        // Build menu.        nsCOMPtr<nsIStringBundle> turboBundle;        nsCOMPtr<nsIStringBundle> mailBundle;        svc->CreateBundle( "chrome://navigator/locale/turboMenu.properties",                           getter_AddRefs( turboBundle ) );        nsresult rv = svc->CreateBundle( "chrome://messenger/locale/mailTurboMenu.properties",                                         getter_AddRefs( mailBundle ) );        PRBool isMail = NS_SUCCEEDED(rv) && mailBundle;        nsAutoString exitText;        nsAutoString disableText;        nsAutoString navigatorText;        nsAutoString editorText;        nsAutoString mailText;        nsAutoString addressbookText;        nsXPIDLString text;        if ( turboBundle ) {            if ( brandBundle ) {                const PRUnichar* formatStrings[] = { tooltip.get() };                turboBundle->FormatStringFromName( NS_LITERAL_STRING( "Exit" ).get(), formatStrings, 1,                                                   getter_Copies( text ) );                exitText = (const PRUnichar*)text;            }            turboBundle->GetStringFromName( NS_LITERAL_STRING( "Disable" ).get(),                                            getter_Copies( text ) );            disableText = (const PRUnichar*)text;            turboBundle->GetStringFromName( NS_LITERAL_STRING( "Navigator" ).get(),                                            getter_Copies( text ) );            navigatorText = (const PRUnichar*)text;            turboBundle->GetStringFromName( NS_LITERAL_STRING( "Editor" ).get(),                                            getter_Copies( text ) );            editorText = (const PRUnichar*)text;        }        if (isMail) {            mailBundle->GetStringFromName( NS_LITERAL_STRING( "MailNews" ).get(),			                               getter_Copies( text ) );            mailText = (const PRUnichar*)text;            mailBundle->GetStringFromName( NS_LITERAL_STRING( "Addressbook" ).get(),			                               getter_Copies( text ) );            addressbookText = (const PRUnichar*)text;        }        if ( exitText.IsEmpty() )            exitText = NS_LITERAL_STRING( "E&xit Mozilla" );        if ( disableText.IsEmpty() )            disableText = NS_LITERAL_STRING( "&Disable Quick Launch" );        if ( navigatorText.IsEmpty() )            navigatorText = NS_LITERAL_STRING( "&Navigator" );        if ( editorText.IsEmpty() )            editorText = NS_LITERAL_STRING( "&Composer" );        if ( isMail ) {            if ( mailText.IsEmpty() )              mailText = NS_LITERAL_STRING( "&Mail && Newsgroups" );            if ( addressbookText.IsEmpty() )              addressbookText = NS_LITERAL_STRING( "&Address Book" );        }        // Create menu and add item.        mTrayIconMenu = ::CreatePopupMenu();        ::AppendMenuW( mTrayIconMenu, MF_STRING, TURBO_NAVIGATOR, navigatorText.get() );        if ( ::GetLastError() == ERROR_CALL_NOT_IMPLEMENTED ) {            AppendMenuItem( mTrayIconMenu, TURBO_NAVIGATOR, navigatorText );            if ( isMail )                AppendMenuItem( mTrayIconMenu, TURBO_MAIL, mailText );            AppendMenuItem( mTrayIconMenu, TURBO_EDITOR, editorText );            if ( isMail )                AppendMenuItem( mTrayIconMenu, TURBO_ADDRESSBOOK, addressbookText );            ::AppendMenu( mTrayIconMenu, MF_SEPARATOR, NULL, NULL );            AppendMenuItem( mTrayIconMenu, TURBO_DISABLE, disableText );            AppendMenuItem( mTrayIconMenu, TURBO_EXIT, exitText );        }        else {            if (isMail)                ::AppendMenuW( mTrayIconMenu, MF_STRING, TURBO_MAIL, mailText.get() );            ::AppendMenuW( mTrayIconMenu, MF_STRING, TURBO_EDITOR, editorText.get() );            if (isMail)                ::AppendMenuW( mTrayIconMenu, MF_STRING, TURBO_ADDRESSBOOK, addressbookText.get() );            ::AppendMenuW( mTrayIconMenu, MF_SEPARATOR, NULL, NULL );            ::AppendMenuW( mTrayIconMenu, MF_STRING, TURBO_DISABLE, disableText.get() );            ::AppendMenuW( mTrayIconMenu, MF_STRING, TURBO_EXIT, exitText.get() );        }    }    // Add the tray icon.    ::Shell_NotifyIcon( NIM_ADD, &mIconData );}