Sign in to follow this  
Followers 0
autoitquestion

check boxes creation

17 posts in this topic

Hi,

I tried create more than one check box in same UI , however, in same time, I see only one

This what I did:

Local $avArray[3]=["Hanna","Danny","Moshe"]

Local $checkCN, $msg, $start, $i

GUICreate("Check boxes") ; will create a dialog box that when displayed is centered

$start=20

For $i = 1 to 3 Step 1

GUICtrlCreateCheckbox($avArray[$i], 10, 10, 120, $start)

$start +=30

Next

GUISetState()

Let me know where I'm mistake..

Thanks in advance!

Noa :-)

Share this post


Link to post
Share on other sites



autoitquestion,

- 1. Your array runs from 0 to 2, not 1 to 3 - and you do not need Step 1, that is the default.

- 2. You were increasing the "height" parameter - you need to change the "top":

Local $avArray[3]=["Hanna","Danny","Moshe"]
Local $checkCN, $msg, $start, $i
GUICreate("Check boxes") ; will create a dialog box that when displayed is centered

$start=20
For $i = 0 to 2 ; Step 1 <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
GUICtrlCreateCheckbox($avArray[$i], 10, $start, 120, 20) ; <<<<<<<<<<<<<<<
$start +=30
Next

GUISetState()

While 1
    If GUIGetMsg() = -3 Then Exit
WEnd

Look for the <<<<<<<<<<<<< lines. :unsure:

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

Oh... It's working!! thanks a lot..

After, I also create button:

$btn = GUICtrlCreateButton("Run", 120, 200, 60, 20)

And then I wish to get user selections..

Where I have user selections?

Hope my question is clear...

Thanks a lot!!

Noa :-)

Share this post


Link to post
Share on other sites

Oh... It's working!! thanks a lot..

After, I also create button:

$btn = GUICtrlCreateButton("Run", 120, 200, 60, 20)

And then I wish to get user selections..

Where I have user selections?

Hope my question is clear...

Thanks a lot!!

Noa :-)

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

autoitquestion,

You need to look at the state of the checkboxes like this:

#include <GUIConstantsEx.au3>

Global $avArray[3] = ["Hanna", "Danny", "Moshe"]
Global $avCheckID[3]
Global $checkCN, $msg, $start, $i

GUICreate("Check boxes") ; will create a dialog box that when displayed is centered

$start = 20
For $i = 0 To 2
    $avCheckID[$i] = GUICtrlCreateCheckbox($avArray[$i], 10, $start, 120, 20)
    $start += 30
Next

$btn = GUICtrlCreateButton("Run", 120, 200, 60, 20)

GUISetState()

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $btn
            ; Loop through the checkboxes
            For $i = 0 To 2
                ; Is this one checked?
                If GUICtrlRead($avCheckID[$i]) = 1 Then
                    ; If so then say so
                    ConsoleWrite("Checkbox " & $avArray[$i] & " is checked" & @CRLF)
                EndIf
                ConsoleWrite(@CRLF)
            Next
    EndSwitch
WEnd

All clear? :>

M23

Edit: Added the missing ; :unsure:

Edited by Melba23

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

Thanks a lot for all your help! very appricate it..

I dont know why, but it's did not work 4 me well.

It wrote to console different selection from what I selected...

Share this post


Link to post
Share on other sites

It did not return strings values of the array..

Share this post


Link to post
Share on other sites

Really? Other than a missing semicolon on a comment:

; Is this one checked?
Melba's demo runs perfectly for me and calls out the correct selections.

:unsure:


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

Yes, this is clear.. but I still did not found my problem..

I'll check it again and will update

Share this post


Link to post
Share on other sites

Okay.. it's working.. my mistake..

Just wish to know how can I select check box from my script? Cause I wish to make check box that will select all options

Thanks a lot for all your help! Very appreciate your help..

Share this post


Link to post
Share on other sites

all it's okay for now..

thanks you all!

Share this post


Link to post
Share on other sites

Melba's demo, plus "Select All" and "Clear All" buttons:

#include <GUIConstantsEx.au3>

Global $avArray[3] = ["Hanna", "Danny", "Moshe"]
Global $hGUI, $avCheckID[3]
Global $checkCN, $msg, $start, $i

$hGUI = GUICreate("Check boxes") ; will create a dialog box that when displayed is centered

$start = 20
For $i = 0 To 2
    $avCheckID[$i] = GUICtrlCreateCheckbox($avArray[$i], 10, $start, 120, 20)
    $start += 30
Next

$btn = GUICtrlCreateButton("Run", 120, 200, 60, 20)
$btnSel = GUICtrlCreateButton("Sel All", 120, 240, 60, 20)
$btnClr = GUICtrlCreateButton("Clr All", 120, 280, 60, 20)
GUISetState()

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $btn
            ; Loop through the checkboxes
            For $i = 0 To 2
                ; Is this one checked?
                If GUICtrlRead($avCheckID[$i]) = 1 Then
                    ; If so then say so
                    ConsoleWrite("Checkbox " & $avArray[$i] & " is checked" & @CRLF)
                EndIf
                ConsoleWrite(@CRLF)
            Next
        Case $btnSel
            _ChangeAll(1)
        Case $btnClr
            _ChangeAll(0)
    EndSwitch
WEnd

Func _ChangeAll($f_State)
    For $n = 0 To UBound($avCheckID) - 1
        If $f_State Then
            ControlCommand($hGUI, "", $avCheckID[$n], "Check")
        Else
            ControlCommand($hGUI, "", $avCheckID[$n], "Uncheck")
        EndIf
    Next
EndFunc

:unsure:


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

#13 ·  Posted (edited)

Thanks a lot!!

I wish to do clear all and select all buttons with check box

Assume: $SelAll=GUICtrlCreateCheckbox($string,200, 10, 120, 20)

So my questions is:

How can I change text of check box suitable to check box status (if V select all and if V removed so text will be remove all)-I tried

define global variable $string="Select all" and add case like this:

Case GUICtrlRead($SelAll) = 1

$string="Select all"

Case GUICtrlRead($SelAll) = 4

$string="Remove all"

but it's doesn't work-question is why..

Thanks a lot!!!

Noa :-)

Edited by autoitquestion

Share this post


Link to post
Share on other sites

autoitquestion,

Her is how you can do it with checkbox: :unsure:

#include <GUIConstantsEx.au3>

Global $avArray[3] = ["Hanna", "Danny", "Moshe"]
Global $hGUI, $avCheckID[3]
Global $checkCN, $msg, $start, $i

$hGUI = GUICreate("Check boxes") ; will create a dialog box that when displayed is centered

$start = 20
For $i = 0 To 2
    $avCheckID[$i] = GUICtrlCreateCheckbox($avArray[$i], 10, $start, 120, 20)
    $start += 30
Next

$btn = GUICtrlCreateButton("Run", 120, 200, 60, 20)

$chkSel = GUICtrlCreateCheckbox("Sel All", 120, 240, 60, 20)

GUISetState()

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $btn
            ; Loop through the checkboxes
            For $i = 0 To 2
                ; Is this one checked?
                If GUICtrlRead($avCheckID[$i]) = 1 Then
                    ; If so then say so
                    ConsoleWrite("Checkbox " & $avArray[$i] & " is checked" & @CRLF)
                EndIf
                ConsoleWrite(@CRLF)
            Next
        Case $chkSel
            Switch GUICtrlRead($chkSel)
                Case 1
                    For $i = 0 To 2
                        GUICtrlSetState($avCheckID[$i], $GUI_CHECKED)
                    Next
                Case Else
                    For $i = 0 To 2
                        GUICtrlSetState($avCheckID[$i], $GUI_UNCHECKED)
                    Next
            EndSwitch
    EndSwitch

WEnd

M23

P.S. When you post code please use Code tags. Put [autoit] before and [/autoit] after your posted code. :>


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

Thanks a lot Melba!!

And how can I change text of check box suitable to check box status (if V select all and if V removed so text will be remove all)?

I tried define global variable and change it in the suitable case, but did not know why it's did not work

#include <GUIConstantsEx.au3>

Global $avArray[3] = ["Hanna", "Danny", "Moshe"]
Global $hGUI, $avCheckID[3]
Global $checkCN, $msg, $start, $i
Local  $string="Select all"

$hGUI = GUICreate("Check boxes") ; will create a dialog box that when displayed is centered

$start = 20
For $i = 0 To 2
    $avCheckID[$i] = GUICtrlCreateCheckbox($avArray[$i], 10, $start, 120, 20)
    $start += 30
Next

$btn = GUICtrlCreateButton("Run", 120, 200, 60, 20)

$chkSel = GUICtrlCreateCheckbox($string, 120, 240, 60, 20)

GUISetState()

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $btn
            ; Loop through the checkboxes
            For $i = 0 To 2
                ; Is this one checked?
                If GUICtrlRead($avCheckID[$i]) = 1 Then
                    ; If so then say so
                    ConsoleWrite("Checkbox " & $avArray[$i] & " is checked" & @CRLF)
                EndIf
                ConsoleWrite(@CRLF)
            Next
        Case $chkSel
            Switch GUICtrlRead($chkSel)
            Case 1
                    For $i = 0 To 2
                        GUICtrlSetState($avCheckID[$i], $GUI_CHECKED)
                    Next
                    $string="Remove all"
                Case Else
                    For $i = 0 To 2
                        GUICtrlSetState($avCheckID[$i], $GUI_UNCHECKED)
                    Next
                    $string="Select all"
            EndSwitch
    EndSwitch

WEnd

Share this post


Link to post
Share on other sites

autoitquestion,

Just change the checkbox text to match the state: :unsure:

Case $chkSel
            Switch GUICtrlRead($chkSel)
                Case 1
                    For $i = 0 To 2
                        GUICtrlSetState($avCheckID[$i], $GUI_CHECKED)
                    Next
                    GUICtrlSetData($chkSel, "Remove All")
                Case Else
                    For $i = 0 To 2
                        GUICtrlSetState($avCheckID[$i], $GUI_UNCHECKED)
                    Next
                    GUICtrlSetData($chkSel, "Sel All")
            EndSwitch

But personally I feel that this is not a good idea - it is the state of the checkbox that tells you what the next action should be. :>

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

Thanks a lot Melba!! you're the best

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