DisplayPropertiesEventHandler 委托

定义

注意

在Windows 8.1后,DisplayProperties 类型和相关事件处理程序可能会更改或不可用。 请改用 DisplayInformation

表示处理显示属性事件的方法。

public delegate void DisplayPropertiesEventHandler(Platform::Object ^ sender);
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 65536)]
/// [Windows.Foundation.Metadata.Deprecated("DisplayProperties may be altered or unavailable for releases after Windows Phone 8.1. Instead, use DisplayInformation.", Windows.Foundation.Metadata.DeprecationType.Deprecate, 65536, Windows.Foundation.UniversalApiContract)]
/// [Windows.Foundation.Metadata.Guid(3688729345, 61857, 18129, 158, 227, 84, 59, 204, 153, 89, 128)]
class DisplayPropertiesEventHandler : MulticastDelegate
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 65536)]
/// [Windows.Foundation.Metadata.Guid(3688729345, 61857, 18129, 158, 227, 84, 59, 204, 153, 89, 128)]
/// [Windows.Foundation.Metadata.Deprecated("DisplayProperties may be altered or unavailable for releases after Windows Phone 8.1. Instead, use DisplayInformation.", Windows.Foundation.Metadata.DeprecationType.Deprecate, 65536, "Windows.Foundation.UniversalApiContract")]
class DisplayPropertiesEventHandler : MulticastDelegate
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
[Windows.Foundation.Metadata.Deprecated("DisplayProperties may be altered or unavailable for releases after Windows Phone 8.1. Instead, use DisplayInformation.", Windows.Foundation.Metadata.DeprecationType.Deprecate, 65536, typeof(Windows.Foundation.UniversalApiContract))]
[Windows.Foundation.Metadata.Guid(3688729345, 61857, 18129, 158, 227, 84, 59, 204, 153, 89, 128)]
public delegate void DisplayPropertiesEventHandler(object sender);
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
[Windows.Foundation.Metadata.Guid(3688729345, 61857, 18129, 158, 227, 84, 59, 204, 153, 89, 128)]
[Windows.Foundation.Metadata.Deprecated("DisplayProperties may be altered or unavailable for releases after Windows Phone 8.1. Instead, use DisplayInformation.", Windows.Foundation.Metadata.DeprecationType.Deprecate, 65536, "Windows.Foundation.UniversalApiContract")]
public delegate void DisplayPropertiesEventHandler(object sender);
var displayPropertiesEventHandlerHandler = function(sender){
/* Your code */
}
Public Delegate Sub DisplayPropertiesEventHandler(sender As Object)

参数

sender
Object

Platform::Object

IInspectable

引发事件的对象。

属性

Windows 要求

设备系列
Windows 10 (在 10.0.10240.0 中引入)
API contract
Windows.Foundation.UniversalApiContract (在 v1.0 中引入)

示例

#include <winrt/Windows.Graphics.Display.h>
using namespace winrt;
using namespace Windows::Graphics::Display;
...
void GameRenderer::Initialize()
{
    DisplayProperties::StereoEnabledChanged({ this, &GameRenderer::OnStereoEnableChanged });
}

void GameRenderer::OnStereoEnableChanged(winrt::Windows::Foundation::IInspectable const& sender)
{
    UpdateForStereoChange();
}
void GameRenderer::Initialize()
{
    DisplayProperties::StereoEnabledChanged += 
        ref new DisplayPropertiesEventHandler(this, &GameRenderer::OnStereoEnableChanged);
}

void GameRenderer::OnStereoEnableChanged(_In_ Platform::Object^ sender)
{
    UpdateForStereoChange();
}

注解

建议应用程序使用单个委托来处理大多数显示事件,因为在大多数情况下,对每个显示属性的更改都需要应用程序自行重新绘制。 此外,许多属性更改都源于影响整个操作系统的单个模式更改。

Direct3D 11.1 简单立体声 3D 示例演示如何处理系统立体声更改。

适用于