Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes
nsSplashScreenWin Class Reference
Inheritance diagram for nsSplashScreenWin:
Inheritance graph
[legend]
Collaboration diagram for nsSplashScreenWin:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 nsSplashScreenWin ()
 ~nsSplashScreenWin ()
NS_IMETHOD Show ()
NS_IMETHOD Hide ()
 NS_IMETHOD_ (nsrefcnt) AddRef()
 NS_IMETHOD_ (nsrefcnt) Release()
NS_IMETHOD QueryInterface (const nsIID &iid, void **p)
void SetDialog (HWND dlg)
void LoadBitmap ()

Static Public Member Functions

static nsSplashScreenWinGetPointer (HWND dlg)
static BOOL CALLBACK DialogProc (HWND dlg, UINT msg, WPARAM wp, LPARAM lp)
static DWORD WINAPI ThreadProc (LPVOID)
static VOID CALLBACK TimerProc (HWND hwnd, UINT uMsg, UINT idEvent, DWORD dwTime)

Public Attributes

HWND mDlg
HBITMAP mBitmap
nsrefcnt mRefCnt

Static Public Attributes

static int mOpacity = 55
static
MOZ_SetLayeredWindowAttributesProc 
mSetLayeredWindowAttributesProc = 0

Detailed Description

Definition at line 178 of file nsNativeAppSupportWin.cpp.


Constructor & Destructor Documentation

Definition at line 448 of file nsNativeAppSupportWin.cpp.

    : mDlg( 0 ), mBitmap( 0 ), mRefCnt( 0 ) {
}

Definition at line 452 of file nsNativeAppSupportWin.cpp.

                                      {
#if MOZ_DEBUG_DDE
    printf( "splash screen dtor called\n" );
#endif
    KillTimer(mDlg, 0);
    // Make sure dialog is gone.
    Hide();
}

Here is the call graph for this function:


Member Function Documentation

BOOL CALLBACK nsSplashScreenWin::DialogProc ( HWND  dlg,
UINT  msg,
WPARAM  wp,
LPARAM  lp 
) [static]

Definition at line 548 of file nsNativeAppSupportWin.cpp.

                                                                        {
    if ( msg == WM_INITDIALOG ) {
        // Store dialog handle.
        nsSplashScreenWin *splashScreen = (nsSplashScreenWin*)lp;
        if ( lp ) {
            splashScreen->SetDialog( dlg );

            HMODULE user32lib = GetModuleHandle("user32.dll");
            mSetLayeredWindowAttributesProc = (MOZ_SetLayeredWindowAttributesProc) GetProcAddress(user32lib, "SetLayeredWindowAttributes");

            // only do fade if it's supported and the user isn't using remote desktop
            if (mSetLayeredWindowAttributesProc && !GetSystemMetrics(SM_REMOTESESSION)) {
                SetWindowLong(dlg, GWL_EXSTYLE,
                                 GetWindowLong(dlg, GWL_EXSTYLE) | WS_EX_LAYERED);
                mSetLayeredWindowAttributesProc(dlg, 0,
                                                  mOpacity, LWA_ALPHA);
                SetTimer(dlg, 0, 10, TimerProc);
            }

            // Try to load customized bitmap.
            splashScreen->LoadBitmap();
        }

        /* 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;
    } else if (msg == WM_CLOSE) {
        // Before killing ourself, set the top-level current.
        // See comments in nsSplashScreenWin::Hide() above.
        HWND topLevel = (HWND)lp;
        if (topLevel)
            ::SetForegroundWindow(topLevel);
        // Destroy the dialog
        ::EndDialog(dlg, 0);
        // Release custom bitmap (if there is one).
        HBITMAP bitmap = (HBITMAP)wp;
        if ( bitmap ) {
            ::DeleteObject( bitmap );
        }
    }
    return 0;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 620 of file nsNativeAppSupportWin.cpp.

                                                           {
    // Get result from dialog user data.
    LONG data = GetWindowLong( dlg, DWL_USER );
    return (nsSplashScreenWin*)(void*)data;
}

Implements nsISplashScreen.

Definition at line 472 of file nsNativeAppSupportWin.cpp.

                        {
    if ( mDlg ) {
        // Fix for bugs:
        //  http://bugzilla.mozilla.org/show_bug.cgi?id=26581
        //  http://bugzilla.mozilla.org/show_bug.cgi?id=65974
        //  http://bugzilla.mozilla.org/show_bug.cgi?id=29172
        //  http://bugzilla.mozilla.org/show_bug.cgi?id=45805
        // As the splash-screen is in a separate thread, Windows considers
        // this the "foreground" thread.  When our main windows on the main
        // thread are activated, they are treated like windows from a different
        // application, so Windows 2000 and 98 both leave the window in the background.
        // Therefore, we post a message to the splash-screen thread that includes
        // the hwnd of the window we want moved to the foreground.  This thread
        // can then successfully bring the top-level window to the foreground.
        nsCOMPtr<nsIDOMWindowInternal> topLevel;
        GetMostRecentWindow(nsnull, getter_AddRefs( topLevel ) );
        HWND hWndTopLevel = topLevel ? hwndForDOMWindow(topLevel) : 0;
        // Dismiss the dialog.
        ::PostMessage(mDlg, WM_CLOSE, (WPARAM)mBitmap, (LPARAM)hWndTopLevel);
        mBitmap = 0;
        mDlg = 0;
    }
    return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 498 of file nsNativeAppSupportWin.cpp.

                              {
    // Check for '<program-name>.bmp" in same directory as executable.
    char fileName[ _MAX_PATH ];
    int fileNameLen = ::GetModuleFileName( NULL, fileName, sizeof fileName );
    if ( fileNameLen >= 3 ) {
        fileName[ fileNameLen - 3 ] = 0;
        strcat( fileName, "bmp" );
        // Try to load bitmap from that file.
        HBITMAP bitmap = (HBITMAP)::LoadImage( NULL,
                                               fileName,
                                               IMAGE_BITMAP,
                                               0,
                                               0,
                                               LR_LOADFROMFILE );
        if ( bitmap ) {
            HWND bitmapControl = GetDlgItem( mDlg, IDB_SPLASH );
            if ( bitmapControl ) {
                HBITMAP old = (HBITMAP)SendMessage( bitmapControl,
                                                    STM_SETIMAGE,
                                                    IMAGE_BITMAP,
                                                    (LPARAM)bitmap );
                // Remember bitmap so we can delete it later.
                mBitmap = bitmap;
                // Delete old bitmap.
                if ( old ) {
                    BOOL ok = DeleteObject( old );
                }
            } else {
                // Delete bitmap since it isn't going to be used.
                DeleteObject( bitmap );
            }
        }
    }
}

Here is the caller graph for this function:

Definition at line 187 of file nsNativeAppSupportWin.cpp.

                                   {
        mRefCnt++;
        return mRefCnt;
    }

Definition at line 191 of file nsNativeAppSupportWin.cpp.

                                    {
        --mRefCnt;
        if ( !mRefCnt ) {
            delete this;
            return 0;
        }
        return mRefCnt;
    }

Definition at line 199 of file nsNativeAppSupportWin.cpp.

                                                           {
        nsresult rv = NS_OK;
        if ( p ) {
            *p = 0;
            if ( iid.Equals( NS_GET_IID( nsISplashScreen ) ) ) {
                nsISplashScreen *result = this;
                *p = result;
                NS_ADDREF( result );
            } else if ( iid.Equals( NS_GET_IID( nsISupports ) ) ) {
                nsISupports *result = NS_STATIC_CAST( nsISupports*, this );
                *p = result;
                NS_ADDREF( result );
            } else {
                rv = NS_NOINTERFACE;
            }
        } else {
            rv = NS_ERROR_NULL_POINTER;
        }
        return rv;
    }

Here is the call graph for this function:

Definition at line 613 of file nsNativeAppSupportWin.cpp.

                                            {
    // Save dialog handle.
    mDlg = dlg;
    // Store this pointer in the dialog.
    SetWindowLong( mDlg, DWL_USER, (LONG)(void*)this );
}

Here is the caller graph for this function:

Implements nsISplashScreen.

Definition at line 462 of file nsNativeAppSupportWin.cpp.

                        {
    // Spawn new thread to display real splash screen.
    DWORD threadID = 0;
    HANDLE handle = CreateThread( 0, 0, (LPTHREAD_START_ROUTINE)ThreadProc, this, 0, &threadID );
    CloseHandle(handle);

    return NS_OK;
}

Here is the call graph for this function:

DWORD WINAPI nsSplashScreenWin::ThreadProc ( LPVOID  splashScreen) [static]

Definition at line 626 of file nsNativeAppSupportWin.cpp.

                                                                {
    DialogBoxParam( GetModuleHandle( 0 ),
                    MAKEINTRESOURCE( IDD_SPLASH ),
                    HWND_DESKTOP,
                    (DLGPROC)DialogProc,
                    (LPARAM)splashScreen );
    return 0;
}

Here is the call graph for this function:

Here is the caller graph for this function:

VOID CALLBACK nsSplashScreenWin::TimerProc ( HWND  hwnd,
UINT  uMsg,
UINT  idEvent,
DWORD  dwTime 
) [static]

Definition at line 537 of file nsNativeAppSupportWin.cpp.

                                                                             {
    mOpacity += 20;
    if (mOpacity >= 255) { // >= because we still want to kill the timer for 255
        mOpacity = 255;
        KillTimer(hwnd, 0);
    }
    // no need to null check - this code can't be reached if SetLayeredWindowAttributes isn't available
    mSetLayeredWindowAttributesProc(hwnd, 0, mOpacity, LWA_ALPHA);
}

Here is the caller graph for this function:


Member Data Documentation

Definition at line 229 of file nsNativeAppSupportWin.cpp.

Definition at line 228 of file nsNativeAppSupportWin.cpp.

Definition at line 232 of file nsNativeAppSupportWin.cpp.

Definition at line 230 of file nsNativeAppSupportWin.cpp.

Definition at line 233 of file nsNativeAppSupportWin.cpp.


The documentation for this class was generated from the following file: