Jump to content

How to know which EDIT GUICTRL is active?


Recommended Posts

I have two tabs, which are TAB_1 and TAB_2, there are two EDIT controls, one in TAB_1, another in TAB_2, respectively.

My question is, how to know which EDIT control is active?---I mean, to know which one is in front?

I tried GUICtrlGetState, but two EDIT controls return 80, I also tried GUICtrlRead($tab), but nothing return.

Link to post
Share on other sites

You could use ControlCommand to check if the Edit is visible?

If ControlCommand($hGUI, '', ControlGetHandle($hGUI, '', $Edit_1), 'IsVisible') = 1 Then
    ConsoleWrite('Edit_1 is visible' & @CRLF)
ElseIf ControlCommand($hGUI, '', ControlGetHandle($hGUI, '', $Edit_2), 'IsVisible') = 1 Then
    ConsoleWrite('Edit_2 is visible' & @CRLF)
EndIf

If you're wanting to know which tab is selected, you could use _GUICtrlTab_GetCurSel.

#include <GuiTab.au3>

Local $iCurSel = _GUICtrlTab_GetCurSel($Tab_1)

 

Link to post
Share on other sites
29 minutes ago, Luke94 said:

You could use ControlCommand to check if the Edit is visible?

If ControlCommand($hGUI, '', ControlGetHandle($hGUI, '', $Edit_1), 'IsVisible') = 1 Then
    ConsoleWrite('Edit_1 is visible' & @CRLF)
ElseIf ControlCommand($hGUI, '', ControlGetHandle($hGUI, '', $Edit_2), 'IsVisible') = 1 Then
    ConsoleWrite('Edit_2 is visible' & @CRLF)
EndIf

If you're wanting to know which tab is selected, you could use _GUICtrlTab_GetCurSel.

#include <GuiTab.au3>

Local $iCurSel = _GUICtrlTab_GetCurSel($Tab_1)

 

Great, that's what I need, thanks.

Link to post
Share on other sites
5 hours ago, September said:

I also tried GUICtrlRead($tab), but nothing return.

I highly doubt that.  See example :

#include <GUIConstantsEx.au3>

Example()

Func Example()
    GUICreate("Test")
    Local $tab = GUICtrlCreateTab(10, 10, 400, 400)

    GUICtrlCreateTabItem("tab0")
    GUICtrlCreateEdit("ed1", 20, 40, 250, 250)

    GUICtrlCreateTabItem("tab1")
    GUICtrlCreateEdit("ed2", 20, 40, 250, 250)

    GUICtrlCreateTabItem("")
    GUISetState()

    While 1
        If GUIGetMsg() = $GUI_EVENT_CLOSE Then ExitLoop
        ConsoleWrite(GUICtrlRead($tab) & @CRLF)
    WEnd
EndFunc   ;==>Example

 

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
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...