载入png图片
CStatic* pWndYL = (CStatic*)GetDlgItem(IDC_PIC_YL); CImage imageYL; imageYL.Load((m_strAppPath + _T("src/ylSelected.png")).c_str()); HBITMAP hBmpYL = imageYL.Detach(); pWndYL->SetBitmap(hBmpYL); pWndYL->SetWindowPos(NULL, 0, 0, 100, 50, SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOZORDER);
|
插入图片
IDC_STATIC_PICTURE 是 picture box 控件的 ID
CImage image; image.Load(m_vPersonInfo[itemData].picPath.c_str()); CRect rect; int cx = image.GetWidth(); int cy = image.GetHeight();
GetDlgItem(IDC_STATIC_PICTURE)->GetWindowRect(&rect); ScreenToClient(&rect); GetDlgItem(IDC_STATIC_PICTURE)->MoveWindow(rect.left, rect.top, rect.Width(), rect.Height(), TRUE);
CWnd *pWnd = GetDlgItem(IDC_STATIC_PICTURE);
pWnd->GetClientRect(&rect);
CDC *pDC = pWnd->GetDC(); pDC->SetStretchBltMode(COLORONCOLOR); image.Draw(pDC->m_hDC, rect); ReleaseDC(pDC);
|
响应单击事件
将其notify属性设置为true。