Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


Moving icons on Desktop

Posted on 2005-03-03
Medium Priority
Last Modified: 2011-09-20

I would like to ask how can I  list all icons on the desktop and then send message to one of them to move somewhere.

Question by:Murdoc
  • 3
LVL 11

Assisted Solution

ZhaawZ earned 160 total points
ID: 13454879
A short sample of getting a handle of 'desktop' (actually - a listview (SysListView32) control that holds icons) and a count of icons.

  wnd : cardinal;
  cnt : integer;
wnd := FindWindow('progman', 'Program Manager');
wnd := FindWindowEx(wnd, 0, 'SHELLDLL_DefView', nil);
wnd := FindWindowEx(wnd, 0, 'SysListView32', 'FolderView');
cnt := SendMessage(wnd, $1004{lvm_getitemcount}, 0, 0);
ShowMessageFmt('There are %d icons', [cnt]);

Haven't found a way to get labels and positions for icons yet. I could try it next evening - it's too late now (1:45AM) ;)
I hope this helps

Author Comment

ID: 13456721
will check this out in few 'cause going out of town :)
LVL 20

Accepted Solution

Madshi earned 160 total points
ID: 13456836
The problem is that using list view messages over process boundaries only work that easily when no pointers are contained in the messages. Otherwise you run into problems.

An easy solution would be to use madShell, with which you could e.g. do this:

uses madShell;

  Desktop.Item('My Computer').Position := Point(500, 500);

madShell is free for non-commercial usage. Here's the online documentation:


If you don't want to use a 3rd party component like madShell, then I suggest that you write a little hook dll which you inject into the explorer by using SetWindowsHookEx. This dll could then use the list view messages to do what you want.

Author Comment

ID: 13479165
have to split points between both of you...hope it will be fair

Thanks for help


Author Comment

ID: 13479215
oops have no idea how to choose which answer should be accepted and which one suppose to be assisted....


Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

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 explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…
Kernel Data Recovery is a renowned Data Recovery solution provider which offers wide range of softwares for both enterprise and home users with its cost-effective solutions. Let's have a quick overview of the journey and data recovery tools range he…

564 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