Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Toolkit Pro
  New Posts New Posts RSS Feed - Enable/Disable buttons in CXTPToolBar
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Enable/Disable buttons in CXTPToolBar

 Post Reply Post Reply
Author
Message
zeiga View Drop Down
Newbie
Newbie


Joined: 21 March 2011
Location: United States
Status: Offline
Points: 7
Post Options Post Options   Thanks (0) Thanks(0)   Quote zeiga Quote  Post ReplyReply Direct Link To This Post Topic: Enable/Disable buttons in CXTPToolBar
    Posted: 21 March 2011 at 5:55pm
I created a CXTPToolBar with several buttons. One of the buttons is "Action", and its handler is OnAction(). Here is my problem: After OnAction() is executed, all the buttons on the toolbar seem to be reset and enabled!

A self-written method RefreshToolBarButtons() is called at the end of OnAction() function to update the enable/disable status of all the buttons. (Yes, for some reason, I didn't use ON_UPDATE_COMMAND_UI handler.) I expect all the buttons should be disabled after calling RefreshToolBarButtons() because the visual studio debugger stepped through the following:
{....
CXTPControl* pButtonAction = pToolBar->GetControls()->FindControl(xtpControlButton, ID_ACTION, TRUE, FALSE);
CXTPControl* pButtonAnotherAction = pToolBar->GetControls()->FindControl(xtpControlButton, ID_ANOTHER_ACTION, TRUE, FALSE);
pButtonAction->SetEnabled(FALSE);
pButtonAnother->SetEnabled(FALSE);
....
}

Note:
I tried several ways, but it still does not work.
  1. Added pCommandBars->GetCommandBarsOptions()->bDisableCommandIfNoHandler = TRUE;
  2. call pToolBar->UpdateWindow(); after calling SetEnabled(FALSE).
Any suggestions are appreciated.

Back to Top
Oleg View Drop Down
Admin Group
Admin Group


Joined: 21 May 2003
Location: United States
Status: Offline
Points: 11234
Post Options Post Options   Thanks (0) Thanks(0)   Quote Oleg Quote  Post ReplyReply Direct Link To This Post Posted: 22 March 2011 at 1:16am
If you don't use handler you must set special flag to ignore it:

pControl->SetFlags(xtpFlagManualUpdate);
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS
Back to Top
zeiga View Drop Down
Newbie
Newbie


Joined: 21 March 2011
Location: United States
Status: Offline
Points: 7
Post Options Post Options   Thanks (0) Thanks(0)   Quote zeiga Quote  Post ReplyReply Direct Link To This Post Posted: 22 March 2011 at 6:31pm
It works, thanks a lot. 
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.156 seconds.