duilib 动态加载非资源图片

duilib 动态加载非资源图片

思路:使用bitmap加载外部图片,将Bitmap转为HBITMAP,加载到paintmanager中,然后控件加载paintmanager中的HBITMAP资源。
Bitmap btm(_T(“E:\pic\test.bmp”));

HBITMAP hBitmap = NULL;
if (Gdiplus::Ok == btm.GetHBITMAP(NULL, &hBitmap))
{
	CDuiString sCtrlKey = _T("your_key_name");

	if(m_pCodeLab)
	{	
		m_PaintManager.RemoveImage(sCtrlKey);	
		m_PaintManager.AddImage(sCtrlKey, hBitmap,w, h, false);		//w图片宽度  h图片高度
		m_pCodeLab->SetBkImage(sCtrlKey);
	}

}

猜你喜欢

转载自blog.csdn.net/sunqingok/article/details/82799861