Solved

Determining position of desktop icons

Posted on 1998-06-29
12
325 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.
0
Comment
Question by:patel4694
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
  • 2
  • +3
12 Comments
 
LVL 22

Expert Comment

by:nietod
ID: 1408976
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.
0
 
LVL 1

Expert Comment

by:Musashi
ID: 1408977
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
   
   
0
 

Author Comment

by:patel4694
ID: 1408978
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

0
SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

 
LVL 2

Expert Comment

by:connex
ID: 1408979
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


0
 

Author Comment

by:patel4694
ID: 1408980
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.

 

0
 
LVL 2

Expert Comment

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

0
 

Expert Comment

by:waimun
ID: 1408982
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.
0
 

Author Comment

by:patel4694
ID: 1408983
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.
0
 
LVL 8

Expert Comment

by:MikeP090797
ID: 1408984
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
0
 

Author Comment

by:patel4694
ID: 1408985
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.
0
 
LVL 8

Accepted Solution

by:
MikeP090797 earned 300 total points
ID: 1408986
First try and make sure it's working
0
 

Expert Comment

by:waimun
ID: 1408987
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!!!
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes how to programmatically preset the "Pages per Sheet" option that's available with most printer drivers.   This setting lets you do "n-Up" printing, where two, four, or more pages are printed on each sheet of paper. If your …
This article describes how to add a user-defined command button to the Windows 7 Explorer toolbar.  In the previous article (http://www.experts-exchange.com/A_2172.html), we saw how to put the Delete button back there where it belongs.  "Delete" is …
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

688 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question