From d94ceacf73afc91d57a5776260ce87f3df531b01 Mon Sep 17 00:00:00 2001 From: "law%netscape.com" Date: Fri, 25 Feb 2000 02:19:41 +0000 Subject: [PATCH] Fixes to splash screen and program icon problems; bugs=26581/26685, r=jband@netscape.com, a=jevering@netscape.com git-svn-id: svn://10.0.0.236/trunk@61637 18797224-902f-48f8-a5cc-f745e15eee43 --- .../xpfe/bootstrap/nsNativeAppSupportWin.cpp | 65 ++++++++++++++++++- .../xpfe/bootstrap/nsNativeAppSupportWin.h | 5 -- mozilla/xpfe/bootstrap/splash.rc | 16 +++-- 3 files changed, 72 insertions(+), 14 deletions(-) diff --git a/mozilla/xpfe/bootstrap/nsNativeAppSupportWin.cpp b/mozilla/xpfe/bootstrap/nsNativeAppSupportWin.cpp index 655de19dbb5..9670ea88a63 100644 --- a/mozilla/xpfe/bootstrap/nsNativeAppSupportWin.cpp +++ b/mozilla/xpfe/bootstrap/nsNativeAppSupportWin.cpp @@ -72,6 +72,7 @@ public: static nsSplashScreenWin* GetPointer( HWND dlg ); static BOOL CALLBACK DialogProc( HWND dlg, UINT msg, WPARAM wp, LPARAM lp ); + static BOOL CALLBACK PhantomDialogProc( HWND dlg, UINT msg, WPARAM wp, LPARAM lp ); static DWORD WINAPI ThreadProc( LPVOID ); HWND mDlg; @@ -92,7 +93,31 @@ nsSplashScreenWin::~nsSplashScreenWin() { NS_IMETHODIMP nsSplashScreenWin::Show() { - // Spawn new thread to display splash screen. + /* + * A hack for http://bugzilla.mozilla.org/show_bug.cgi?id=26581 + * + * Windows NT seems to think that the first thread to show a window must + * therefore be our main UI thread. It then seems to want to put the first + * window that shows up on other threads in our application behind the main + * windows of other applications. Since we want to show our splash screen + * on a 'non-main' thread, our browser windows start showing up later on a + * thread that Windows thinks is not our main UI thread. So, (I believe) it + * pushes the first one of our browser windows to the back until the user + * pulls it forward. That is not what we want! + * + * This hack attempts to trick Windows by very briefly showing an + * offscreen window on the main thread. This happens before the splash + * screen thread creates its window (which it sets as topmost). So when our + * browser windows start showing up on the main thread Windows will see that + * they are on the "first thread with a window" and it will (hopefully!) not + * push them to the back. + */ + DialogBox( GetModuleHandle( 0 ), + MAKEINTRESOURCE( IDD_SPLASH ), + HWND_DESKTOP, + (DLGPROC)PhantomDialogProc ); + + // Spawn new thread to display real splash screen. DWORD threadID = 0; CreateThread( 0, 0, (LPTHREAD_START_ROUTINE)ThreadProc, this, 0, &threadID ); return NS_OK; @@ -108,13 +133,49 @@ nsSplashScreenWin::Hide() { return NS_OK; } -BOOL CALLBACK nsSplashScreenWin::DialogProc( HWND dlg, UINT msg, WPARAM wp, LPARAM lp ) { +BOOL CALLBACK +nsSplashScreenWin::PhantomDialogProc( HWND dlg, UINT msg, WPARAM wp, LPARAM lp ) { + if ( msg == WM_INITDIALOG ) { + // Show window for an instant to make this the active thread. + ShowWindow( dlg, SW_SHOW ); + EndDialog( dlg, 0 ); + return 1; + } + return 0; +} + +BOOL CALLBACK +nsSplashScreenWin::DialogProc( HWND dlg, UINT msg, WPARAM wp, LPARAM lp ) { if ( msg == WM_INITDIALOG ) { // Store dialog handle. nsSplashScreenWin *splashScreen = (nsSplashScreenWin*)lp; if ( lp ) { splashScreen->SetDialog( dlg ); } + /* Size and center the splash screen correctly. The flags in the + * dialog template do not do the right thing if the user's + * machine is using large fonts. + */ + HWND bitmapControl = GetDlgItem( dlg, IDB_SPLASH ); + if ( bitmapControl ) { + HBITMAP hbitmap = (HBITMAP)SendMessage( bitmapControl, + STM_GETIMAGE, + IMAGE_BITMAP, + 0 ); + if ( hbitmap ) { + BITMAP bitmap; + if ( GetObject( hbitmap, sizeof bitmap, &bitmap ) ) { + SetWindowPos( dlg, + NULL, + GetSystemMetrics(SM_CXSCREEN)/2 - bitmap.bmWidth/2, + GetSystemMetrics(SM_CYSCREEN)/2 - bitmap.bmHeight/2, + bitmap.bmWidth, + bitmap.bmHeight, + SWP_NOZORDER ); + ShowWindow( dlg, SW_SHOW ); + } + } + } return 1; } return 0; diff --git a/mozilla/xpfe/bootstrap/nsNativeAppSupportWin.h b/mozilla/xpfe/bootstrap/nsNativeAppSupportWin.h index ec634281c7e..cc5dcf80c5c 100644 --- a/mozilla/xpfe/bootstrap/nsNativeAppSupportWin.h +++ b/mozilla/xpfe/bootstrap/nsNativeAppSupportWin.h @@ -21,14 +21,9 @@ * Bill Law law@netscape.com */ -// Program icon ID. -#define IDI_MOZILLA 1 - // Splash screen dialog ID. #define IDD_SPLASH 100 // Splash screen bitmap ID. #define IDB_SPLASH 101 -// Splash screen timer ID. -#define IDT_SPLASH 501 diff --git a/mozilla/xpfe/bootstrap/splash.rc b/mozilla/xpfe/bootstrap/splash.rc index 2ec09a11d37..6e6f068d660 100644 --- a/mozilla/xpfe/bootstrap/splash.rc +++ b/mozilla/xpfe/bootstrap/splash.rc @@ -24,21 +24,23 @@ #include "nsNativeAppSupportWin.h" // Program icon. -IDI_MOZILLA ICON +IDI_APPLICATION ICON "mozilla.ico" // Splash screen dialog. -IDD_SPLASH DIALOG +IDD_SPLASH DIALOGEX DISCARDABLE - 0, 0, 260, 160 - STYLE DS_SETFOREGROUND | DS_CENTER | WS_POPUP | WS_VISIBLE + 0,0,0,0 + STYLE DS_SETFOREGROUND | DS_CENTER | WS_POPUP + EXSTYLE WS_EX_TOOLWINDOW FONT 8, "MS Sans Serif" BEGIN - CONTROL IDB_SPLASH, - -1, + CONTROL + IDB_SPLASH, + IDB_SPLASH, "Static", SS_BITMAP, - 0,0,390,261 + 0,0,0,0 END // Splash screen bitmap.