Home > Software engineering >  MFC picture can't display HBITMAP
MFC picture can't display HBITMAP

Time:09-20

GDI screen capture to figure, to get the HBITMAP then want to use display picture controls within the dialog, change the control type to call after the BITMAP CStatic SetBitmap method, within the dialog cannot display, bosses, please advice

CodePudding user response:

"With a picture control display, the control type to the BITMAP after "?

CodePudding user response:

reference 1st floor schlafenhamster response:
"display with picture controls, the control type to the BITMAP after "?

Yes, is only to get the data can be??

CodePudding user response:

Picture is derived to control CStatic
Why should control type to the BITMAP? (only a CBitmap)

CodePudding user response:

reference schlafenhamster reply: 3/f
picture is derived to control CStatic
Why should control type to the BITMAP? (only a CBitmap)

In the attribute selection, a BITMAP

CodePudding user response:

"Have a BITMAP in the attribute selection,"
Picture control is derived to CStatic class type did not change
GDI screen capture to figure, make the BITMAP is ok,

CodePudding user response:

 
HBITMAP CopyScreenToBitmap (CRect & amp; The Rect, HWND HWND)
{
HDC hScrDC hMemDC;
HBITMAP hOldBitmap HBITMAP;
Int xScrn yScrn;
//to screen coordinates.
MapWindowPoints (HWND, NULL, (POINT *) & amp; The Rect, 2);
HScrDC=CreateDC (" DISPLAY ", NULL, NULL, NULL);
HMemDC=CreateCompatibleDC (hScrDC);
//
XScrn=GetDeviceCaps (hScrDC HORZRES);
YScrn=GetDeviceCaps (hScrDC VERTRES);
//
If (the Rect. Left & lt; 0) of the Rect. Left=0;
If (the Rect. Top & lt; 0) of the Rect. Top=0;
If (the Rect. Right & gt; The Rect xScrn). Right=xScrn;
If (the Rect. Bottom & gt; The Rect yScrn). The bottom=yScrn;
//
HBitmap=CreateCompatibleBitmap (hScrDC, the Rect. Width (), the Rect. Height ());
HOldBitmap=(HBITMAP) SelectObject (hMemDC HBITMAP);
BitBlt (hMemDC, 0, 0, the Rect. Width (), the Rect. Height (), hScrDC, the Rect. Left, the Rect. Top, SRCCOPY);
HBitmap=(hBitmap) SelectObject (hMemDC hOldBitmap);
//
DeleteDC (hScrDC);
DeleteDC (hMemDC);
//
Return the hBitmap;
}

CodePudding user response:

HBITMAP scope for?
Whether useful Invalid UpdateWindow by drawing?

CodePudding user response:

VS2013, I just want to say, if choose the bitmap in the properties, a compiler error, resource file cannot be opened, the pit a force, don't know if you have the same problem

CodePudding user response:

ModifyStyle (0 xf, SS_BITMAP | SS_CENTERIMAGE);
  • Related