SystemEvents.UserPreferenceChanging 事件
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
當使用者喜好設定正在變更時發生。
public:
static event Microsoft::Win32::UserPreferenceChangingEventHandler ^ UserPreferenceChanging;
public static event Microsoft.Win32.UserPreferenceChangingEventHandler UserPreferenceChanging;
public static event Microsoft.Win32.UserPreferenceChangingEventHandler? UserPreferenceChanging;
member this.UserPreferenceChanging : Microsoft.Win32.UserPreferenceChangingEventHandler
Public Shared Custom Event UserPreferenceChanging As UserPreferenceChangingEventHandler
事件類型
例外狀況
目前內容不支援系統事件告知。 例如,伺服器處理序可能就不支援全域系統事件告知。
建立系統事件視窗執行緒的嘗試未成功。
範例
下列程式代碼範例示範如何監視 UserPreferenceChanging 事件。 此程式代碼範例是提供給 類別之較大範例的 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 。
警告
因為這是靜態事件,所以您必須在處置應用程式時卸離事件處理程式,否則記憶體流失將會產生。