Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17



Posted on 2010-11-12
Medium Priority
Last Modified: 2012-05-10
Previously in MFC I've managed to use the ON_UPDATE_COMMAND_UI handler to set the state of check boxes and buttons on application menu bars and let ON_COMMAND set the new state.

I'm now using a ribbon bar with a CBCGPRibbonSlider on it. The position of the slider maintained by ON_UPDATE.. and a change to the position from the ON_COMMAND handler.

THE PROBLEM is in the ON_COMMAND handler I use pCtrl->GetPos(); only to find that the ON_UPDATE_COMMAND_UI has already set it back to the previous position.

I could ignore the GetPos value but have no other CBCGPRibbonSlider method to know its new position.

Am I going about the UPDATE + COMMAND interface the wrong way or should the CBCGPRibbonSlider return the position better?

void CMainFrame::OnMapDDIDetails()
	int iDDIViewDetails = -1;
	CBCGPRibbonSlider* pCtrl  = (CBCGPRibbonSlider*)m_wndRibbonBar.FindByID(IDC_MAP_DDI_DETAILS, FALSE);
		iDDIViewDetails = pCtrl->GetPos();
void CMainFrame::OnUpdateMapDDIDetails(CCmdUI* pCmdUI)
	int iDDIViewDetails = -1;
	CBCGPRibbonSlider* pCtrl  = (CBCGPRibbonSlider*)m_wndRibbonBar.FindByID(IDC_MAP_DDI_DETAILS, FALSE);
		iDDIViewDetails = GetDetailState();

Open in new window

Question by:itdeptneci
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
LVL 31

Accepted Solution

Zoppo earned 2000 total points
ID: 34119674
Hi itdeptneci,

the only way to avoid this is to simply not set the control's position within the ON_UPDATE_COMMAND_UI handler. The ON_UPDATE_COMMAND_UI handler is used to implement the visible state of a GUI element's, it's not intended to be used to update data which might be associated with that control. And IMO this is really senseful, since if one uses a ON_COMMAND_UPDATE_UI handler to change any data may initiate another ON_UPDATE_COMMAND_UI.

So, I would suggest you add a 'int' member to your applications document - in 'OnMapDDIDetails' you can retrieve its value as you now do for 'iDDIViewDetails'. In 'OnUpdateMapDDIDetails' just handle visibility/disabled-state of the control. Add a 'OnActivateView' handler and use the 'SetPos' there as you before did in 'OnUpdateMapDDIDetails'.

Hope that helps,

LVL 40

Expert Comment

ID: 34824134
This question has been classified as abandoned and is being closed as part of the Cleanup Program. See my comment at the end of the question for more details.

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Errors will happen. It is a fact of life for the programmer. How and when errors are detected have a great impact on quality and cost of a product. It is better to detect errors at compile time, when possible and practical. Errors that make their wa…
Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
Suggested Courses

661 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question