// =========================================================================== // File Splash.cpp // Desc The implementation file for the CSplash class. // =========================================================================== #include "stdafx.h" #include "splash.h" #include "windowsx.h" // =========================================================================== // The following is used for layering support which is used in the // splash screen for transparency. In VC 6 these are not defined in the headers // for user32.dll and hence we use mechanisms so that it can work in VC 6. // We define the flags here and write code so that we can load the function // from User32.dll explicitely and use it. This code requires Win2k and above // to work. // =========================================================================== typedef BOOL (WINAPI *lpfnSetLayeredWindowAttributes) (HWND hWnd, COLORREF cr, BYTE bAlpha, DWORD dwFlags); lpfnSetLayeredWindowAttributes g_pSetLayeredWindowAttributes; #define WS_EX_LAYERED 0x00080000 // #define LWA_COLORKEY 1 // Use color as the transparency color. // #define LWA_ALPHA 2 // Use bAlpha to determine the opacity of the layer // =========================================================================== // Func ExtWndProc // Desc The windows procedure that is used to forward messages to the // CSplash class. CSplash sends the "this" pointer through the // CreateWindowEx call and the pointer reaches here in the // WM_CREATE message. We store it here and use it for message // forwarding. // =========================================================================== static LRESULT CALLBACK ExtWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { static CSplash * spl = NULL; if(uMsg == WM_CREATE) { spl = (CSplash*)((LPCREATESTRUCT)lParam)->lpCreateParams; } if(spl) return spl->WindowProc(hwnd, uMsg, wParam, lParam); else return DefWindowProc (hwnd, uMsg, wParam, lParam); } LRESULT CALLBACK CSplash::WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { // We need to handle on the WM_PAINT message switch(uMsg) { HANDLE_MSG(hwnd, WM_PAINT, OnPaint); } return DefWindowProc (hwnd, uMsg, wParam, lParam) ; } void CSplash:: OnPaint(HWND hwnd) { if (!m_hBitmap || m_uBitmap == 0) return; SetBitmap(m_uBitmap); // ======================================================================= // Paint the background by BitBlting the bitmap // ======================================================================= PAINTSTRUCT ps ; HDC hDC = BeginPaint (hwnd, &ps) ; RECT rect; RECT rc; HFONT font, pOldFont; LONG startcv,i; CString strtmp; ::GetClientRect(m_hwnd, &rect); HDC hMemDC = ::CreateCompatibleDC(hDC); HBITMAP hOldBmp = (HBITMAP)::SelectObject(hMemDC, m_hBitmap); // create font font = ::CreateFont(14, 0, 0, 0, FW_BOLD, 0, 0, 0, DEFAULT_CHARSET, OUT_CHARACTER_PRECIS, CLIP_CHARACTER_PRECIS, PROOF_QUALITY, DEFAULT_PITCH|FF_DECORATIVE, _T("Tahoma")); pOldFont = (HFONT) ::SelectObject(hMemDC, font); ::SetBkMode(hMemDC, TRANSPARENT); startcv = 90; rc.left = rect.left + 20; rc.right = rect.right - 10; for(i=0;i= MAX_SPLASH_SIZE) { for(i=1;i