1.在资源视图,选择PictureControl,并且在属性中把Type设置为Bitmap。
2.加载PNG
CStatic* pWnd = (CStatic*)GetDlgItem(IDC_PIC); // 得到 Picture Control 句柄
CImage image;
image.Load(_T("png.png");
HBITMAP hBmp = image.Detach();
pWnd->SetBitmap(hBmp);
pWnd->SetWindowPos(NULL,
0,
0,
100,
50,
SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOZORDER);
3.加载BMP
CStatic* pWnd = (CStatic*)GetDlgItem(IDC_PIC); // 得到 Picture Control 句柄
pWnd->ModifyStyle(0, SS_BITMAP); // 修改它的属性为位图
pWnd->SetBitmap((HBITMAP)::LoadImage(NULL, _T("bmp.bmp"),
IMAGE_BITMAP,
100,
50,
LR_CREATEDIBSECTION | LR_DEFAULTSIZE | LR_LOADFROMFILE));