Originally posted by Sebastiani
Ok, here's what I did:
The program already generated a .rc file for the icon, I think, and so I just added that snippet to it, saved it, changed the "hwnd" to "hThisInstance"(that's my hinstance) in my program, and set the second parameter to "myBitmap". But not only does the compiler say that "myBitmap" is undeclared, but also "hThisInstance"!! I rechecked my code, and it should recognize "hThisInstance" at least. Now here's what the resource file looks like:
____________________________________
500 ICON MOVEABLE PURE LOADONCALL DISCARDABLE "C:/DEV-C++/Icon/MAINICON.ICO"
myBitmap BITMAP "C//:nuntitled.bmp"
_____________________________________
I also tried it the other way around, that is:
BITMAP myBitmap "C//:nuntitled.bmp"
...didn't work either.
I also use Dev-C++ and this is the correct way to do it.
In the resource file include the bitmap like this
PHP Code:
myBitmap BITMAP "C:/nuntitled.bmp"
In the source code declare a general variable for the bitmap.
You can do it also for HINSTANCE but I prefer to get it from hWnd.
In the windows procedure include the following
PHP Code:
....
case WM_CREATE:
{
HINSTANCE hInst = GetWindowLong(hWnd, GWL_HINSTANCE);
hBmp = LoadBitmap(hInst, "myBitmap");
}
break;
....
case WM_PAINT:
/* Include here the functions to paint
the bitmap in the client area */
break;
.....
case WM_DESTROY:
DeleteObject(hBmp);
break;
....
hth