Window.SetWindowDisplayAffinity
-------------------------------

Sets the window display affinity.

| Component | Version | macOS | Windows | Linux | Server | iOS SDK |
|---|---|---|---|---|---|---|
| [Window](component_Window.md) | [15.3](newinversion153.md) | ❌ No | ✅ Yes | ❌ No | ❌ No | ❌ No |

MBS( "Window.SetWindowDisplayAffinity"; WindowRef; Value ) 

**MBS**( **"Window.SetWindowDisplayAffinity";** /\* Sets the window display affinity. \*/  
**$WindowRef**; /\* Window Reference is the unique OS level window ID. You can obtain this by using the [Window.FindByTitle](WindowFindByTitle.md) or [Window.FindByIndex](WindowFindByIndex.md) functions. Pass zero to access the frontmost window.e.g. 0 \*/   
**$Value**) /\* The display affinity setting that specifies where the content of the window can be displayed. \*/ 

### Parameters

| Parameter | Description | Example |
|---|---|---|
| WindowRef | Window Reference is the unique OS level window ID. You can obtain this by using the [Window.FindByTitle](WindowFindByTitle.md) or [Window.FindByIndex](WindowFindByIndex.md) functions. Pass zero to access the frontmost window. | 0 |
| Value | The display affinity setting that specifies where the content of the window can be displayed. |  |

### Result

Returns OK or error.

### Description

Sets the window display affinity.  
Specifies where the content of the window can be displayed.  
  
The display affinity setting that specifies where the content of the window can be displayed.  
  
This parameter can be one of the following values:  
  
| Name | Value | Meaning |
|---|---|---|
| None | 0 | Imposes no restrictions on where the window can be displayed. |
| Monitor | 1 | The window content is displayed only on a monitor. Everywhere else, the window appears with no content. |
| ExcludeFromCapture | &amp;h11 | 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. |

  
This property is 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, will strictly protect windowed content, for example where someone takes a photograph of the screen.  
  
Starting in Windows 10 Version 2004, ExcludeFromCapture is a supported value. Setting the display affinity to ExcludeFromCapture on previous version of Windows will behave as if Monitor is applied.  
### See also

- [Window.FindByIndex](WindowFindByIndex.md)
- [Window.FindByTitle](WindowFindByTitle.md)
- [Window.GetWindowDisplayAffinity](WindowGetWindowDisplayAffinity.md)

### Release notes

- **Version 15.3**
    - Added [Window.GetWindowDisplayAffinity](https://www.mbsplugins.eu/WindowGetWindowDisplayAffinity.shtml) and [Window.SetWindowDisplayAffinity](https://www.mbsplugins.eu/WindowSetWindowDisplayAffinity.shtml) functions.

### Blog Entries

- [MBS FileMaker Plugin 15.3 News](https://www.mbsplugins.de/archive/2025-07-29/MBS_FileMaker_Plugin_153_News/monkeybreadsoftware_blog_filemaker)
- [MBS FileMaker Plugin, version 15.3pr1](https://www.mbsplugins.de/archive/2025-06-01/MBS_FileMaker_Plugin_version_1/monkeybreadsoftware_blog_filemaker)

This function checks for a license.

Created 22nd May 2025 , last changed 29th June 2025

  
[Window.SetTopMost](WindowSetTopMost.md) - [Window.SetZoomButton](WindowSetZoomButton.md)

[HTML Version](WindowSetWindowDisplayAffinity.shtml)