Skip to content

Latest commit

 

History

History
135 lines (111 loc) · 5.01 KB

nf-winuser-setwindowdisplayaffinity.md

File metadata and controls

135 lines (111 loc) · 5.01 KB
UID title description helpviewer_keywords old-location tech.root ms.assetid ms.date ms.keywords req.header req.include-header req.target-type req.target-min-winverclnt req.target-min-winversvr req.kmdf-ver req.umdf-ver req.ddi-compliance req.unicode-ansi req.idl req.max-support req.namespace req.assembly req.type-library req.lib req.dll req.irql targetos req.typenames req.redist ms.custom f1_keywords dev_langs topic_type api_type api_location api_name req.apiset
NF:winuser.SetWindowDisplayAffinity
SetWindowDisplayAffinity function (winuser.h)
Stores the display affinity setting in kernel mode on the hWnd associated with the window.
SetWindowDisplayAffinity
SetWindowDisplayAffinity function [Windows and Messages]
_win32_SetWindowDisplayAffinity
_win32_setwindowdisplayaffinity_cpp
winmsg.setwindowdisplayaffinity
winui._win32_setwindowdisplayaffinity
winuser/SetWindowDisplayAffinity
winmsg\setwindowdisplayaffinity.htm
winmsg
VS|winui|~\winui\windowsuserinterface\windowing\windows\windowreference\windowfunctions\setwindowdisplayaffinity.htm
12/05/2018
SetWindowDisplayAffinity, SetWindowDisplayAffinity function [Windows and Messages], _win32_SetWindowDisplayAffinity, _win32_setwindowdisplayaffinity_cpp, winmsg.setwindowdisplayaffinity, winui._win32_setwindowdisplayaffinity, winuser/SetWindowDisplayAffinity
winuser.h
Windows.h
Windows
Windows 7 [desktop apps only]
Windows Server 2008 R2 [desktop apps only]
User32.lib
User32.dll
Windows
19H1
SetWindowDisplayAffinity
winuser/SetWindowDisplayAffinity
c++
APIRef
kbSyntax
DllExport
User32.dll
Ext-MS-Win-NTUser-Window-l1-1-1.dll
Ext-MS-Win-NTUser-Window-l1-1-2.dll
ext-ms-win-ntuser-window-l1-1-3.dll
Ext-MS-Win-NTUser-Window-L1-1-4.dll
SetWindowDisplayAffinity
ext-ms-win-ntuser-window-l1-1-1 (introduced in Windows 8.1)

SetWindowDisplayAffinity function

-description

Specifies where the content of the window can be displayed.

-parameters

-param hWnd [in]

Type: HWND

A handle to the top-level window. The window must belong to the current process.

-param dwAffinity [in]

Type: DWORD

The display affinity setting that specifies where the content of the window can be displayed.

This parameter can be one of the following values.

Value Meaning
WDA_NONE
0x00000000
Imposes no restrictions on where the window can be displayed.
WDA_MONITOR
0x00000001
The window content is displayed only on a monitor. Everywhere else, the window appears with no content.
WDA_EXCLUDEFROMCAPTURE
0x00000011
The window is displayed only on a monitor. Everywhere else, the window does not appear at all.

One use for this affinity is for windows that show video recording controls, so that the controls are not included in the capture.

Introduced in Windows 10 Version 2004. See remarks about compatibility regarding previous versions of Windows.

-returns

Type: BOOL

If the function succeeds, it returns TRUE; otherwise, it returns FALSE when, for example, the function call is made on a non top-level window. To get extended error information, call GetLastError.

-remarks

This function and GetWindowDisplayAffinity are designed to support the window content protection feature that is new to Windows 7. This feature enables applications to protect their own onscreen window content from being captured or copied through a specific set of public operating system features and APIs. However, it works only when the Desktop Window Manager(DWM) is composing the desktop.

It is important to note that unlike a security feature or an implementation of Digital Rights Management (DRM), there is no guarantee that using SetWindowDisplayAffinity and GetWindowDisplayAffinity, and other necessary functions such as DwmIsCompositionEnabled, will strictly protect windowed content, for example where someone takes a photograph of the screen.

Starting in Windows 10 Version 2004, WDA_EXCLUDEFROMCAPTURE is a supported value. Setting the display affinity to WDA_EXCLUDEFROMCAPTURE on previous version of Windows will behave as if WDA_MONITOR is applied.

-see-also

SetWindowDisplayAffinity, Windows