static HBITMAP hBmp;
static int cxBmp;
static int cyBmp;
case WM_CREATE:
{
//load bmp and get bmp info
hBmp = LoadBitmap(GetModuleHandle(NULL),MAKEINTRESOURCE(IDB_BALL));
BITMAP bmpInfo;
GetObject(hBmp,sizeof(BITMAP),&bmpInfo);
cxBmp = bmpInfo.bmWidth;
cyBmp = bmpInfo.bmHeight;
//put window int the middle screen
int cxScr = GetSystemMetrics(SM_CXSCREEN);
int cyScr = GetSystemMetrics(SM_CYSCREEN);
int cxWnd = 400;
int cyWnd = 400;
MoveWindow(hWnd,(cxScr-cxWnd)/2,(cyScr-cyWnd)/2,cxWnd,cyWnd,TRUE);
}
break;
case WM_PAINT:
hdc = BeginPaint(hWnd, &ps);
{
//bg color
RECT rcWnd;
HBRUSH hBrush;
GetClientRect(hWnd,&rcWnd);
hBrush = CreateSolidBrush(RGB(0,128,128));
FillRect(hdc,&rcWnd,hBrush);
DeleteObject(hBrush);
//disp bmp
HDC hMemDC = CreateCompatibleDC(hdc);
HBITMAP hOldBmp = (HBITMAP)SelectObject(hMemDC,hBmp);
//BitBlt(hdc,73,58,cxBmp,cyBmp,hMemDC,0,0,SRCCOPY);
TransparentBlt(hdc,73,58,cxBmp,cyBmp,hMemDC,0,0,cxBmp,cyBmp,RGB(255,255,255));
SelectObject(hMemDC,hOldBmp);
DeleteDC(hMemDC);
}
EndPaint(hWnd, &ps);
break;