Print Page | Close Window

Enable/Disable buttons in CXTPToolBar

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Toolkit Pro
Forum Description: Topics Related to Codejock Toolkit Pro
URL: http://forum.codejock.com/forum_posts.asp?TID=18093
Printed Date: 09 May 2024 at 12:01pm
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: Enable/Disable buttons in CXTPToolBar
Posted By: zeiga
Subject: Enable/Disable buttons in CXTPToolBar
Date 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.




Replies:
Posted By: Oleg
Date 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


Posted By: zeiga
Date Posted: 22 March 2011 at 6:31pm
It works, thanks a lot. 



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net