How to have Daisy Fuentes?

I've got this really cool and seductive picture of Daisy which I want to use for a wallpaper on my pc at work.  Unfortunately, people sometimes pop in to my cubicle, and they might not think my wallpaper is appropriate.  So...I want to write a little program /TSR for Win 95/NT.  The idea is that I could just quickly hit a hot key, say F12, and the wallpaper would change to something more acceptable (Although far more boring).  
     Can someone show me the code to change wallpapers, and how to get the program to run sort of like an NT service, but which would allow the quick hot key.  Maybe theres already a program to do this, so pointing me to that would be just as good.  I wish I could offer more points, but know that you will be helping many a man with this question!

:) dapperry
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

dapperryAuthor Commented:
Oh yeah, if anyone wants the picture just leave your email address.

:) dapperry
Here is Daisy!
Pressing F12 will toggle the wallpaper between the 2 images you setup in Form_Load.

Private Sub Form_Load()
    lHotkey = &HBF0F&
    'Setup your 2 images to swap here
    sWP1 = "c:\windows\Internet Explorer Wallpaper.bmp"
    sWP2 = "c:\windows\waves.bmp"
    'F12 is the hotkey to swap images
    Call RegisterHotKey(Me.hwnd, lHotkey, 0&, vbKeyF12)
    'Hook into the message stream to catch WM_HOTKEY message
    glPrevWndProc = fSubClass()
End Sub

Private Sub Form_Unload(Cancel As Integer)
    ' Stop intercepting messages.
    Call pUnSubClass
    Call UnregisterHotKey(Me.hwnd, lHotkey)
End Sub

Option Explicit

Public Const GWL_WNDPROC = (-4)
Declare Function SystemParametersInfo Lib "user32" Alias _
    "SystemParametersInfoA" (ByVal uAction As Long, ByVal uParam _
    As Long, ByVal lpvParam As Any, ByVal fuWinIni As Long) As Long
Declare Function RegisterHotKey Lib "user32" _
    (ByVal hwnd As Long, ByVal id As Long, _
    ByVal fsModifiers As Long, ByVal vk As Long) As Long
Declare Function UnregisterHotKey Lib "user32" _
    (ByVal hwnd As Long, ByVal id As Long) As Long

Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" _
    (ByVal hwnd As Long, ByVal nIndex As Long, _
    ByVal dwNewLong As Long) As Long
Declare Function CallWindowProc Lib "user32" Alias "CallWindowProcA" _
    (ByVal lpPrevWndFunc As Long, ByVal hwnd As Long, _
    ByVal Msg As Long, ByVal wParam As Long, _
    ByVal lParam As Long) As Long
Public Const WM_HOTKEY = &H312

Public sWP1 As String
Public sWP2 As String
Public lHotkey As Long
Public glPrevWndProc As Long
Private bToggle As Boolean

Public Sub pUnSubClass()
' Stops the form from intercepting Window's messages
' by resetting the default procedures associated
' with the form.
Call SetWindowLong(Form1.hwnd, GWL_WNDPROC, glPrevWndProc)
End Sub

Public Function pMyWindowProc(ByVal hw As Long, ByVal uMsg As Long, _
    ByVal wParam As Long, ByVal lParam As Long) As Long
' This is the callback procedure used when a message is received
' by this form.  The desired message is processed and all others are
' passed back to the original procedure associated with the form.
If uMsg = WM_HOTKEY Then
    If wParam = lHotkey Then
        If Not bToggle Then
            Call SetWallpaper(sWP2)
            Call SetWallpaper(sWP1)
        End If
        bToggle = Not bToggle
    End If
End If

pMyWindowProc = CallWindowProc(glPrevWndProc, hw, uMsg, wParam, lParam)
End Function

Public Function fSubClass() As Long
' Subclass the form by replacing the "normal" procedures associated
' with the form with procedure "pMyWindowProc".
' NOTE: Comment all calls to fSubClass while in IDE.
fSubClass = SetWindowLong(Form1.hwnd, GWL_WNDPROC, AddressOf pMyWindowProc)
End Function

Public Sub SetWallpaper(ByVal FileName As String)
    Dim x As Long
    x = SystemParametersInfo(SPI_SETDESKWALLPAPER, _
End Sub

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
dapperryAuthor Commented:
I will try to implement this code this afternoon, and will get back to you soon on how it works out.  Thanks.

:) dapperry
The Ultimate Tool Kit for Technolgy Solution Provi

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy for valuable how-to assets including sample agreements, checklists, flowcharts, and more!

dapperryAuthor Commented:
Ok, the code works great!  The only part of the question is how to make it work as a service, or hidden, or at least in the sys tray.  Let me know what the best thing to do here would be.  I think it would be great if it was hidden, but you could hit another hot key to bring up the form.  Then in the form you could choose the wallpapers to switch.  (In case I get any more sexy shots of Daisy!) Let me know, and thanks for your help thus far.

:) dapperry
The best option would be to make the program reside in the system tray.  You can have the program startup hidden or minimized in the tray.  To restore the program, use the tray icon.

Here is a MS article which shows how to put your program into the system tray:
dapperryAuthor Commented:
It works great.  Thanks a lot.  BTW, please check out my new question, or how to determine/remove a shortcut from the startup.

:) dapperry
dapperryAuthor Commented:
      Just an update.  I completed my program.  It seems to work fine on Win 95, but the hot keys seem to have no effect in Win NT 4.  Any idea why?

:) dapperry
Here's what MS says about RegisterHotkey:

Return Values
If the function succeeds, the return value is nonzero.
If the function fails, the return value is zero.

[check to make sure RegisterHotkey returns a nonzero number]

RegisterHotKey fails if the keystrokes specified for the hot key have already been registered by another hot key.

[make sure F12 is not already a reserved hotkey]
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.