Jump to content

how can determine whether it is a form or a control by a given Handle?


Recommended Posts

Given a handle, how can it be used to determine whether it is a form or a control?

In AU3 functions, forms and controls use different functions, and some properties of forms or controls are different. How to determine whether a handle is a form or a control by a fetched handle (for example, a handle from a point)

Link to comment
Share on other sites

This may help you:

#include <WinAPI.au3>
#include <GUIListView.au3>

Local $hGui = GUICreate('test')
Local $cLV1 = GuiCtrlCreateListView('1|2', 10, 10, 200, 150)
Local $hLV2 = _GUICtrlListView_Create($hGui, 'A|B', 10, 180, 200, 150)

GUISetState()

ConsoleWrite('_WinAPI_GetDlgCtrlID($hGui): ' & _GetCtrlID($hGui) & @CRLF)
ConsoleWrite('_WinAPI_GetDlgCtrlID($cLV1): ' & _GetCtrlID($cLV1) & @CRLF)
ConsoleWrite('_WinAPI_GetDlgCtrlID($hLV2): ' & _GetCtrlID($hLV2) & @CRLF)

Do
Until GUIGetMsg() = -3

Func _GetCtrlID($vWnd)
    Local $hWnd = IsHWnd($vWnd) ? $vWnd : GUICtrlGetHandle($vWnd)
    Return _WinAPI_GetDlgCtrlID($hWnd)
EndFunc

 

Best Regards BugFix  

Link to comment
Share on other sites

6 hours ago, BugFix said:

This may help you:

#include <WinAPI.au3>
#include <GUIListView.au3>

Local $hGui = GUICreate('test')
Local $cLV1 = GuiCtrlCreateListView('1|2', 10, 10, 200, 150)
Local $hLV2 = _GUICtrlListView_Create($hGui, 'A|B', 10, 180, 200, 150)

GUISetState()

ConsoleWrite('_WinAPI_GetDlgCtrlID($hGui): ' & _GetCtrlID($hGui) & @CRLF)
ConsoleWrite('_WinAPI_GetDlgCtrlID($cLV1): ' & _GetCtrlID($cLV1) & @CRLF)
ConsoleWrite('_WinAPI_GetDlgCtrlID($hLV2): ' & _GetCtrlID($hLV2) & @CRLF)

Do
Until GUIGetMsg() = -3

Func _GetCtrlID($vWnd)
    Local $hWnd = IsHWnd($vWnd) ? $vWnd : GUICtrlGetHandle($vWnd)
    Return _WinAPI_GetDlgCtrlID($hWnd)
EndFunc

 

Thanks BugFix ! Now I know that _ WinAPI_GetDlgCtrlID is so useful. It looks like windows, controls, ID and handles  are explained more in MFC, so I'll find some learning materials to learn. Thanks again!

Link to comment
Share on other sites

In addition, I would like to ask two more questions:

1, Use "Au3Info. Exe" when collecting window information, what is the function or method in which the "instance" is obtained?

such as, WinWaitActive ("[TITLE: my window; CLASS: my class; INSTANCE:2] ",") 

2, if want to use the "X\ Y\ W\ H-window location and size" attributes to identify the window, how do write the expression?

[TITLE: my window; CLASS: my class; INSTANCE:2;64\ 128\ 435\ 218]?

Thanks in advance....

Edited by Letraindusoir
Link to comment
Share on other sites

On ‎3‎/‎31‎/‎2019 at 11:21 PM, Letraindusoir said:

In addition, I would like to ask two more questions:

2, if want to use the "X\ Y\ W\ H-window location and size" attributes to identify the window, how do write the expression?

[TITLE: my window; CLASS: my class; INSTANCE:2;64\ 128\ 435\ 218]?

Thanks in advance....

I searched and only find one topic in the forum:

ControlSetText($_currentWindowHWND, "", "[X:1081; Y:9; W:188; H:15]", $_orderNumber)

Edited by Letraindusoir
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...