Author: Jonas Bilinkevicius
I wonder if anyone can help me. I am trying to capture when the mouse button is
pressed on the desktop wallpaper (excluding icons if possible).
Answer:
This returns the same handle:
1 function GetDesktopListViewHandle: THandle;
2 var3 S: string;
4 begin5 Result := FindWindow('ProgMan', nil);
6 Result := GetWindow(Result, GW_CHILD);
7 Result := GetWindow(Result, GW_CHILD);
8 SetLength(S, 40);
9 GetClassName(Result, PChar(S), 39);
10 if PChar(S) <> 'SysListView32' then11 Result := 0;
12 end;
13 14 procedure TForm1.Timer1Timer(Sender: TObject);
15 var16 CursorPos: TPoint;
17 h: THandle;
18 begin19 GetCursorPos(CursorPos);
20 h := WindowFromPoint(CursorPos);
21 Label1.Caption := IntToStr(h);
22 end;
23 24 procedure TForm1.FormShow(Sender: TObject);
25 begin26 Label2.Caption := IntToStr(GetDesktopListViewHandle); { GetDeskTopWindow); }27 Timer1.Enabled := True;
28 end;