Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>you should call the PrintWindow API:</p> <pre><code>void CScreenShotDlg::OnPaint() { // device context for painting CPaintDC dc(this); // Get the window handle of calculator application. HWND hWnd = ::FindWindow( 0, _T( "Calculator" )); // Take screenshot. PrintWindow( hWnd, dc.GetSafeHdc(), 0 ); } </code></pre> <p>see this question: <a href="https://stackoverflow.com/questions/2447172/getting-window-screenshot-windows-api">getting window screenshot windows API</a></p> <p>if you are not using MFC, here the pure PrintWindow signature:</p> <pre><code>BOOL PrintWindow( HWND hwnd, HDC hdcBlt, UINT nFlags ); </code></pre> <p>see MSDN for more details: <a href="http://msdn.microsoft.com/en-us/library/dd162869(v=vs.85).aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/dd162869(v=vs.85).aspx</a></p> <p>about how to save it as bitmap asMatteo said depends on the actual framework you are using...</p> <p><strong>EDIT:</strong></p> <p>here full example in raw C++</p> <pre><code>#define _WIN32_WINNT 0x0501 //xp #include &lt;windows.h&gt; int main() { RECT rc; HWND hwnd = FindWindow(TEXT("Notepad"), NULL); //the window can't be min if (hwnd == NULL) { cout &lt;&lt; "it can't find any 'note' window" &lt;&lt; endl; return 0; } GetClientRect(hwnd, &amp;rc); //create HDC hdcScreen = GetDC(NULL); HDC hdc = CreateCompatibleDC(hdcScreen); HBITMAP hbmp = CreateCompatibleBitmap(hdcScreen, rc.right - rc.left, rc.bottom - rc.top); SelectObject(hdc, hbmp); //Print to memory hdc PrintWindow(hwnd, hdc, PW_CLIENTONLY); //copy to clipboard OpenClipboard(NULL); EmptyClipboard(); SetClipboardData(CF_BITMAP, hbmp); CloseClipboard(); //release DeleteDC(hdc); DeleteObject(hbmp); ReleaseDC(NULL, hdcScreen); cout &lt;&lt; "success copy to clipboard, please paste it to the 'mspaint'" &lt;&lt; endl; return 0; } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload