Jump to content

When checkbox is checked


v0id
 Share

Recommended Posts

I have this script. My intention: if you select Regular user and then check box SVE, for example, it gives a text area. Same for FIN or DAN or NOR. So if I select 3 checkboxes - 3 text areas should appear beneath the checkboxes.

I tried with another Select (testing with MsgBox for now:

            Select
               Case $SVECheckBox And BitAND(GUICtrlRead($SVECheckBox), $GUI_CHECKED) = $GUI_CHECKED
                  MsgBox(4096, "SVE checked", "Box1 is checked.")
            EndSelect

But it did not work. Tried with If statement - still no result.

What am I doing wrong? (full script attached)

 

example.au3

Link to comment
Share on other sites

I think I fixed it with declaring global variables before the function:

<...>

GUISetState(@SW_SHOW)

            Global $SVECheckBox
            Global $FINCheckBox
            Global $DANCheckBox
            Global $NORCheckBox

UserType()

Func UserType()

<...>

 

Now I need for CreateEdit to appear. The way I did right now is like this:

             Select

                Case $SVECheckBox And BitAND(GUICtrlRead($SVECheckBox), $GUI_CHECKED) = $GUI_CHECKED
                  ;MsgBox(4096, "SVE checked", "Box1 is checked.")
                   Local $SVEMyedit = GUICtrlCreateEdit("First line" & @CRLF, 8, 360, 122, 97, $ES_AUTOVSCROLL + $WS_VSCROLL)
                   Send("{END}")
                   GUICtrlSetData($SVEMyedit, "Second line", 1)

<...>

But it does not work for multiple checkboxes. Any hints?

 

example.au3

Link to comment
Share on other sites

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

$main = GUICreate("Test",  400, 300)
$cbx1 = GUICtrlCreateCheckbox("CBX1", 10, 10, 90, 24)
$ed1 = GUICtrlCreateEdit('', 100, 10, 200, 100)
GUICtrlSetState($ed1, $GUI_HIDE)
GUISetState(@SW_SHOW)

While 1
   $msg = GUIGetMsg()
   Select
        Case $msg = $GUI_EVENT_CLOSE
            Exit
        Case $msg = $cbx1
            If IsChecked($cbx1) Then
                GUICtrlSetState($ed1, $GUI_SHOW)
            Else
                GUICtrlSetState($ed1, $GUI_HIDE)
            EndIf

    EndSelect
WEnd

Func IsChecked($control)
    Return BitAND(GUICtrlRead($control), $GUI_CHECKED) = $GUI_CHECKED
EndFunc

 

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...