共用方式為


SystemEvents.DisplaySettingsChanged 事件

定義

當使用者變更顯示設定時發生。

public:
 static event EventHandler ^ DisplaySettingsChanged;
public static event EventHandler DisplaySettingsChanged;
public static event EventHandler? DisplaySettingsChanged;
member this.DisplaySettingsChanged : EventHandler 
Public Shared Custom Event DisplaySettingsChanged As EventHandler 

事件類型

例外狀況

目前內容不支援系統事件告知。 例如,伺服器處理序可能就不支援全域系統事件告知。

建立系統事件視窗執行緒的嘗試未成功。

範例

下列程式代碼範例示範如何監視 DisplaySettingsChanged 事件。 此程式代碼範例是針對 類別提供的較大範例的 SystemEvents 一部分。

int main()
{
    // Set the SystemEvents class to receive event notification
    // when a user preference changes, the palette changes, or
    // when display settings change.
    SystemEvents::UserPreferenceChanging += gcnew
        UserPreferenceChangingEventHandler(
        SystemEvents_UserPreferenceChanging);
    SystemEvents::PaletteChanged += gcnew
        EventHandler(SystemEvents_PaletteChanged);
    SystemEvents::DisplaySettingsChanged += gcnew
        EventHandler(SystemEvents_DisplaySettingsChanged);

    // For demonstration purposes, this application sits idle
    // waiting for events.
    Console::WriteLine("This application is waiting for system events.");
    Console::WriteLine("Press <Enter> to terminate this application.");
    Console::ReadLine();
}
static void Main() 
{         
    // Set the SystemEvents class to receive event notification when a user 
    // preference changes, the palette changes, or when display settings change.
    SystemEvents.UserPreferenceChanging += new 
        UserPreferenceChangingEventHandler(SystemEvents_UserPreferenceChanging);
    SystemEvents.PaletteChanged += new 
        EventHandler(SystemEvents_PaletteChanged);
    SystemEvents.DisplaySettingsChanged += new 
        EventHandler(SystemEvents_DisplaySettingsChanged);        

    // For demonstration purposes, this application sits idle waiting for events.
    Console.WriteLine("This application is waiting for system events.");
    Console.WriteLine("Press <Enter> to terminate this application.");
    Console.ReadLine();
}
'Set the SystemEvents class to receive event notification 
'when a user preference changes, the palette changes, or 
'when display settings change.
AddHandler SystemEvents.UserPreferenceChanging, _
AddressOf SystemEvents_UserPreferenceChanging

AddHandler SystemEvents.PaletteChanged, _
AddressOf SystemEvents_PaletteChanged

AddHandler SystemEvents.DisplaySettingsChanged, _
AddressOf SystemEvents_DisplaySettingsChanged

備註

警告

因為這是靜態事件,所以當您處置應用程式時,您必須卸離事件處理程式,否則記憶體流失將會導致。

適用於

另請參閱