It is currently Wed May 27, 2020 12:46 pm

All times are UTC + 1 hour




Post new topic Reply to topic  [ 7 posts ] 
Author Message
 Post subject: Get belonging hwnd?
PostPosted: Fri Feb 22, 2019 8:22 pm 
Offline
User
User

Joined: Mon Jan 21, 2019 1:41 pm
Posts: 38
Hi,

As an example: Let's say you open Windows Explorer and from within its "Folder options" window.

Two questions:
01. The folder options window contains a few tabs and subsections with elements.
How do I get the hwnd of this window when the mouse is hovering over any element in this window?

02. How do I get the hwnd of the "root" window (the hwnd of the belonging Windows Explorer window) under the same assumption that the mouse is over any element in the folder options window?

Or more generalized:
How should this be done for any application (finding the hwnd of the window that the current hovered element belongs to and finding the hwnd of the main (if the current window is a child window) window)?

Tia,
Jacky


Top
 Profile  
Reply with quote  
 Post subject: Re: Get belonging hwnd?
PostPosted: Sat Feb 23, 2019 12:03 am 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Sun Sep 11, 2016 2:17 pm
Posts: 648
Try this :)

Get hwnd from mouse pos:
Code:
p.q
GetCursorPos_(@p);
Debug WindowFromPoint_(p)


Get root:
Code:
GetAncestor_(hwnd,#GA_ROOT)


Top
 Profile  
Reply with quote  
 Post subject: Re: Get belonging hwnd?
PostPosted: Sat Feb 23, 2019 9:12 am 
Offline
User
User

Joined: Mon Jan 21, 2019 1:41 pm
Posts: 38
Thank you, Mijikai!

Quote:
Get hwnd from mouse pos

This works fine.

Quote:
GetAncestor_(hwnd,#GA_ROOT)

This doesn't get me the hwnd of the window that the (sub) window belongs too.

E.g. if the folder options window is open and the mouse is inside of it, it returns
the hwnd of that folder options window and not the hwnd of the window it "belongs too" (the main Windows Explorer window)


Top
 Profile  
Reply with quote  
 Post subject: Re: Get belonging hwnd?
PostPosted: Sat Feb 23, 2019 11:50 am 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Sun Sep 11, 2016 2:17 pm
Posts: 648
For the 'root' window u can also try one of these Apis:

Code:
;GetWindow_() -> with #GW_OWNER
;GetPartent_()


Top
 Profile  
Reply with quote  
 Post subject: Re: Get belonging hwnd?
PostPosted: Sat Feb 23, 2019 8:50 pm 
Offline
Addict
Addict
User avatar

Joined: Tue Oct 09, 2007 2:15 am
Posts: 1118
Mijikai wrote:
For the 'root' window u can also try one of these Apis:

Code:
;GetWindow_() -> with #GW_OWNER
;GetPartent_()


A typo ;)

Code:
GetParent_()

_________________
PureBasic 5.71 LTS (Windows x86/x64) | Windows10 Pro x64 | Z370 Extreme4 | i7 8770k | 32GB RAM | iChill GeForce RTX 2080 Super | HAF XF Evo​​
English is not my native language... (I often use DeepL to translate my texts.)


Top
 Profile  
Reply with quote  
 Post subject: Re: Get belonging hwnd?
PostPosted: Sat Feb 23, 2019 9:04 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Sun Sep 11, 2016 2:17 pm
Posts: 648
Bisonte wrote:
A typo ;)


:mrgreen:


Top
 Profile  
Reply with quote  
 Post subject: Re: Get belonging hwnd?
PostPosted: Tue Feb 26, 2019 7:13 am 
Offline
User
User

Joined: Mon Jan 21, 2019 1:41 pm
Posts: 38
Thanks Mijikai,
Code:
GetWindow_() -> with #GW_OWNER

is what I was looking for :D


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 2 guests


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

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye