mfc picture控件显示png图片

onpaint函数里添加程序:

CClientDC *pDC = new CClientDC(GetDlgItem(IDC_LIGHT));
CRect rect;
GetDlgItem(IDC_LIGHT)->GetWindowRect(&rect);
Graphics graphics(pDC->m_hDC); // Create a GDI+ graphics object
Image image(L"./res/png/light.png"); // Construct an image


graphics.DrawImage(&image, 0, 0, image.GetWidth(), image.GetHeight());
delete pDC;

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