MFC picture控件加载图标和位图


图标 

Pic控件type设置为icon
 //DDX_Control(pDX, IDC_LAMP_WORK1, m_ctrlLampWork1);//为pic控件IDC_LAMP_WORK1添加变量
m_ctrlLampWork1.SetIcon(AfxGetApp()->LoadIcon(IDI_LAMP_GREEN));// IDI_LAMP_GREEN图标ID
m_ctrlLampWork1.SetIcon(AfxGetApp()->LoadIcon(IDI_LAMP_GRAY)); // IDI_LAMP_GRAY图标ID
    

位图

Pic控件type设置为Bitmap
HBITMAP hBitmap_GRAY,hBitmap_GREEN,hBitmap_RED; 
//DDX_Control(pDX, IDC_Pic_in, m_Pic1);// 为pic控件IDC_Pic_in添加变量
hBitmap_GRAY = ::LoadBitmap(AfxGetInstanceHandle(),MAKEINTRESOURCE(IDB_BITMAP_GRAY)); 
	hBitmap_GREEN = ::LoadBitmap(AfxGetInstanceHandle(),MAKEINTRESOURCE(IDB_BITMAP_GGREEN)); 
	hBitmap_RED = ::LoadBitmap(AfxGetInstanceHandle(),MAKEINTRESOURCE(IDB_BITMAP_RRED)); 
m_Pic1.SetBitmap(hBitmap_GRAY);//灰色位图
m_Pic1.SetBitmap(hBitmap_GREEN);//绿色位图
m_Pic1.SetBitmap(hBitmap_RED);//红色位图


智能推荐

注意!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系我们删除。



 
© 2014-2019 ITdaan.com 粤ICP备14056181号  

赞助商广告