VC Picture Control显示BMP图片

长平狐 发布于 2013/01/06 11:17
阅读 1K+
收藏 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); 
}


参考推荐:

使用Picture Control显示BMP图片

VC怎样在picture control中添加图片



原文链接:http://blog.csdn.net/sunboy_2050/article/details/7776880
加载中
返回顶部
顶部