Checking drop down toolbar menu items
-
I have a drop down menu on one of my toolbar buttons. I am having problem with checking menu items. If I use CCmdUI::SetCheck method, there is no problem, but I want to do this in a different way. Why does this code give error? int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) { if (CMDIFrameWnd::OnCreate(lpCreateStruct) == -1) return -1; ... ... menu_tb2_btn1.LoadMenu(IDR_MENU_TOOLBAR2_BUTTON1); ASSERT(menu_tb2_btn1); pPopup = menu_tb2_btn1.GetSubMenu(0); ... ... return 0; } void CMainFrame::OnTb2btn1Item1() { // TODO: Add your command handler code here ... ... pPopup->CheckMenuRadioItem(0,3,1,MF_BYPOSITION); ... ... }
-
I have a drop down menu on one of my toolbar buttons. I am having problem with checking menu items. If I use CCmdUI::SetCheck method, there is no problem, but I want to do this in a different way. Why does this code give error? int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) { if (CMDIFrameWnd::OnCreate(lpCreateStruct) == -1) return -1; ... ... menu_tb2_btn1.LoadMenu(IDR_MENU_TOOLBAR2_BUTTON1); ASSERT(menu_tb2_btn1); pPopup = menu_tb2_btn1.GetSubMenu(0); ... ... return 0; } void CMainFrame::OnTb2btn1Item1() { // TODO: Add your command handler code here ... ... pPopup->CheckMenuRadioItem(0,3,1,MF_BYPOSITION); ... ... }
Kapgan wrote: Why does this code give error? Exactly what error does it give? Is it a compiler error? A linker error? A run-time error? If the latter, what steps are you taking that leads up to this point?
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
-
Kapgan wrote: Why does this code give error? Exactly what error does it give? Is it a compiler error? A linker error? A run-time error? If the latter, what steps are you taking that leads up to this point?
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
-
It's a run-time error. It says debug assertion failure. I defined a pPopup named object and tried to make it hold the drop down menu, so that I can easily have access to other functions. But unfortunately I couldn't do this.
Kapgan wrote: It says debug assertion failure. Which line of which file?
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
-
Kapgan wrote: It says debug assertion failure. Which line of which file?
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
-
As the assertion is related to a
CString
object, the code snippet you've provided is of no help. You'll need to locate theCString
object in question. Given thatm_pchData
is in error, my first guess is that it is a heap-based object.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow