BOOL CALLBACK SplashDlgProc( HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam ) { static HWND hWndBmp; static HBITMAP hBmp; switch( msg ) { case WM_INITDIALOG: /* bitmap handle is passed at dialog creation */ hBmp = (HBITMAP)lParam; hWndBmp = GetDlgItem( hDlg, IDBITMAP ); return TRUE; case WM_PAINT: /* paint the logo bitmap */ PaintBitmap( hWndBmp, hBmp ); break; case WM_DESTROY: /* destroy the bitmap */ DeleteObject( hBmp ); break; } return FALSE; }
bool CToolImg::CreateButtonField(COLORREF clrBackground, ButtonFieldInfo* pBtns, int nBtnCount) { FreeDC(); FreeBMP(); mprc_Btns = (LPRECT)calloc(nBtnCount, sizeof(*mprc_Btns)); if (!mprc_Btns) return false; mn_MaxBtnCount = nBtnCount; int nFieldWidth = pBtns[0].nWidth; int nFieldHeight = pBtns[0].nHeight; for (int i = 1; i < nBtnCount; i++) { nFieldWidth = std::max(nFieldWidth, pBtns[i].nWidth); nFieldHeight += 1 + pBtns[i].nHeight; } if (!CreateField(nFieldWidth, nFieldHeight, clrBackground)) return false; //COLORMAP colorMap = {0xC0C0C0, clrBackground/*GetSysColor(COLOR_BTNFACE)*/}; bool bRc = true; _ASSERTE(mn_BtnCount == 0); int nDstY = 0; DWORD nErrCode = 0; for (int i = 0; i < nBtnCount; i++) { //HBITMAP hbm = CreateMappedBitmap(g_hInstance, (INT_PTR)pBtns[i].szName, 0, &colorMap, 1); HBITMAP hbm = (HBITMAP)LoadImage(g_hInstance, pBtns[i].szName, IMAGE_BITMAP, 0, 0, LR_LOADTRANSPARENT|LR_LOADMAP3DCOLORS); if (hbm == NULL) { nErrCode = GetLastError(); bRc = false; continue; } else { RECT rc = {0, nDstY, pBtns[i].nWidth, nDstY+pBtns[i].nHeight}; mprc_Btns[i] = rc; if (!PaintBitmap(hbm, pBtns[i].nWidth, pBtns[i].nHeight, mh_BmpDc, 0, nDstY, pBtns[i].nWidth, pBtns[i].nHeight)) { nErrCode = GetLastError(); bRc = false; } DeleteObject(hbm); } nDstY += 1 + pBtns[i].nHeight; } #ifdef _DEBUG //SaveImageEx(L"T:\\BtnField.png", mh_Bmp); #endif mn_BtnCount = mn_MaxBtnCount; return true; }