-
Adding bitmap to dialog
Hello,
Recently I've been trying to make a small program that contains a bitmap, but whenever i try to add the bitmap file to the bitmap control when the dialog is initialized, it doesn't show when compiled.
Here is my code:
Code:
case WM_INITDIALOG:
{
HICON hIcon;
HBITMAP hBitmap;
hIcon = (HICON)LoadImage(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_MYICON), IMAGE_ICON, 32, 32, 0);
SendMessage(hWnd, WM_SETICON, ICON_BIG, (LPARAM)hIcon);
SendMessage(hWnd, WM_SETICON, ICON_SMALL, (LPARAM)hIcon);
hBitmap = LoadBitmap(hInstance,MAKEINTRESOURCE(IDI_MYIMAGE));
SendDlgItemMessage(hWnd, IDC_IMG1, STM_SETIMAGE, IMAGE_BITMAP, (LPARAM)hBitmap);
}
The bitmap control id is IDC_IMG1 and the bitmap hook is HBITMAP.
Does anyone know how to fix this? If I've forgotten any important code please tell me and ill add it.
Thanks in advanced.
-
Why is the first parameter of the LoadImage and LoadBitmap different?
Have you tried to check the return values of the function called and use GetLastError to check what is happening?
-
Thanks vart. Changing the first parameter of LoadBitmap to GetModuleHandle(NULL) fixed my problem. I dont see why it didnt work with hInstance though.