Jump to content
LarsJ

Implementing ComboBoxes

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.

Share this post


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


Share this post


Link to post
Share on other sites

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? <_<

Share this post


Link to post
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"    ] ]

 

Share this post


Link to post
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? <_<

Share this post


Link to post
Share on other sites

I tried to hack your code and failed miserably :sweating:

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

other than the default comma-delimited list of selected items.

How can I achieve this?

 

Share this post


Link to post
Share on other sites
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

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

Share this post


Link to post
Share on other sites

Thank you @Chimp, I will try that.

Edit: Sadly the changes did not work, still exhibits default behavior.

Edited by dmob

Share this post


Link to post
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?

 


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

Share this post


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

Share this post


Link to post
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

Share this post


Link to post
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

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

Share this post


Link to post
Share on other sites
1 hour ago, LarsJ said:

Slightly modified code and new function parameters:

Yebo! :hyper::dance:Thank you so much @LarsJ. Most of your code zips right over my head :think: but your UDFs bring magic :sorcerer:

Thank you @Chimp for taking the time :thumbsup:

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

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...