Detect desktop wallpaper has been changed in a module?

P

Patrick Dugan

I have a small application that is a module that creates a tray icon. I
would like to be able to detect whenever the desktop wallpaper has
changed. I found this routine:

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Public Const SPI_SETDESKWALLPAPER As Integer = 20
Public Const WM_SETTINGCHANGE As Integer = 26

' let's override WndProc...
Protected Overloads Overrides Sub WndProc(ByRef m As
System.Windows.Forms.Message)
' if it's WM_SETTINGCHANGE
If m.Msg = WM_SETTINGCHANGE Then
If m.WParam.ToInt32() = SPI_SETDESKWALLPAPER Then
' do something here...
listBox1.Items.Add("Wallpaper has changed/set!")
Return
End If
End If
' else let default WndProc() handle it
MyBase.WndProc(m)
End Sub
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

However it seems I cannot implement it within a module. Is there
any way to alter this code or another method to detect when the desktop
wallpaper has changed?
 
M

Mattias Sjögren

Is there
any way to alter this code or another method to detect when the desktop
wallpaper has changed?

Have you tried using the SystemEvents class?


Mattias
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top