MrCreatoR

GroupCheckBox - Creating group checkboxes

2 posts in this topic

#1 ·  Posted (edited)

Name: GroupCheckBox

Description: Allows to create and manage group checkboxes.

AutoIt: 3.3.6.1 - 3.3.12.0

 

Example:

Example 1.au3 from archive (there is 2 more examples)

#include <GUIConstantsEx.au3>
#include 'GroupCheckBox.au3'

Global $aCB_Data[][2] = _
    [ _
        ['CheckBox1', 'Some data for CheckBox1'], _
        ['CheckBox2', 'Some data for CheckBox2'], _
        ['CheckBox3', 'Some data for CheckBox3'], _
        ['CheckBox4', 'Some data for CheckBox4'], _
        ['CheckBox5', 'Some data for CheckBox5'] _
    ]

$hGUI = GUICreate('GroupCheckBox Example 1', 410, 200)

$hGroupCheckBox = _GroupCheckBox_Create($aCB_Data, 20, 20, -1, -1, 2, 30, 10)
$iCheckAll_CB = GUICtrlCreateCheckbox('Check All', 20, 80)
$iRemove_Bttn = GUICtrlCreateButton('Remove (1 | 3 | 5)', 20, 130, 100, 20)
$iStatus_Lbl = GUICtrlCreateLabel('', 20, 170, 270, 20)

GUICtrlSetFont(-1, 9, 600)
GUICtrlSetColor(-1, 0x0000FF)

Global $aCB_Data[][2] = _
    [ _
        ['CheckBox6', 'Some data for CheckBox6'], _
        ['CheckBox7', 'Some data for CheckBox7'], _
        ['CheckBox8', 'Some data for CheckBox8'] _
    ]

_GroupCheckBox_Add($hGroupCheckBox, $aCB_Data, -1)

GUISetState(@SW_SHOW, $hGUI)

While 1
    $iMsg = GUIGetMsg()
    
    Switch $iMsg
        Case $GUI_EVENT_CLOSE
            _GroupCheckBox_Destroy($hGroupCheckBox)
            Exit
        Case $iRemove_Bttn
            _GroupCheckBox_Remove($hGroupCheckBox, '1|3|5', True)
            GUICtrlSetState($iRemove_Bttn, $GUI_DISABLE)
        Case $iCheckAll_CB
            $iState = $GCB_CHECK_STATE_NONE
            
            If GUICtrlRead($iCheckAll_CB) = $GUI_CHECKED Then
                $iState = $GCB_CHECK_STATE_ALL
            EndIf
            
            _GroupCheckBox_SetState($hGroupCheckBox, $iState, -1)
            
            ContinueCase
        Case _GroupCheckBox_GetEvent($hGroupCheckBox, $iMsg)
            GUICtrlSetData($iStatus_Lbl, '')
            
            $iState = _GroupCheckBox_GetState($hGroupCheckBox)
            
            Switch $iState
                Case $GCB_CHECK_STATE_ONE
                    GUICtrlSetData($iStatus_Lbl, 'One (Or More) CheckBoxes Checked')
                Case $GCB_CHECK_STATE_ALL
                    GUICtrlSetState($iCheckAll_CB, $GUI_CHECKED)
                    GUICtrlSetData($iStatus_Lbl, 'All CheckBoxes Checked.')
                    
                    $iCB = Random(1, _GroupCheckBox_GetInfo($hGroupCheckBox), 1)
                    $aInfo = _GroupCheckBox_GetInfo($hGroupCheckBox, $iCB, $GCB_INDEX_ALL)
                    
                    If Not @error Then
                        MsgBox(64, 'State', _
                            StringFormat('All CheckBoxes Checked.\n\nCheckBox #%i (Random) Info:\n\nCtrlID = %i\nText = %s\nParam = %s', _
                                $iCB, $aInfo[$GCB_INDEX_CTRLID], $aInfo[$GCB_INDEX_TEXT], $aInfo[$GCB_INDEX_PARAM]), _
                            0, $hGUI)
                    EndIf
                Case $GCB_CHECK_STATE_NONE
                    GUICtrlSetState($iCheckAll_CB, $GUI_UNCHECKED)
                    GUICtrlSetData($iStatus_Lbl, 'All CheckBoxes UnChecked.')
            EndSwitch
    EndSwitch
WEnd

 

Download:  GroupCheckBox.zip

Edited by MrCreatoR

Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

AutoIt_Icon_small.pngProjects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize Program

AutoIt_Icon_small.pngUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF
 
AutoIt_Icon_small.pngExamples: 
ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo

Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

AutoIt is simple, subtle, elegant. © AutoIt Team

Share this post


Link to post
Share on other sites



Update:

 

0.2
* _GroupCheckBox_Delete renamed to _GroupCheckBox_Destroy.
* _GroupCheckBox_CheckAll renamed to _GroupCheckBox_SetState (changed parameters, check the function description for more details).
* All $GCB_STATE_* constants renamed to $GCB_CHECK_STATE_*.
* Changed return values from _GroupCheckBox_GetInfo (check the function description for more details).
+ Added optional $iCheckBox parameter to _GroupCheckBox_GetState function (check the function description for more details).
+ Added _GroupCheckBox_Add and _GroupCheckBox_Remove functions (check the functions description for more details).
+ Added new user constants: $GCB_INDEX_LEFT, $GCB_INDEX_TOP, $GCB_INDEX_WIDTH, $GCB_INDEX_HEIGHT, $GCB_INDEX_MAXROWS, $GCB_INDEX_COLSINTRVL, $GCB_INDEX_ROWSINTRVL.


Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

AutoIt_Icon_small.pngProjects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize Program

AutoIt_Icon_small.pngUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF
 
AutoIt_Icon_small.pngExamples: 
ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo

Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

AutoIt is simple, subtle, elegant. © AutoIt Team

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

  • Similar Content

    • jannikrendl
      By jannikrendl
      Hey guys,
      I would like to learn how the whole GUI stuff is working so I try to understand it step by step...
      First of all I created a GUI with a single button. My goal is to activate an infinite while loop as soon as the checkbox is checked and to deactive the infinite while loop as soon as I uncheck the checkbox, but I don't understand how... I read various threads but couldn't find a good example etc...
      Thanks in advance 
    • Terenz
      By Terenz
      Hello,
      I have searched everywhere but on the forum there isn't an example of a combobox with checkbox. I think is a very useful control but require subclassing. Several example in C++, one of this:
      CheckComboBox Control
      If somone has some time to check it out. If need i can provide the source code. Thanks
    • ur
      By ur
      I have below screen when I launch the application.

      By default the first radio button is checked.
      I want to select the second radio button as highlighted.
      And when it is selected, the textbox highlighted will be enabled and we need to enter the license details.
       
      To do that, I tried to get the control id with windo info tool , but I am getting the second section(Concurrent Licenses) completely as "Button" class with ID 12.But not that radiobutton ID.
      Even I tried with that as below.
      $hwd =WinWaitActivate("erwin Data Modeler Licensing","Acquire concurrent u") ControlCommand($hwd,"","[CLASS:Button; INSTANCE:12]","Check") But not working.
      Any suggestions please.
    • StMaSi
      By StMaSi
      So, I have a text file like this...
      "Label", {left}, {top}, {width}, {height} "Label", {left}, {top}, {width}, {height} "Label", {left}, {top}, {width}, {height} "Label", {left}, {top}, {width}, {height} "Label", {left}, {top}, {width}, {height} What I'm attempting to do is read the data from this file, into an array, and use it to create checkboxes on a form like this...
      For $cb = 0 to 4 ; line numbers $Checkbox[$cb] = GUICtrlCreateCheckbox({label}, {left}, {top}, {width}, {height}) Next However, I can't figure out how to read the file into the array so as to be able to assign the data elements appropriately. I'm obviously missing something (or more than likely more than one something), but can't figure it out.
      Can anyone assist with this?
      Thanx.
       
    • Em4gdn1m
      By Em4gdn1m
      Hey everyone, I'm curious if there is a way to incorporate a checkbox with a combo GUICtrl?
      so for instance I have a GUI that has a bunch of checkboxes that allow me to open certain programs as needed.  (this is just some parsing of my code, sorry, noob here and not sure what the preferred method of displaying code is, please enlighten me)

          $L0742 = GUICtrlCreateCheckbox("L07 4.2", 110, 320, 100)
          $L07502 = GUICtrlCreateCheckbox("L07 5.0.2", 110, 350, 100)
          $GenComm = GUICtrlCreateCheckbox("GenComm", 110, 380, 100)
          $Templates = GUICtrlCreateCheckbox("Templates", 110, 410, 100)
          $MCT = GUICtrlCreateCheckbox("MCT", 110, 440, 100)
          $Desktop_Shortcuts = GUICtrlCreateCheckbox("Desktop Shortcuts by Tester", 110, 470, 200)
       
      ...
      Case $msg = $RunBtn
                  RunPrograms()
       
      ...
      Func RunPrograms()

          if GUICtrlRead($L0742) = $GUI_CHECKED then Run("C:\Program Files\Varian\Paxscan\L07 Rel4.2\viva\viva.exe", "")
          if GUICtrlRead($L07502) = $GUI_CHECKED then Run("C:\Program Files\Varian\Paxscan\L07 Rel5\viva\viva.exe", "")
          if GUICtrlRead($GenComm) = $GUI_CHECKED then Run("\\Fpanelfs1\FPShared\Desktop_Shortcuts_by_Tester\Matt\CPI Generator\CPI Generator Windows 7 64 Bit\GenComm\GenComm.NET.exe", "")
          if GUICtrlRead($Templates) = $GUI_CHECKED then ShellExecute("\\Fpanelfs1\FPProjects\Documentation Controlled\Test_Templates")
          if GUICtrlRead($MCT) = $GUI_CHECKED then Run("\\Fpanelfs1\FPProjects\Documentation Controlled\Manufacturing Software\MCT\MCT.exe","")
          if GUICtrlRead($Desktop_Shortcuts) = $GUI_CHECKED then ShellExecute("\\Fpanelfs1\fpshared\Desktop_Shortcuts_by_Tester")
      EndFunc
       
      so i click some checkboxes, and hit a run button and the programs which are checked run, great.
      BUT i want to add a bunch of options under one checkbox. A combo that will list a bunch of versions of a program that can be opened. something like this... but I want that program to be part of a checkbox
      $ViVAComboBox = GUICtrlCreateCombo("L01 Rel 13", 110, 320, 100)
      GUICtrlSetData($ViVAComboBox, "L04|L05|L07 Rel 4.2|L07 Rel 5.0.2|L09", "L07 Rel 4.2")
       
      is this possible? is there another GUICtrl that does this better that i am not aware of?