switch (message)
{
case WM_INITDIALOG:
{
HANDLE hBitmap;
hBitmap = LoadImageW(hWindowInstance, L"pic\\7.bmp", IMAGE_BITMAP, 144, 90, LR_LOADFROMFILE);
HWND hPic = GetDlgItem(hDlg,IDC_Pic);
SendMessage(hPic, STM_SETIMAGE, IMAGE_BITMAP, LPARAM(hBitmap));
break;
}
}
但是发现按照这样编写代码还是不能在控件里显示图片。
要怎样做才能达到目的?
1 个解决方案
#1
先修改图片控件的属性:属性->general->Type选择Bitmap
这个方法只能显示bmp类型的图片到picture控件
HBITMAP bitmap=(HBITMAP)LoadImage(AfxGetInstanceHandle(),"D:\\x.bmp",
IMAGE_BITMAP,0,0,LR_LOADFROMFILE);
ASSERT(bitmap);
CStatic *pIpic=(CStatic*)GetDlgItem(IDC_STATIC);
pIpic->SetBitmap(bitmap);
这个方法只能显示bmp类型的图片到picture控件
HBITMAP bitmap=(HBITMAP)LoadImage(AfxGetInstanceHandle(),"D:\\x.bmp",
IMAGE_BITMAP,0,0,LR_LOADFROMFILE);
ASSERT(bitmap);
CStatic *pIpic=(CStatic*)GetDlgItem(IDC_STATIC);
pIpic->SetBitmap(bitmap);
#1
先修改图片控件的属性:属性->general->Type选择Bitmap
这个方法只能显示bmp类型的图片到picture控件
HBITMAP bitmap=(HBITMAP)LoadImage(AfxGetInstanceHandle(),"D:\\x.bmp",
IMAGE_BITMAP,0,0,LR_LOADFROMFILE);
ASSERT(bitmap);
CStatic *pIpic=(CStatic*)GetDlgItem(IDC_STATIC);
pIpic->SetBitmap(bitmap);
这个方法只能显示bmp类型的图片到picture控件
HBITMAP bitmap=(HBITMAP)LoadImage(AfxGetInstanceHandle(),"D:\\x.bmp",
IMAGE_BITMAP,0,0,LR_LOADFROMFILE);
ASSERT(bitmap);
CStatic *pIpic=(CStatic*)GetDlgItem(IDC_STATIC);
pIpic->SetBitmap(bitmap);