Articles   Members Online:
-Article/Tip Search
-News Group Search over 21 Million news group articles.
-Delphi/Pascal
-CBuilder/C++
-C#Builder/C#
-JBuilder/Java
-Kylix
Member Area
-Home
-Account Center
-Top 10 NEW!!
-Submit Article/Tip
-Forums Upgraded!!
-My Articles
-Edit Information
-Login/Logout
-Become a Member
-Why sign up!
-Newsletter
-Chat Online!
-Indexes NEW!!
Employment
-Build your resume
-Find a job
-Post a job
-Resume Search
Contacts
-Contacts
-Feedbacks
-Link to us
-Privacy/Disclaimer
Embarcadero
Visit Embarcadero
Embarcadero Community
JEDI
Links
How to get the X- and Y-coordinates of Desktop icons Turn on/off line numbers in source code. Switch to Orginial background IDE or DSP color Comment or reply to this aritlce/tip for discussion. Bookmark this article to my favorite article(s). Print this article
30-Aug-02
Category
System
Language
Delphi 2.x
Views
105
User Rating
No Votes
# Votes
0
Replies
0
Publisher:
DSP, Administrator
Reference URL:
DKB
			Author: Tomas Rutkauskas 

Does anyone know where the X- and Y-coordinates of the icons on the Windows Desktop 
are stored/ saved and how I can read and write those values?

Answer:

Since the desktop is a simple ListView (embedded in a few other windows), you'll be 
able to find it with this (from a little utility of mine). It uses IPCThrd.pas from 
the IPCXXX demos in the demos directory, for the SharedMem class. You'll have to 
use that, since otherwise you won't be able to read the information from desktop's 
memory into your memory.


1   type
2     PInfo = ^TInfo;
3     TInfo = packed record
4       infoPoint: TPoint;
5       infoText: array[0..255] of Char;
6       infoItem: TLVItem;
7       infoFindInfo: TLVFindInfo;
8     end;
9   
10    {...}
11  
12  var
13    Info: PInfo;
14    IniFile: TRegIniFile;
15    Wnd: HWnd;
16    Count, I: Integer;
17    SharedMem: TSharedMem;
18  begin
19    {Find list view window}
20    Wnd := FindWindowEx(GetDesktopWindow, 0, 'Progman', 'Program Manager');
21    Wnd := FindWindowEx(Wnd, 0, 'SHELLDLL_DefView', nil);
22    Wnd := FindWindowEx(Wnd, 0, 'SysListView32', nil);
23    Count := ListView_GetItemCount(Wnd);
24    SharedMem := TSharedMem.Create('', SizeOf(TInfo));
25    Info := SharedMem.Buffer;
26    with Info^ do
27    try
28      infoItem.pszText := infoText;
29      infoItem.cchTextMax := 255;
30      infoItem.mask := LVIF_TEXT;
31      IniFile := TRegIniFile.Create('Software\YaddaYadda');
32      try
33        with IniFile do
34        begin
35          EraseSection('Desktop\' + CurRes);
36          for I := 0 to Count - 1 do
37          begin
38            infoItem.iItem := I;
39            try
40              ListView_GetItem(Wnd, infoItem);
41              ListView_GetItemPosition(Wnd, I, infoPoint);
42              WriteString('Desktop\' + CurRes, infoText, Format('%.4d, %.4d', 
43  [Point.X,
44                Point.Y]));
45            except
46            end;
47          end;
48        end;
49      finally
50        IniFile.Free;
51      end;
52    finally
53      SharedMem.Free;
54    end;
55  end;


			
Vote: How useful do you find this Article/Tip?
Bad Excellent
1 2 3 4 5 6 7 8 9 10

 

Advertisement
Share this page
Advertisement
Download from Google

Copyright © Mendozi Enterprises LLC