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中添加图片