共用方式為


SystemEvents.PaletteChanged 事件

定義

當使用者切換至使用不同調色盤的應用程式時發生。

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

事件類型

例外狀況

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

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

範例

下列程式代碼範例示範如何監視 PaletteChanged 事件。 此程式代碼範例是提供給 類別之較大範例的 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

備註

注意

只有在訊息幫浦正在執行時,才會引發此事件。 在 Windows 服務中,除非使用隱藏表單或訊息幫浦手動啟動,否則不會引發此事件。 如需示範如何使用 Windows 服務中的隱藏表單來處理系統事件的程式代碼範例,請參閱 類別 SystemEvents

警告

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

適用於