Jump to content

GroupCheckBox - Creating group checkboxes


MrCreatoR
 Share

Recommended Posts

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

 

Spoiler

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

Spoiler

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

Link to comment
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.

 

Spoiler

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

Spoiler

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

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

×
×
  • Create New...