VCPictureControl显示BMP图片
7,763 views
0
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); }
参考推荐:
版权所有: 本文系米扑博客原创、转载、摘录,或修订后发表,最后更新于 2012-07-23 20:38:13
侵权处理: 本个人博客,不盈利,若侵犯了您的作品权,请联系博主删除,莫恶意,索钱财,感谢!