@@ -1725,11 +1725,43 @@ internal override Control? ParentInternal
1725
1725
}
1726
1726
1727
1727
/// <summary>
1728
- /// If ShowInTaskbar is true then the form will be displayed in the Windows Taskbar.
1728
+ /// Gets or sets the behavior for preventing screen capture/video recording of the
1729
+ /// form's content via screen capture applications based on the Windows APIs.
1729
1730
/// </summary>
1730
- [ DefaultValue ( 0 ) ]
1731
+ /// <remarks>
1732
+ /// <para>
1733
+ /// This property determines how the form's content behaves when captured by screen capture applications
1734
+ /// or screenshots. Different capture modes provide varying levels of privacy and security for sensitive content.
1735
+ /// </para>
1736
+ /// <para>
1737
+ /// By default, forms allow their content to be captured. Setting this property to a more restrictive value
1738
+ /// can prevent sensitive information from being captured in screenshots or recorded in screen recordings.
1739
+ /// </para>
1740
+ /// <para>
1741
+ /// The setting takes effect immediately for visible forms. For forms that aren't yet shown,
1742
+ /// the setting takes effect when the form becomes visible.
1743
+ /// </para>
1744
+ /// <para>
1745
+ /// Warning! Additional top-level window, which will be spinning off the form, will not be affected
1746
+ /// by this setting. Please be aware, that for example sensitive information in a pop-up window
1747
+ /// like a MessageBox, a context menu, DropDownButton menus or PullDown-menus can not be prevented
1748
+ /// from being captured!
1749
+ /// </para>
1750
+ /// <para>
1751
+ /// Note that this setting only affects the current form and not any other windows in the application.
1752
+ /// Also note that this will also affect video streaming applications for video conferencing, etc.
1753
+ /// </para>
1754
+ /// <para>
1755
+ /// Disclaimer: Please keep in mind, that this setting can of course not prevent screen recordings by tools,
1756
+ /// which are either circumvent the public Windows APIs or use hardware-based screen capture methods.
1757
+ /// </para>
1758
+ /// </remarks>
1759
+ /// <value>
1760
+ /// One of the <see cref="ScreenCaptureMode"/> enumeration values. The default is
1761
+ /// <see cref="ScreenCaptureMode.Allow"/>.
1762
+ /// </value>
1731
1763
[ SRCategory ( nameof ( SR . CatWindowStyle ) ) ]
1732
- [ SRDescription ( "" ) ]
1764
+ [ SRDescription ( nameof ( SR . FormScreenCaptureModeDescr ) ) ]
1733
1765
public ScreenCaptureMode FormScreenCaptureMode
1734
1766
{
1735
1767
get => _formScreenCaptureMode ;
@@ -1749,6 +1781,12 @@ public ScreenCaptureMode FormScreenCaptureMode
1749
1781
}
1750
1782
}
1751
1783
1784
+ private bool ShouldSerializeFormScreenCaptureMode ( ) =>
1785
+ FormScreenCaptureMode != ScreenCaptureMode . Allow ;
1786
+
1787
+ private void ResetFormScreenCaptureMode ( ) =>
1788
+ FormScreenCaptureMode = ScreenCaptureMode . Allow ;
1789
+
1752
1790
private void SetScreenCaptureModeInternal ( ScreenCaptureMode value )
1753
1791
{
1754
1792
if ( ! TopLevel )
@@ -1767,19 +1805,6 @@ private void SetScreenCaptureModeInternal(ScreenCaptureMode value)
1767
1805
PInvoke . SetWindowDisplayAffinity ( HWND , affinity ) ;
1768
1806
}
1769
1807
1770
- private ScreenCaptureMode GetScreenCaptureModeInternal ( )
1771
- {
1772
- PInvoke . GetWindowDisplayAffinity ( HWND , out uint affinityValue ) ;
1773
- WINDOW_DISPLAY_AFFINITY affinity = ( WINDOW_DISPLAY_AFFINITY ) affinityValue ;
1774
-
1775
- return affinity switch
1776
- {
1777
- WINDOW_DISPLAY_AFFINITY . WDA_EXCLUDEFROMCAPTURE => ScreenCaptureMode . HideWindow ,
1778
- WINDOW_DISPLAY_AFFINITY . WDA_MONITOR => ScreenCaptureMode . HideContent ,
1779
- _ => ScreenCaptureMode . Allow ,
1780
- } ;
1781
- }
1782
-
1783
1808
/// <summary>
1784
1809
/// If ShowInTaskbar is true then the form will be displayed in the Windows Taskbar.
1785
1810
/// </summary>
0 commit comments