本文主要是介绍VC Picture Control显示BMP图片,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
VC对话框初始时,Picture Control显示BMP图片:
BOOL CLoginDog::OnInitDialog()
{ CDialog::OnInitDialog(); HBITMAP hBitmap; //添加登陆窗口中的图片//关联图片ID hBitmap =(HBITMAP)LoadImage(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDB_BITMAP_LOGIN_PIC), IMAGE_BITMAP,0,0, LR_LOADMAP3DCOLORS); CStatic *pStatic=(CStatic *)GetDlgItem(IDC_STATIC_PIC); //获得指向静态控件的指针pStatic->ModifyStyle(0xF,SS_BITMAP|SS_CENTERIMAGE); //设置静态控件的样式,使其位图居中 pStatic->SetBitmap(hBitmap); //设置静态控件显示位图return TRUE;
}
SetBitmap定义如下:
// uBmpResource:图片ID; uCtrlResource: Picture控件ID
void SetBitmap(UINT uBmpResource, UINT uCtrlResource)
{ HBITMAP hBitmap; CStatic *pStatic = (CStatic *)GetDlgItem(uCtrlResource); hBitmap = (HBITMAP)LoadImage( AfxGetInstanceHandle(), MAKEINTRESOURCE(uBmpResource), IMAGE_BITMAP, 0, 0, LR_LOADMAP3DCOLORS); pStatic->ModifyStyle(0xF, SS_BITMAP); pStatic->SetBitmap(hBitmap);
}
参考推荐:
使用Picture Control显示BMP图片
VC怎样在picture control中添加图片
这篇关于VC Picture Control显示BMP图片的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!