We help IT Professionals succeed at work.

Check out our new AWS podcast with Certified Expert, Phil Phillips! Listen to "How to Execute a Seamless AWS Migration" on EE or on your favorite podcast platform. Listen Now

x

Determining position of desktop icons

patel4694
patel4694 asked
on
Medium Priority
347 Views
Last Modified: 2013-12-03
I want to write a screen saver that moves icons, windows etc that are currently on or open on the desktop.  I can determine the position of any window open, but am not sure how to get the position of icons on the desktop.  

Does anyone now how to get a hold of the positions of the icons on the desktop.
Comment
Watch Question

Commented:
The Icons are part of the desktop program, not part of the OS, so there is no API for handling them.  However there is a OLE interface to the desktop manager called IShellLink.  You might look into that.

Commented:
Check the following registry entries

HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\
    Explorer\Streams, and
    Explorer\StreamMRU

Then look into IShellBrowser::GetViewStateStream().

Also, do a search for Q171002,
    How Windows Stores View Preferences
   
   

Author

Commented:
I too had found the registry entries, but how does one actually parse the binary. I do not see how ShellBrowser::GetViewStateStream() would help if I have no means of parsing the stream.

I tried to look for:

>Also, do a search for Q171002,
>   How Windows Stores View Preferences

but I did not find it on MSDN(I'm assumming that is where you meant)  I also tried to look for that question on experts exchange but there are too many question to actually browse through.

Any more suggestions.  If you have sample code or attachements you would like to send me, please send to apatel@sight-n-sound.com

Commented:
Have a look at the online help of 'IShellFolder' in your Devstudio :) There you
can access all information you need. The Desktop is of course
just a simple IShellFolder too, accessed by SHGetDesktopFolder


Author

Commented:
looks like this IShellFolder will only help in returning all info but the pysicall location of an items in the folder.

I want the CRect in screen cordinates of the area being occupied by an icon on the desktop. Sorry, but I don not see a way to get to that info using the IShellFolder.

 

Commented:
Well, enuerate the items, then go via GetDesktopWindow
and GetRect of the items ... didn't try yet, should work

Commented:
I assume that u r talking about screen saver that looks something like those done by LizardWork Inc. As far as I know, there is only 1 way to do this. That is to write a hook program in a dll and then inject this hook into the desktop instance using SetWindowsHookEx.

Author

Commented:
To connex,

I'm confused.  How do you get the rect of the item from the DesktopWindowHandle when all you have is the item(which is not even a window).

Please elaborate more.
Call GetDektopWindow to get the handle of the desktop. Sicnce the desktop is a listview based window, it's supposed to respond to listview messages. Use SendMessage LVM_GETITEMPOSITION to get the item pos
Tell me how it goes

Author

Commented:
Mike, please respond to this question as an answer and not a comment(since that is the only way I can give you the points)

Meanwhile, I will try your suggestion, which make great sense.  I guess the key to this question was knowing that the Desktop was a CListView derived object.

thanks.
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION

Commented:
Hi all,
As I've mentioned before, using hook is the only way out. I've tried before using the way MikeP mentioned but it could not work out. May be I did it wrongly, please keep me update with the progress as i'm also interested in this issue. Why this way fails is because Desktop is in a protected process. As u try to retrieve info from it, your explorer will generate a GP fault. Don't believe, u try. This is logical as every process in Win32 is protected. I could only set the icons positions but unable to retrieve them. At least this could not be done without using hook. If anyone know of a way, please let me know. Thanks!!!
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.