Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


HWND question?

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
blqxxxxxxx
Cheater
Reputation: 0

Joined: 25 Aug 2009
Posts: 37

PostPosted: Fri Feb 11, 2011 10:24 am    Post subject: HWND question? Reply with quote

Hi all Smile
[Delphi]I have a question about hwnd and syslistview32(listview). How can i get a handle from listview from another application? Surprised

Kind regards!

_________________
Back to top
View user's profile Send private message
atom0s
Moderator
Reputation: 205

Joined: 25 Jan 2006
Posts: 8587
Location: 127.0.0.1

PostPosted: Fri Feb 11, 2011 12:20 pm    Post subject: Reply with quote

Use FindWindow and FindWindowEx or EnumChildWindows.
_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
blqxxxxxxx
Cheater
Reputation: 0

Joined: 25 Aug 2009
Posts: 37

PostPosted: Fri Feb 11, 2011 1:24 pm    Post subject: Reply with quote

Code:

Handle := FindwindowEx(0,0, 'SYSLISTVIE32', nil);
postmessage(Handle, WM_LBUTTONDBLCLK,0,MakeLong(x,y));

naturally it will not work



1.png
 Description:
 Filesize:  36.37 KB
 Viewed:  9391 Time(s)

1.png



_________________
Back to top
View user's profile Send private message
atom0s
Moderator
Reputation: 205

Joined: 25 Jan 2006
Posts: 8587
Location: 127.0.0.1

PostPosted: Fri Feb 11, 2011 1:39 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
blqxxxxxxx
Cheater
Reputation: 0

Joined: 25 Aug 2009
Posts: 37

PostPosted: Sat Feb 12, 2011 10:09 am    Post subject: Reply with quote

Thank you Wiccaan Smile
_________________
Back to top
View user's profile Send private message
blqxxxxxxx
Cheater
Reputation: 0

Joined: 25 Aug 2009
Posts: 37

PostPosted: Tue Feb 15, 2011 4:25 am    Post subject: Reply with quote

I have 3 syslistview32(listviews) how to use one of them ([SysListView32] "" Handle: 722480)? Sad


Handle.png
 Description:
 Filesize:  4.08 KB
 Viewed:  9231 Time(s)

Handle.png



_________________
Back to top
View user's profile Send private message
Slugsnack
Grandmaster Cheater Supreme
Reputation: 71

Joined: 24 Jan 2007
Posts: 1857

PostPosted: Tue Feb 15, 2011 6:46 am    Post subject: Reply with quote

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
View user's profile Send private message
blqxxxxxxx
Cheater
Reputation: 0

Joined: 25 Aug 2009
Posts: 37

PostPosted: Wed Feb 16, 2011 3:46 am    Post subject: Reply with quote

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 Smile

_________________
Back to top
View user's profile Send private message
atom0s
Moderator
Reputation: 205

Joined: 25 Jan 2006
Posts: 8587
Location: 127.0.0.1

PostPosted: Wed Feb 16, 2011 10:53 am    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
blqxxxxxxx
Cheater
Reputation: 0

Joined: 25 Aug 2009
Posts: 37

PostPosted: Sat Feb 19, 2011 8:26 am    Post subject: Reply with quote

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 Sad
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? Sad

_________________
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites