Home > Software engineering >  A problem with MFC show screenshots, trouble great god to help me have a look at it, grateful!!!!!!!
A problem with MFC show screenshots, trouble great god to help me have a look at it, grateful!!!!!!!

Time:09-30

Want to directly in the window display screen capture, but the following code can only be part of the display window, screenshots, try to ask you how great god changes can show full screen, or change what data can obtain the rest of the screen screenshots??????
I was directly to set up a basic dialog box to realize the code, then I hope you can help me with great god, thank you all for the great god, trouble, very grateful!!!!!!!!!!
 HDC m_hDC=: : GetDC (NULL); 
//create the associated
HDC m_MemDC=CreateCompatibleDC (m_hDC);
//get X/Y
Int x=GetSystemMetrics (SM_CXSCREEN);
Int y=GetSystemMetrics (SM_CYSCREEN);
//create a canvas
HBITMAP MemPic=: : CreateCompatibleBitmap (m_hDC, x, y);
: : SelectObject (m_MemDC MemPic);
//copy to memory
: : BitBlt (m_MemDC, 0, 0, x, y, m_hDC, 0, 0, SRCCOPY);

//save
HDC m_MainDC=: : GetDC (m_hWnd);
: : BitBlt (m_MainDC, 0, 0, x, y, m_MemDC, 0, 0, SRCCOPY);
: : ReleaseDC (m_hWnd, m_MainDC);

: : DeleteObject (MemPic);
: : DeleteDC (m_MemDC);
: : ReleaseDC (NULL, m_hDC);

CodePudding user response:

 
Void CMyDlg: : OnButton1 ()
{
HDC HDC=: : GetDC (NULL);
//create the associated
HDC MemDC=CreateCompatibleDC (HDC);
//get X/Y
Int x=GetSystemMetrics (SM_CXSCREEN);
Int y=GetSystemMetrics (SM_CYSCREEN);
//create a canvas
HBITMAP MemPic=: : CreateCompatibleBitmap (hDC, x, y);
: : SelectObject (MemDC MemPic);
//copy to memory
: : BitBlt (MemDC, 0, 0, x, y, hDC, 0, 0, SRCCOPY);

//save
HDC MainDC=: : GetDC (m_hWnd);
CRect rc;
GetClientRect (& amp; Rc);
SetStretchBltMode (MainDC, HALFTONE);
: : StretchBlt (MainDC, 0, 0, rc. The Width (), rc, Height (), MemDC, 0, 0, x, y, SRCCOPY);
//: : BitBlt (MainDC, 0, 0, x, y, MemDC, 0, 0, SRCCOPY);
: : ReleaseDC (m_hWnd, MainDC);

: : DeleteObject (MemPic);
: : DeleteDC (MemDC);
: : ReleaseDC (NULL, hDC);


1 the unnecessary m_ deleted
2 began to save, using the current window size
HDC MainDC=: : GetDC (m_hWnd);
CRect rc;
GetClientRect (& amp; Rc);
SetStretchBltMode (MainDC, HALFTONE);
: : StretchBlt (MainDC, 0, 0, rc. The Width (), rc, Height (), MemDC, 0, 0, x, y, SRCCOPY);
//: : BitBlt (MainDC, 0, 0, x, y, MemDC, 0, 0, SRCCOPY);

CodePudding user response:

Scaling of the show again

CodePudding user response:

copy WINAPI hDC lpRect part to the specified file (BMP file format) in Dstfile

CodePudding user response:

HDC m_hDC=: : GetDC (NULL);
//create the associated
HDC m_MemDC=CreateCompatibleDC (m_hDC);
//get X/Y
Int x=GetSystemMetrics (SM_CXSCREEN);
Int y=GetSystemMetrics (SM_CYSCREEN);
//create a canvas
HBITMAP MemPic=: : CreateCompatibleBitmap (m_hDC, x, y);
: : SelectObject (m_MemDC MemPic);
//copy to memory
: : BitBlt (m_MemDC, 0, 0, x, y, m_hDC, 0, 0, SRCCOPY);
//here, you have the window data copies to m_MemDC

//save
HDC m_MainDC=: : GetDC (m_hWnd);
: : BitBlt (m_MainDC, 0, 0, x, y, m_MemDC, 0, 0, SRCCOPY);
//window you have no way to show the whole bitmap, beyond the window part is pruned the
: : ReleaseDC (m_hWnd, m_MainDC);

: : DeleteObject (MemPic);
: : DeleteDC (m_MemDC);
: : ReleaseDC (NULL, m_hDC);
  • Related