Results 1 to 18 of 18

Thread: [RESOLVED] Semi-Checked status on checkboxes. How to use?

Hybrid View

  1. #1

    Thread Starter
    PowerPoster cafeenman's Avatar
    Join Date
    Mar 2002
    Location
    Florida
    Posts
    2,819

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

  2. #2
    PowerPoster Zvoni's Avatar
    Join Date
    Sep 2012
    Location
    To the moon and then left
    Posts
    5,268

    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
    Last edited by Zvoni; Dec 18th, 2024 at 07:27 AM.
    Last edited by Zvoni; Tomorrow at 31:69 PM.
    ----------------------------------------------------------------------------------------

    One System to rule them all, One Code to find them,
    One IDE to bring them all, and to the Framework bind them,
    in the Land of Redmond, where the Windows lie
    ---------------------------------------------------------------------------------
    People call me crazy because i'm jumping out of perfectly fine airplanes.
    ---------------------------------------------------------------------------------
    Code is like a joke: If you have to explain it, it's bad

  3. #3
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    10,915

    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.
    Any software I post in these forums written by me is provided "AS IS" without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. To all, peace and happiness.

  4. #4

    Thread Starter
    PowerPoster cafeenman's Avatar
    Join Date
    Mar 2002
    Location
    Florida
    Posts
    2,819

    Re: Semi-Checked status on checkboxes. How to use?

    Quote Originally Posted by Elroy View Post
    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.

  5. #5
    PowerPoster Zvoni's Avatar
    Join Date
    Sep 2012
    Location
    To the moon and then left
    Posts
    5,268

    Re: Semi-Checked status on checkboxes. How to use?

    Quote Originally Posted by cafeenman View Post
    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
    Last edited by Zvoni; Tomorrow at 31:69 PM.
    ----------------------------------------------------------------------------------------

    One System to rule them all, One Code to find them,
    One IDE to bring them all, and to the Framework bind them,
    in the Land of Redmond, where the Windows lie
    ---------------------------------------------------------------------------------
    People call me crazy because i'm jumping out of perfectly fine airplanes.
    ---------------------------------------------------------------------------------
    Code is like a joke: If you have to explain it, it's bad

  6. #6
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    10,915

    Re: Semi-Checked status on checkboxes. How to use?

    Quote Originally Posted by cafeenman View Post
    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.
    Any software I post in these forums written by me is provided "AS IS" without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. To all, peace and happiness.

  7. #7
    PowerPoster
    Join Date
    Feb 2017
    Posts
    5,700

    Re: Semi-Checked status on checkboxes. How to use?

    Quote Originally Posted by cafeenman View Post
    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).

  8. #8
    PowerPoster Zvoni's Avatar
    Join Date
    Sep 2012
    Location
    To the moon and then left
    Posts
    5,268

    Re: Semi-Checked status on checkboxes. How to use?

    Quote Originally Posted by Eduardo- View Post
    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
    .............
    Last edited by Zvoni; Tomorrow at 31:69 PM.
    ----------------------------------------------------------------------------------------

    One System to rule them all, One Code to find them,
    One IDE to bring them all, and to the Framework bind them,
    in the Land of Redmond, where the Windows lie
    ---------------------------------------------------------------------------------
    People call me crazy because i'm jumping out of perfectly fine airplanes.
    ---------------------------------------------------------------------------------
    Code is like a joke: If you have to explain it, it's bad

  9. #9
    PowerPoster Zvoni's Avatar
    Join Date
    Sep 2012
    Location
    To the moon and then left
    Posts
    5,268

    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
    Last edited by Zvoni; Tomorrow at 31:69 PM.
    ----------------------------------------------------------------------------------------

    One System to rule them all, One Code to find them,
    One IDE to bring them all, and to the Framework bind them,
    in the Land of Redmond, where the Windows lie
    ---------------------------------------------------------------------------------
    People call me crazy because i'm jumping out of perfectly fine airplanes.
    ---------------------------------------------------------------------------------
    Code is like a joke: If you have to explain it, it's bad

  10. #10

    Thread Starter
    PowerPoster cafeenman's Avatar
    Join Date
    Mar 2002
    Location
    Florida
    Posts
    2,819

    Re: Semi-Checked status on checkboxes. How to use?

    That's exactly how it works for the VB6 installer.

  11. #11
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    10,915

    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).
    Any software I post in these forums written by me is provided "AS IS" without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. To all, peace and happiness.

  12. #12
    PowerPoster
    Join Date
    Feb 2017
    Posts
    5,700

    Re: Semi-Checked status on checkboxes. How to use?

    "Can be done" but not without additional code (that was my point).

  13. #13
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    10,915

    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.
    Any software I post in these forums written by me is provided "AS IS" without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. To all, peace and happiness.

  14. #14
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    10,915

    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.
    Last edited by Elroy; Dec 18th, 2024 at 01:19 PM.
    Any software I post in these forums written by me is provided "AS IS" without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. To all, peace and happiness.

  15. #15
    PowerPoster Zvoni's Avatar
    Join Date
    Sep 2012
    Location
    To the moon and then left
    Posts
    5,268

    Re: Semi-Checked status on checkboxes. How to use?

    Quote Originally Posted by Elroy View Post
    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

    Sets the check state of a radio button or check box.
    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.
    Last edited by Zvoni; Tomorrow at 31:69 PM.
    ----------------------------------------------------------------------------------------

    One System to rule them all, One Code to find them,
    One IDE to bring them all, and to the Framework bind them,
    in the Land of Redmond, where the Windows lie
    ---------------------------------------------------------------------------------
    People call me crazy because i'm jumping out of perfectly fine airplanes.
    ---------------------------------------------------------------------------------
    Code is like a joke: If you have to explain it, it's bad

  16. #16
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    10,915

    Re: Semi-Checked status on checkboxes. How to use?

    Quote Originally Posted by Zvoni View Post
    Probably a SendMessage with BST_INDETERMINATE
    https://learn.microsoft.com/en-us/wi...ectedfrom=MSDN
    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".
    Any software I post in these forums written by me is provided "AS IS" without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. To all, peace and happiness.

  17. #17
    PowerPoster Zvoni's Avatar
    Join Date
    Sep 2012
    Location
    To the moon and then left
    Posts
    5,268

    Re: Semi-Checked status on checkboxes. How to use?

    Quote Originally Posted by Elroy View Post
    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)
    Last edited by Zvoni; Tomorrow at 31:69 PM.
    ----------------------------------------------------------------------------------------

    One System to rule them all, One Code to find them,
    One IDE to bring them all, and to the Framework bind them,
    in the Land of Redmond, where the Windows lie
    ---------------------------------------------------------------------------------
    People call me crazy because i'm jumping out of perfectly fine airplanes.
    ---------------------------------------------------------------------------------
    Code is like a joke: If you have to explain it, it's bad

  18. #18
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    10,915

    Re: Semi-Checked status on checkboxes. How to use?

    Quote Originally Posted by Zvoni View Post
    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.
    Any software I post in these forums written by me is provided "AS IS" without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. To all, peace and happiness.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width