Change desktop background based on program shortcut
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6

Thread: Change desktop background based on program shortcut

Hybrid View

  1. #1
    Join Date
    Sep 2012
    Posts
    3

    Change desktop background based on program shortcut

    Hi, could anyone give me the general idea on how to implement this feature?

    Basically, i want the desktop background to change whenever user place the mouse on program's shortcut.
    It's not clicking, just Focusing.
    You know, just place your mouse cursor on the shortcut and the background will change.

    i.e:
    I have a halo 4 game shortcut on my desktop
    I place the mouse to that shortcut, and the background will change to halo 4 wallpaper
    When i click it the game will run normally.

    By default windows shows the location of the program's exe when the shortcut is focused.
    I couldn't find the registry files that control this feature, nor the method to tweak windows shortcuts...

    thanks before.

  2. #2
    Join Date
    Oct 2002
    Location
    Timisoara, Romania
    Posts
    14,360

    Re: Change desktop background based on program shortcut

    You have to define "focused". Do you mean just hovering the cursor over the shortcut's text and icon, or actually clicking on it (not double clicking to launch the program)?
    Marius Bancila
    Home Page
    My CodeGuru articles

    I do not offer technical support via PM or e-mail. Please use vbBulletin codes.

  3. #3
    Join Date
    Sep 2012
    Posts
    3

    Re: Change desktop background based on program shortcut

    Quote Originally Posted by cilu View Post
    You have to define "focused". Do you mean just hovering the cursor over the shortcut's text and icon, or actually clicking on it (not double clicking to launch the program)?
    By focus, I mean hovering the cursor over shortcuts icon, and after set times, 3 sec for example it will change the wallpaper.. by default windows shows the location of the exe file when focused, i want it to be changed to wallpaper change..

  4. #4
    Join Date
    Oct 2008
    Posts
    1,088

    Re: Change desktop background based on program shortcut

    AFAIK, the easiest way I can think of is to write an infotip shell extension handler ( google for further info ): when you are asked for the tooltip text you also set the desktop background ( but only if the mouse is on the desktop window, of course ). Alternatively (or if you need more control), you'll need to hook the ListView window holding the desktop icons, not a comfortable task though ( consider that you'll need to read from that window process memory in order to retrieve info from the list view ) ...
    Last edited by superbonzo; September 10th, 2012 at 05:25 AM.

  5. #5
    Join Date
    Sep 2012
    Posts
    3

    Re: Change desktop background based on program shortcut

    Quote Originally Posted by superbonzo View Post
    AFAIK, the easiest way I can think of is to write an infotip shell extension handler ( google for further info ): when you are asked for the tooltip text you also set the desktop background ( but only if the mouse is on the desktop window, of course ). Alternatively (or if you need more control), you'll need to hook the ListView window holding the desktop icons, not a comfortable task though ( consider that you'll need to read from that window process memory in order to retrieve info from the list view ) ...
    thanks for the answer,
    does this mean i can just find the infotip registry value for specific shortcut?
    but is it possible to execute the script (that will change the wallpaper) from infotip handler?

  6. #6
    Join Date
    Oct 2008
    Posts
    1,088

    Re: Change desktop background based on program shortcut

    Quote Originally Posted by denywinarto View Post
    does this mean i can just find the infotip registry value for specific shortcut?
    no, it means that you have to write a COM DLL implementing a so called "shell extension handler". Once registered, this will be invoked by Windows whenever a tooltip is required by user action in the shell environment; in your case, when the user hovers the mouse on a desktop icon your handler will be notified of the "focused" file path ( say, the .lnk file ) and the tooltip will be queried, via IPersistFile::Load and IQueryInfo::GetInfoTip, respectively.
    IPersistFile::Load should just store the file path and IQueryInfo::GetInfoTip should create a tooltip and modify the desktop background ( or even better, it should send the filename to an auxillary process asynchronously; in this way, any blocking operation ( like, say, disk access for wallpaper searching ) would not make the shell unresponsive; moreover, in this way you could do things like reverting to the original background ( based on a timer or user action ), exposing a system tray icon for advanced user settings, etc ... ).

    if you google "infotip shell extension handler" the first result offers a complete example to start from ...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Azure Activities Information Page

Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center