[purple]I'm learning how bitmap images can be shown in a window. I got some questions regarding this bitmap loading and displaying.
1. I tried a .jpg file to load by converting it to .bmp by an image editor. I used [blue]LoadBitmap()[/blue] to load the bitmap. It returned NULL. I clearly stated the path of the .bmp file in resource file. Why it returned NULL?
2. Well, I could successfully load other .bmp files. The book I am following used the following code fragment in WM_PAINT case in window function.[code]
hdc = BeginPaing(hwnd, &ps);
memdc = CreateCompatibleDC(hdc);
//Two call to BitBlt() to show same image
//in two different locations of window
Here are the types used in the code above:
hbit HBITMAP (loaded at WM_CREATE case of
The explanation provided in the book is not enough. The author said, a compatible device context is obtained by the call of [blue]CreateCompatibleDC()[/blue]. The bitmap (hbit) is selected by a call through [blue]SelectObject()[/blue]. These I understand by observing the function names. But my questions are:
>> what is a compatible device context? hdc and memdc are declared as [blue]HDC[/blue]. Why they are not compatible? Why a seperate call to [blue]CreateCompatibleDC()[/blue] is required?
>> Why memdc must hold the bitmap in order to display in hdc (device context associated with the window)?
>> Why the bitmap has to be selected? It is already loaded in hbit.