MFC CImage 类加载图片显示到控件

void CDemoDlg::ShowImage()
{
	CImage m_image;
	HDC m_imageHdc;
	CRect m_imageRect;
	// 得到控件对象
	CWnd *pWnd = GetDlgItem(IDC_STATIC_PICTURE);

	// 获得控件的大小
	pWnd->GetClientRect(&m_imageRect);

	// 获取控件的绘图句柄
	m_imageHdc = pWnd->GetDC()->m_hDC;

	//显示图片
	CString files = "test.jpg";
	m_image.Destroy();
	m_image.Load(files);
	m_image.Draw(m_imageHdc, m_imageRect, Gdiplus::InterpolationModeHighQuality);
}



你可能感兴趣的:(C++,MFC,C++,mfc)