Draw a bitmap on picture control in MFC

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
Hi,
I need to get rounded region in the picture control and then draw a bitmap over the picture control.
I am using below code in onpaint() for drawing bitmap over picture control but it is not at all showing image in picture control.
CWnd* pImage = GetDlgItem(IDC_PICTURE_CONTROL);
CRect rc;
pImage->GetWindowRect(rc);
HRGN hRgn = CreateRoundRectRgn(0, 0, rc.Width(), rc.Height(), 40, 40);
HINSTANCE hIns = AfxGetInstanceHandle();
HBITMAP hBmp = LoadBitmap(hIns, MAKEINTRESOURCE(IDB_IMAGE));
HBRUSH hBr = CreatePatternBrush(hBmp);
DeleteObject(hIns);
DeleteObject(hBmp);
FillRgn(pEmergencyImage->GetWindowDC()->GetSafeHdc(), hRgn, hBr);
Whats wrong with my code.

View the full article
 
Back
Top