Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Toolbar button & Menu Item Link

Status
Not open for further replies.

JillyT

Programmer
Jul 11, 2002
23
CA
I cannot figure out why my menu items are getting updated but my toolbar buttons are not. There are 4 items in each area and I triple checked that matching items have the same ID string and therefore same resource number. This is the code in my message map for my CScrollView-based class:

ON_COMMAND_RANGE(ID_VIEW50, ID_VIEW150, OnViewScale)
ON_UPDATE_COMMAND_UI_RANGE(ID_VIEW50, ID_VIEW150, OnUpdateViewScale)

This is the actual code of the functions:

void CInvoices2View::OnUpdateViewScale(CCmdUI* pCmdUI)
{
pCmdUI->SetCheck(pCmdUI->m_nID == m_iHowScale);
}

//////////////////
// Handle zoom command.
//
void CInvoices2View::OnViewScale(UINT nID)
{
if (m_iHowScale != nID) {
m_iHowScale = nID;
ScrollToPosition(CPoint(0,0));
OnInitialUpdate();
}

}

The toolbar buttons and menu items actually work but when I click on an item in either location it will be checked in the menu item (with the other items unchecked)...with the toolbar buttons, it will either be pressed or unpressed based on its current state and nothing else, which leads to multiple buttons appearing pressed at once when only one zoom level can appear pressed. For more information, please ask...hoping this is enough information
 
Just to add to that...it would appear that my ON_COMMAND_RANGE is being activated but my ON_UPDATE_COMMAND_UI_RANGE is only activated upon startup for the toolbar or when I open the menu containing the menu items...which is even more puzzling because as I mentioned before, the menu items are always updated properly.
 
I think it has something to do with the fact that I am calling on the SDI from a dialog box button...cause the code works fine for an SDI only app.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top