STM_SETIMAGE Trouble!(PLEASE HELP!!)
Hello. I am working on a BMP viewer and I want it to load a BMP onto a static and set the static control to have the same dimensions as the image. Here's some code:
case IDC_VIEW:
GetWindowText (GetDlgItem(hwnd, IDC_FILE), path, MAX_PATH);
bmpname = (HBITMAP) LoadBitmap (0, path);
GetObject (bmpname, sizeof(bmpinfo), &bmpinfo);
x = bmpinfo.bmWidth;
y = bmpinfo.bmHeight;
bmpname = (HBITMAP) LoadBitmap (0, path);
sX = x;
sY = y;
SendMessage(GetDlgItem(hwnd, IDC_BMP), STM_SETIMAGE, (WPARAM)IMAGE_BITMAP, (LPARAM)bmpname);
break;
All of the variables are already declared. The only problem is that it won't display the image on the static control. Can you help me?
Ok, now I have another problem...
I did this:
GetWindowText (GetDlgItem(hwnd, IDC_FILE), path, MAX_PATH);
bmpname = (HBITMAP) LoadImage (0, path, x, y, 0, LR_LOADFROMFILE);
if(!bmpname)
{
MessageBox(0, "Error creating BMP!", "Error", 0);
}
GetObject (bmpname, sizeof(bmpinfo), &bmpinfo);
x = bmpinfo.bmWidth;
y = bmpinfo.bmHeight;
sX = x;
sY = y;
SendMessage(GetDlgItem(hwnd, IDC_BMP), STM_SETIMAGE, (WPARAM)IMAGE_BITMAP, (LPARAM)bmpname);
And it can't create the BMP again. How do I reset the HBITMAP?
NEVERMIND! I got it! I had to erase the BMP off of the static control first!