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 againCodePudding user response:
copy WINAPI hDC lpRect part to the specified file (BMP file format) in DstfileCodePudding 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);