5 out of 7 rated this helpful - Rate this topic

PrintWindow function

Applies to: desktop apps only

The PrintWindow function copies a visual window into the specified device context (DC), typically a printer DC.

Syntax

BOOL PrintWindow(
  HWND hwnd,
  HDC hdcBlt,
  UINT nFlags
);

Parameters

hwnd

A handle to the window that will be copied.

hdcBlt

A handle to the device context.

nFlags

The drawing options. It can be one of the following values.

ValueMeaning
PW_CLIENTONLY

Only the client area of the window is copied to hdcBlt. By default, the entire window is copied.

 

Return value

If the function succeeds, it returns a nonzero value.

If the function fails, it returns zero.

Remarks

Note  This is a blocking or synchronous function and might not return immediately. How quickly this function returns depends on run-time factors such as network status, print server configuration, and printer driver implementation—factors that are difficult to predict when writing an application. Calling this function from a thread that manages interaction with the user interface could make the application appear to be unresponsive.

The application that owns the window referenced by hWnd processes the PrintWindow call and renders the image in the device context that is referenced by hdcBlt. The application receives a WM_PRINT message or, if the PW_PRINTCLIENT flag is specified, a WM_PRINTCLIENT message. For more information, see WM_PRINT and WM_PRINTCLIENT.

Requirements

Minimum supported client

Windows XP

Minimum supported server

Windows Server 2003

Header

Winuser.h (include Windows.h)

Library

User32.lib

DLL

User32.dll

See also

Painting and Drawing Overview
Painting and Drawing Messages
WM_PRINT
WM_PRINTCLIENT

 

 

Send comments about this topic to Microsoft

Build date: 3/6/2012

Did you find this helpful?
(1500 characters remaining)
Community Content Add
Annotations FAQ
Flags
The only flag on this article is PW_PRINTCLIENT, but it's actually defined as PW_CLIENTONLY in WinUser.h.

#define PW_CLIENTONLY 0x00000001

PW Constants?

It would be *really* handy, if all possible values for nFlags would be given.

What kind of number is PW_PRINTCLIENT for instance?