Sign in to follow this  
Followers 0
Triton

Type of GUI control

5 posts in this topic

Is there a way to find out the type of gui control from its variable?

I have an array of gui controls and I want to be able to discover which ones are checkboxes vs inputs.

Any suggestions would be appreciated!


Triton

Share this post


Link to post
Share on other sites



You could try GuiCtrlRead(). The return from a checkbox will be the state info, while the return from an input will be text.

Share this post


Link to post
Share on other sites

Thanks That was too easy! Int vs String


Triton

Share this post


Link to post
Share on other sites

what's about returning 0 and I'm sure it's not a checkbox? I got the following info from Auto3Info:

Class: AfxFrameOrView42u

ClassnameNN: AfxFrameOrView42u2

Advanced (Class): [CLASS:AfxFrameOrView42u; INSTANCE:2]

ID: 119

Style: 0x50000000

ExStyle: 0x00000000

Share this post


Link to post
Share on other sites

Triton

Example:

#include <GuiConstantsEx.au3>

Opt("GuiOnEventMode", 1)

$hGUI = GUICreate("GetClassName Demo", 200, 100)
GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")

$cButton = GUICtrlCreateButton("Button", 11, 11, 75, 23)

$cCheckbox = GUICtrlCreateCheckbox("CheckBox", 11, 51, 80, 16)

$cInput = GUICtrlCreateInput("Hello", 91, 12, 100, 20)

GUISetState()

MsgBox(0, "ClassName", "Button: " & _GetClassName(GUICtrlGetHandle($cButton)))
MsgBox(0, "ClassName", "CheckBox: " & _GetClassName(GUICtrlGetHandle($cCheckbox)))
MsgBox(0, "ClassName", "Input: " & _GetClassName(GUICtrlGetHandle($cInput)))

While 1
    Sleep(100)
WEnd

Func _GetClassName($hWnd)
    Local $aRet = DllCall("User32.dll", "int", "GetClassName", _
                                                "hwnd", $hWnd, _
                                                "str", "", _
                                                "int", 256)
    If $aRet[0] Then Return $aRet[2]
EndFunc   ;==>_GetClassName

Func _Exit()
    GUIDelete($hGUI)
    Exit
EndFunc   ;==>_Exit

:)

Share this post


Link to post
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
Sign in to follow this  
Followers 0