Jump to content

Implementing ComboBox Controls


LarsJ
 Share

Recommended Posts

Note that it's a 7z-file. It contains 11 files and they are all text files. I'm sure they do not contain viruses or malware. So I find it strange too.

I guess it's Microsoft SmartScreen that's the problem. You can try disable SmartScreen and download again.

I cannot do anything about viruses or malware that simply does not exist in the 7z-file.

Link to comment
Share on other sites

Thank you, Mr KaFu. And also thanks to everyone else. Let me know if there are any virus issues.

Link to comment
Share on other sites

Hi Lars, The Checkbox Combo is a masterpiece again !

But would it be possible to add the SELECT ALL option on top.

This functionality would SELECT or DESELECT all checkboxes... This becomes very handy if you have a long list of multiple checkboxes.

Forgive me if the functionality is already there, because I did not yet have time to run the UDF on my machine.

Link to comment
Share on other sites

Link to comment
Share on other sites

  • 1 year later...

Hey LarsJ,

Sorry for replying to such an old post.

awesome work those Checkboxes ! But i have a question:

I wanted to start with zero checked items and the Combobox doesn't appear in my GUI then.

Is this a bug? Or did i missed something?

If not is there a way around?

2D array example:

Local $aItems = [ [ "Item0"    ], _
                      [ "Item1"    ], _
                      [ "Item2"    ], _ 
                      [ "Item3"    ], _
                      [ "Item4"    ], _ 
                      [ "Item5"    ], _
                      [ "Item6"    ], _ 
                      [ "Item7"    ], _
                      [ "Item8"    ], _
                      [ "Item9"    ] ]

 

Edited by Aelc

why do i get garbage when i buy garbage bags? <_<

Link to comment
Share on other sites

Come on. This isn't an old post.

It seems to be a bug. You can use this array as a workaround:

Local $aItems = [ [ "Item0", 0 ], _
                  [ "Item1"    ], _
                  [ "Item2"    ], _ 
                  [ "Item3"    ], _
                  [ "Item4"    ], _ 
                  [ "Item5"    ], _
                  [ "Item6"    ], _ 
                  [ "Item7"    ], _
                  [ "Item8"    ], _
                  [ "Item9"    ] ]

 

Link to comment
Share on other sites

5 minutes ago, LarsJ said:

Come on. This isn't an old post.

Yes sorry for this, but didn't want to create a new topic if it's actually the same subject>_<

 

8 minutes ago, LarsJ said:

It seems to be a bug. You can use this array as a workaround:

Local $aItems = [ [ "Item0", 0 ], _
                  [ "Item1"    ], _
                  [ "Item2"    ], _ 
                  [ "Item3"    ], _
                  [ "Item4"    ], _ 
                  [ "Item5"    ], _
                  [ "Item6"    ], _ 
                  [ "Item7"    ], _
                  [ "Item8"    ], _
                  [ "Item9"    ] ]

 

many thanks :robot:

why do i get garbage when i buy garbage bags? <_<

Link to comment
Share on other sites

  • 4 months later...
2 hours ago, dmob said:

I desire to have the combo display the number of items selected

I think you have to modify the CheckboxCombo_ComboHandler() function located in the CheckboxCombo.au3 file like this:

1) add a variable ($iTotChecked) in line 315:

Local $sText = "", $j = 0, $iTotChecked = 0

2) change line 323 from this

If $sText Then $sText = StringLeft( $sText, StringLen( $sText ) - 2 )

to this

If $sText Then
                    $sText = StringReplace(StringTrimRight($sText, 2), ',', ',')
                    $iTotChecked = @extended + 1
                EndIf

3) change line 325 from this

DllCall( "user32.dll", "int", "DrawTextW", "handle", $hDC, "wstr", $sText, "int", -1, "struct*", DllStructGetPtr( $tDIS, 8 ), "uint", $DT_SINGLELINE+$DT_VCENTER+$DT_END_ELLIPSIS ) ; _WinAPI_DrawText

to this

DllCall( "user32.dll", "int", "DrawTextW", "handle", $hDC, "wstr", String($iTotChecked), "int", -1, "struct*", DllStructGetPtr( $tDIS, 8 ), "uint", $DT_SINGLELINE+$DT_VCENTER+$DT_END_ELLIPSIS ) ; _WinAPI_DrawText

 

Edited by Chimp

 

image.jpeg.9f1a974c98e9f77d824b358729b089b0.jpeg Chimp

small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....

Link to comment
Share on other sites

Hi @dmob,

my mods refer to the files included in the zip of the post "Checkbox Combo". I have checked and it works as expected. That is, when you check/uncheck the check boxes, the combo box header shows the number of checked boxes instead of the list of checked boxes.
Did I misunderstand something about your goal?

 

 

image.jpeg.9f1a974c98e9f77d824b358729b089b0.jpeg Chimp

small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....

Link to comment
Share on other sites

1 hour ago, Chimp said:

I have checked and it works as expected.

I used same UDF from the link. I will recheck my code.

1 hour ago, Chimp said:

Did I misunderstand something about your goal?

No, however the functionally I desire is:
a) The combo is created with some items pre-checked. I would like it to display "3 Items selected" after creation.
b) When selections are made, update combo text accordingly, e.g. "4 Items selected" etc. either during selection or after combo is closed/collapsed.

Link to comment
Share on other sites

Slightly modified code and new function parameters:

; Create Checkbox Combo for multiple selections
;
; Flag values
;     0 => Display comma-delimited list of checked items in Edit control of Combo (default)
;     1 => Display number of checked items in Edit control, leading text in Edit control
;     2 => Display number of checked items in Edit control, trailing text in Edit control
;
; Error code in @error                         Return value
;     1 => Invalid item info string/array          Success => $idComboBox (Dummy control)
;     2 => Error creating ComboBox                 Failure => 0
;     3 => Too many ComboBoxes
;
Func CheckboxCombo_Create( _
  $x, $y, $w, $h, _ ; Left, top, width, height
  $iListRows, _     ; Rows in drop-down ListBox
  $vItemInfo, _     ; Item info string/array
  $iFlag = 0, _     ; Set option flag values
  $sEdit = "" )     ; Edit text if $iFlag = 1/2

CheckboxCombo.7z

Edited by LarsJ
Link to comment
Share on other sites

57 minutes ago, dmob said:

a) The combo is created with some items pre-checked. I would like it to display "3 Items selected" after creation.

b) When selections are made, update combo text accordingly, e.g. "4 Items selected" etc. either during selection or after combo is closed/collapsed.

"ubi maior minor cessat" ... :P
well, so just download the new zip from @LarsJ from the post here above and using the "CheckboxCombo, 2D array.au3" as a basic example, call the CheckboxCombo_Create()
like this:

; Create Checkbox Combo
    Local $idComboBox = CheckboxCombo_Create(10, 10, 200, 20, 10, $aItems, 1, "  Items selected")

 

Edited by Chimp

 

image.jpeg.9f1a974c98e9f77d824b358729b089b0.jpeg Chimp

small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....

Link to comment
Share on other sites

  • LarsJ changed the title to Implementing ComboBox Controls

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