| View previous topic :: View next topic |
| Author |
Message |
blqxxxxxxx Cheater
Reputation: 0
Joined: 25 Aug 2009 Posts: 37
|
Posted: Fri Feb 11, 2011 10:24 am Post subject: HWND question? |
|
|
Hi all
[Delphi]I have a question about hwnd and syslistview32(listview). How can i get a handle from listview from another application?
Kind regards!
_________________
|
|
| Back to top |
|
 |
atom0s Moderator
Reputation: 205
Joined: 25 Jan 2006 Posts: 8587 Location: 127.0.0.1
|
Posted: Fri Feb 11, 2011 12:20 pm Post subject: |
|
|
Use FindWindow and FindWindowEx or EnumChildWindows.
_________________
- Retired. |
|
| Back to top |
|
 |
blqxxxxxxx Cheater
Reputation: 0
Joined: 25 Aug 2009 Posts: 37
|
Posted: Fri Feb 11, 2011 1:24 pm Post subject: |
|
|
| Code: |
Handle := FindwindowEx(0,0, 'SYSLISTVIE32', nil);
postmessage(Handle, WM_LBUTTONDBLCLK,0,MakeLong(x,y)); |
naturally it will not work
| Description: |
|
| Filesize: |
36.37 KB |
| Viewed: |
9391 Time(s) |

|
_________________
|
|
| Back to top |
|
 |
atom0s Moderator
Reputation: 205
Joined: 25 Jan 2006 Posts: 8587 Location: 127.0.0.1
|
Posted: Fri Feb 11, 2011 1:39 pm Post subject: |
|
|
You need to call FindWindow first to get the parent windows hwnd, then use FindWindowEx to obtain the children. Passing 0 as the parent causes FindWindowEx to automatically use HWND_DESKTOP which then finds the first instance of that control and uses that which can give you invalid results.
_________________
- Retired. |
|
| Back to top |
|
 |
blqxxxxxxx Cheater
Reputation: 0
Joined: 25 Aug 2009 Posts: 37
|
Posted: Sat Feb 12, 2011 10:09 am Post subject: |
|
|
Thank you Wiccaan
_________________
|
|
| Back to top |
|
 |
blqxxxxxxx Cheater
Reputation: 0
Joined: 25 Aug 2009 Posts: 37
|
|
| Back to top |
|
 |
Slugsnack Grandmaster Cheater Supreme
Reputation: 71
Joined: 24 Jan 2007 Posts: 1857
|
Posted: Tue Feb 15, 2011 6:46 am Post subject: |
|
|
| One way to do it is to get each of the HWNDs and use GetDlgCtrlId() checking against some hardcoded value you find originally.
|
|
| Back to top |
|
 |
blqxxxxxxx Cheater
Reputation: 0
Joined: 25 Aug 2009 Posts: 37
|
Posted: Wed Feb 16, 2011 3:46 am Post subject: |
|
|
ok. I found it ( ID: 33217, class: SysListView32, caption: ). Now how to use it in FindWindowEx?
| Code: |
HandleWindow := Findwindow('X',0);
H := FindwindowEx(HandleWindow,0, 'class', 0);
postmessage(H, WM_LBUTTONDBLCLK,0,MakeLong(x,y)); |
Thanks for your help
_________________
|
|
| Back to top |
|
 |
atom0s Moderator
Reputation: 205
Joined: 25 Jan 2006 Posts: 8587 Location: 127.0.0.1
|
Posted: Wed Feb 16, 2011 10:53 am Post subject: |
|
|
Try using GetDlgItem, use the main windows hWnd for the first param, and the ID you found for the second. It should return the controls hWnd.
_________________
- Retired. |
|
| Back to top |
|
 |
blqxxxxxxx Cheater
Reputation: 0
Joined: 25 Aug 2009 Posts: 37
|
Posted: Sat Feb 19, 2011 8:26 am Post subject: |
|
|
I tried with this
| Code: |
HandleWindow := Findwindow('X',0);
H := GetDlgitem(HandleWindow,33217);
postmessage(H, WM_LBUTTONDBLCLK,0,MakeLong(100,20));
showmessage(inttostr(GetDlgCtrlId(H)));
|
but the message shows me 0
when i use this
| Code: |
HandleWindow := Findwindow('X',0);
getcursorpos(P);
H := windowfrompoint(P);
GetDlgCtrlId(H);
postmessage(H, WM_LBUTTONDBLCLK,0,MakeLong(100,20));
showmessage(inttostr(GetDlgCtrlId(H))); |
showmessage shows me 33217 and it works perfectly.
| Code: |
function EnumProc(wnd: HWND; Lines: TStrings): BOOL; stdcall;
var
buf, Caption: array [0..255] of char;
begin
Result := True;
GetClassname(HandleWindow, buf, 256);
GetWindowText(HandleWindow, Caption, 256);
Lines.Add(Format('ID: %d, class: %s, caption: %s',
[GetDlgCtrlID(HandleWindow), buf, Caption]));
end;
buttonclick
GetCursorpos(P);
HandleWindow := windowfrompoint(P);
GetWindowRect(HandleWindow,R);
EnumChildWindows(HandleWindow, @EnumProc, Integer(memo1.Lines));
|
I find the ID with this function. Where am I wrong?
_________________
|
|
| Back to top |
|
 |
|