[Dev-C++] displaying bitmap in a dialog box
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: <jab...@ta...> - 2004-02-28 03:03:58
|
I'm trying to put a bitmap in a dialog box. It's not working: a) it freezes, b) if I comment the loadimage line and move the box, it grays up the background without repainting. I'm using win 98. Here is the code:
.....
case WM_PAINT:
{
HBITMAP hbmSail;
BITMAP bm;
int X, Y;
hbmSail = (HBITMAP) LoadImage(GetModuleHandle (NULL), // hinst is global
MAKEINTRESOURCE(5),
IMAGE_BITMAP,
0,
0,
0);
if(!hbmSail){
MessageBox(hwnd, "Load of resources failed.", "Error",
MB_OK | MB_ICONEXCLAMATION);
return -1;
}
GetObject(hbmSail, sizeof(bm), &bm);
X = 20;
Y = 20;
HDC hdcMemory;
HDC hdc;
hdc=GetDC(hwnd);
hdcMemory = CreateCompatibleDC(hdc);
SelectObject(hdcMemory, hbmSail);
BitBlt(hdc, X, Y, bm.bmWidth, bm.bmHeight, hdcMemory, 0, 0, SRCCOPY);
DeleteDC(hdcMemory);
ReleaseDC (hwnd,hdc);
}
......
What am I doing wrong? or better, am I doing anything right?
Thanks for the help!!!
Jorge
|