[RESOLVED] Semi-Checked status on checkboxes. How to use?
I don't need this "for First Graders".
I know what the status is supposed to represent, how to read it and how to set it.
The question is how to put an undecided status into a specific action or inaction in my code.
I have no idea what I would ever use that status for because after I read the checkbox and know what the status is, if it's not checked or unchecked, I have no idea what to do with it.
Because I don't know what to do with it, this is probably a terrible example.
Say you have some db front-end that has lots and lots of auxiliary tables.
You could go with longer start-ups and more memory usage by reading them all in at start-up.
Or you could choose to load them on demand.
And the user selected "undecided" on the checkbox.
So what do you do with that?
If you can educate me with some pseudo-code, I'd really appreciate it. I feel like I'm missing out on something here.
Re: Semi-Checked status on checkboxes. How to use?
IMO, there is only one Usecase for those "TriState"-CheckBoxes (TriState = Checked, Unchecked, PartialCheck):
If you want to implement a quick Check/Uncheck of multiple OTHER options
The most "famous" one being the AutoFilter in Excel.
Imagine your MasterCheckbox being on top of a Form, followed by a List of 10 Checkboxes below, which you use to switch on/off different options.
Now you check your MasterCheckbox, and all following 10 Checkboxes get set to "Checked".
Uncheck your MasterCheckbox, and all following 10 Checkboxes get unchecked.
Now check any single Checkbox of those 10, and your MasterCheckBox gets set to "PartialCheck" to indicate "Well, yeah, SOME Options have been checked but not all"
Bottom line: The only action IMO to execute from such a "partial" Check is to set/indicate OTHER Checkboxes/Options/Whatever, never any "direct" action
Re: Semi-Checked status on checkboxes. How to use?
Personally, I've never used the "partially checked". But the one place I remember them being used with good use is the VB6 IDE installer, where you select the options to install. A partially-checked checkbox indicates that there are several sub-options to consider and that only some of those are checked.
Re: Semi-Checked status on checkboxes. How to use?
One scenario it might be useful is something like a "Default setting" of options, or "last saved/used options-pattern"
Say, you have such a "MasterCheckBox", and with actively setting it to this "partial" state, you can set 64 of 100 config-Options to Default "True", without having to set each single option by yourself.
Or if you have the last used options saved somewhere, you can set your "Preferences" with one click
Re: Semi-Checked status on checkboxes. How to use?
Quote:
Originally Posted by
Elroy
Personally, I've never used the "partially checked". But the one place I remember them being used with good use is the VB6 IDE installer, where you select the options to install. A partially-checked checkbox indicates that there are several sub-options to consider and that only some of those are checked.
That's actually an excellent example. So use it to inform the user but not to actually do anything in your program.
Re: Semi-Checked status on checkboxes. How to use?
Quote:
Originally Posted by
cafeenman
That's actually an excellent example. So use it to inform the user but not to actually do anything in your program.
Yes and no. See my Post #4 above for a potential usecase
Re: Semi-Checked status on checkboxes. How to use?
Quote:
Originally Posted by
cafeenman
That's actually an excellent example. So use it to inform the user but not to actually do anything in your program.
Actually, in some installation scenarios, if you click that checkbox, it selects (or de-selects) all the sub-options. But then, if you somehow call up those sub-options and partially select them, then the "master" checkbox goes back to "grayed".
I forget if that's how the VB6 IDE installer works or not.
Re: Semi-Checked status on checkboxes. How to use?
That's exactly how it works for the VB6 installer.
Re: Semi-Checked status on checkboxes. How to use?
Just to say it out loud, if that grayed check were used for anything other than indicating a "partially checked" situation, I think that would be confusing and a mistake.
If they has a "grayed unchecked" option, it could be used to indicate "checked" or "unchecked" but not subject to user control, basically indicating that some other condition caused it to be checked or unchecked. But, that's tilting at windmills (unless we build a custom UC with our own images).
Re: Semi-Checked status on checkboxes. How to use?
Quote:
Originally Posted by
cafeenman
So use it to inform the user but not to actually do anything in your program.
Yes, it is to inform, because the user can't actually make a checkbox grayed by simple clicking.
(I never used it myself).
Re: Semi-Checked status on checkboxes. How to use?
Quote:
Originally Posted by
Eduardo-
Yes, it is to inform, because the user can't actually make a checkbox grayed by simple clicking.
(I never used it myself).
Actually, it can be done.
for the "normal" check/uncheck a single-click is enough.
Now there is a Double-Click "free" to use.....
It certainly works if you implement in code a "loop" through all 3 states with each click.
Original state = unchecked
First Click = checked
second click = half checked
third click = unchecked
fourth click = checked
.............
Re: Semi-Checked status on checkboxes. How to use?
"Can be done" but not without additional code (that was my point).
Re: Semi-Checked status on checkboxes. How to use?
It's not completely trivial to do, especially if we wish to honor the design-time setting:
Code:
Option Explicit
Private miCheck1Value As Long
Private Sub Form_Load()
miCheck1Value = Me.Check1.Value
End Sub
Private Sub Check1_Click()
Static b As Boolean
If b Then Exit Sub
b = True
miCheck1Value = (miCheck1Value + 2) Mod 3 ' Change the +2 to +1 to make it cycle grayed last.
Me.Check1.Value = miCheck1Value
b = False
End Sub
Just a Form1 with a single Check1 checkbox.
Re: Semi-Checked status on checkboxes. How to use?
I also searched for an API call setting (tristate), and there doesn't seem to be one.
It might be possible with some subclassing (or a create window hook), but I'm not motivated enough to test that.
Re: Semi-Checked status on checkboxes. How to use?
Quote:
Originally Posted by
Elroy
I also searched for an API call setting (tristate), and there doesn't seem to be one.
It might be possible with some subclassing (or a create window hook), but I'm not motivated enough to test that.
Probably a SendMessage with BST_INDETERMINATE
https://learn.microsoft.com/en-us/wi...ectedfrom=MSDN
Quote:
Sets the check state of a radio button or check box.
Quote:
Sets the button state to grayed, indicating an indeterminate state. Use this value only if the button has the
BS_3STATE or
BS_AUTO3STATE style.
Re: Semi-Checked status on checkboxes. How to use?
Quote:
Originally Posted by
Zvoni
That's just the same as Check1.Value = vbGrayed. No need for API call to do that.
And the only way to set the BS_AUTO3STATE is to "catch" the checkbox when it's being created, which would require some kind of API "hook".
Re: Semi-Checked status on checkboxes. How to use?
Quote:
Originally Posted by
Elroy
That's just the same as Check1.Value = vbGrayed. No need for API call to do that.
And the only way to set the BS_AUTO3STATE is to "catch" the checkbox when it's being created, which would require some kind of API "hook".
Huh?
I thought with SetWindowLong one can "change" the style of any "already" created Window (and a Checkbox is a Window)
Re: Semi-Checked status on checkboxes. How to use?
Quote:
Originally Posted by
Zvoni
Huh?
I thought with SetWindowLong one can "change" the style of any "already" created Window (and a Checkbox is a Window)
You can only change some (not all) of the styles after creation of a window. And I'm almost certain that BS_AUTO3STATE is one of those that can't be changed.
However, you're certainly welcome to try and change it. :)