Announcement

Collapse
No announcement yet.

How to programmatically display a pressed toolbar button

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Gary Beene
    replied
    Dominic,

    And of course, now that you point out the answer, I can find examples of it in the forum - now that I know what to look for.

    And as to how would I know the answer - I can see now that it was a mind set problem with me. I was expecting a single style value solution to the problem.

    But since I've been using OR'd style values on dialogs and controls, I shouldn't have had such a limited expectation on button styles - no less that I expect them with dialogs and controls.

    Thanks again for the help,

    Leave a comment:


  • Gary Beene
    replied
    Dominic!

    Works like a charm.

    So, how would I have known this? Nothing I saw in Help or at MSDN spoke of the solution you provided.

    I would have expected a %TBState_UnChecked - but no, instead there was this not-obvious-to-me solution.

    And for that matter, I was surprised not to find it in the forums. I'd have thought it was a very common need.

    Thanks!

    Leave a comment:


  • Dominic Mitchell
    replied
    Actually,

    to check
    Code:
     SendMessage GetDlgItem(hWndParent, %IDC_FORM1_TOOLBAR1), %TB_SETSTATE, %IDM_BUTTON1, %TBSTATE_ENABLED OR %TBSTATE_CHECKED
    and to uncheck
    Code:
    SendMessage GetDlgItem(hWndParent, %IDC_FORM1_TOOLBAR1), %TB_SETSTATE, %IDM_BUTTON1, %TBSTATE_ENABLED

    Leave a comment:


  • Michael Mattias
    replied
    Oh, I don't know, but NOT (%TBSTATE_CHECKED) comes to mind.....

    (don't forget it's bitwise)

    Leave a comment:


  • How to programmatically display a pressed toolbar button

    I want to show a toolbar button as pressed.

    I defined the button:
    Code:
    Toolbar Add Button  hdlg, %ID_Toolbar, 5, %ID_Btn, %TbStyle_Check, "Push"
    The basic code to press/not press the button would be like this:
    Code:
    If pushbutton& Then
       Toolbar Set State hDlg, %ID_Toolbar, ByCmd %ID_Btn, %TBState_Checked
    Else
       Toolbar Set State hDlg, %ID_Toolbar, ByCmd %ID_Btn, %TBState_Enabled
    End If
    Except that with a style of %TBSStyle_Check ...

    %TBSTYLE_CHECK
    The button is dual-state which toggles between the pressed and non-pressed state each time it's clicked.
    It's not obvious what the two opposing state equates would be. Help says the options are as follows. I assume one state would be %TBState_Checked. But what is the equate for the opposite state?

    %TBSTATE_DISABLED
    The button is disabled and grayed. (value=0)

    %TBSTATE_CHECKED
    The button is checked.

    %TBSTATE_PRESSED
    The button is pressed.

    %TBSTATE_ENABLED
    The button is enabled.

    %TBSTATE_HIDDEN
    The button is hidden.

    %TBSTATE_INDETERMINATE
    The button is indeterminate and grayed.

    %TBSTATE_MARKED
    The button is highlighted.
    It seems like such a trivial thing to ask ... it feels like I'm missing something very obvious.
Working...
X