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 类。
注意
由于这是静态事件,因此必须在释放应用程序时分离事件处理程序,否则会导致内存泄漏。