Solved

Determining position of desktop icons

Posted on 1998-06-29
12
318 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
  • 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
 
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
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

This article surveys and compares options for encoding and decoding base64 data.  It includes source code in C++ as well as examples of how to use standard Windows API functions for these tasks. We'll look at the algorithms — how encoding and decodi…
As more and more people are shifting to the latest .Net frameworks, the windows presentation framework is gaining importance by the day. Many people are now turning to WPF controls to provide a rich user experience. I have been using WPF controls fo…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
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…

758 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now