SystemEvents.UserPreferenceChanging Evento

Definición

Se produce cuando se van a cambiar las preferencias de un usuario.

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 

Tipo de evento

Excepciones

No se admiten las notificaciones de eventos del sistema en el contexto actual. Los procesos del servidor, por ejemplo, quizá no admitan las notificaciones globales de eventos del sistema.

No se ha podido crear correctamente un subproceso de ventana de eventos del sistema.

Ejemplos

En el ejemplo de código siguiente se muestra cómo supervisar el UserPreferenceChanging evento. Este ejemplo de código es parte de un ejemplo más grande proporcionado para la clase 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

Comentarios

Nota

Este evento solo se genera si se está ejecutando la bomba de mensajes. En un servicio de Windows, a menos que se use un formulario oculto o se haya iniciado manualmente la bomba de mensajes, este evento no se generará. Para ver un ejemplo de código que muestra cómo controlar los eventos del sistema mediante un formulario oculto en un servicio de Windows, vea la SystemEvents clase .

Precaución

Dado que se trata de un evento estático, debe desasociar los controladores de eventos cuando se elimina la aplicación o se producirán pérdidas de memoria.

Se aplica a

Consulte también