I tried your code as well, it did not work for me either.
About the form not having focus suggestion, I don't think that's the case because my form modifies the registry setting directly.
HKEY_CURRENT_USER\Control Panel\Desktop\SCRNSAVE.EXE
I also tried changing the screensaver from display options just to be sure, but the event did not fire.
I still think we are missing a call to a sub or function.
Dim UserPref As New Microsoft.Win32.UserPreferenceChangedEventHandler(AddressOf UserPreferenceChangedHandler)
UserPref. ????
I'm going to look it up at the MSDN2 library and see if there is a sample.
In the MSDN2 library I found these two samples and neither worked:
'One
Public Delegate Sub UserPreferenceChangedEventHandler(ByVal sender As Object, ByVal e As UserPreferenceChangedEventArgs)
Dim instance As New UserPreferenceChangedEventHandler(AddressOf UserPreference)
Protected Overrides Sub OnHandleCreated(ByVal e As System.EventArgs)
MyBase.OnHandleCreated(e)
End Sub
Protected Overrides Sub OnHandleDestroyed(ByVal e As System.EventArgs)
MyBase.OnHandleDestroyed(e)
End Sub
Private Sub UserPreference(ByVal sender As Object, ByVal e As UserPreferenceChangedEventArgs)
MessageBox.Show(Me.Text, "Settings Changed")
End Sub
'Two
Public Shared Event UserPreferenceChanged As UserPreferenceChangedEventHandler
Dim handler As UserPreferenceChangedEventHandler
Protected Overrides Sub OnHandleCreated(ByVal e As System.EventArgs)
MyBase.OnHandleCreated(e)
AddHandler SystemEvents.UserPreferenceChanged, handler
End Sub
Protected Overrides Sub OnHandleDestroyed(ByVal e As System.EventArgs)
RemoveHandler SystemEvents.UserPreferenceChanged, handler
MyBase.OnHandleDestroyed(e)
End Sub
Private Sub UserPreference(ByVal sender As Object, ByVal e As UserPreferenceChangedEventArgs) Handles Me.UserPreferenceChanged
MessageBox.Show(Me.Text, "Settings Changed")
End Sub
I even removed the screensaver category and still nothing???