CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Dec 2005
    Posts
    445

    [RESOLVED] Disable the select button in CMFCToolBar

    Hi all,

    I have a CMFCToolBar with 2 buttons and I want to disable all the buttons if any of them been clicked

    I added the following message map:
    ON_COMMAND(ID_TOOLBAR_MY_BUTTON1, CMyView::OnButtonClicked1)
    ON_COMMAND(ID_TOOLBAR_MY_BUTTON2, CMyView::OnButtonClicked2)

    And in the message handler I'm doing the following:

    m_wndToolBar.SetButtonStyle(m_wndToolBar.CommandToIndex(ID_TOOLBAR_MY_BUTTON1), TBBS_DISABLED);

    m_wndToolBar.SetButtonStyle(m_wndToolBar.CommandToIndex(ID_TOOLBAR_MY_BUTTON2), TBBS_DISABLED);

    Both buttons gets greyed out as required but the one I've clicked on gets enable again when the function returns (the second button remains disabled).

    It's almost like the button remembers it's state before the click and no matter what I'll do in the message handler the state before the click will be resotored.

    (When I look at the CMFCToolBarButton::m_nStyle value after it's been disabled I can see that it is set to 0x0000000)

    Any ideas???

  2. #2
    GCDEF is offline Elite Member Power Poster
    Join Date
    Nov 2003
    Location
    Florida
    Posts
    12,635

    Re: Disable the select button in CMFCToolBar

    You're probably better off using the CCmdUI OnUpdate mechanism.

  3. #3
    Join Date
    Dec 2005
    Posts
    445

    Thumbs up Re: Disable the select button in CMFCToolBar

    Perfect! Thank you!!

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

Featured