|
-
July 27th, 2010, 02:04 PM
#1
On menu item again
I am stuck at how to access the menu item
My menu has 5 items, the first one will have 5 subitems, and I am unable to access the subitems
CMenu* submenu=menu.GetSubMenu(0);
ASSERT(submenu->GetSafeHMenu()); // This line throws exception
-
July 27th, 2010, 04:43 PM
#2
Re: On menu item again
- What exception?
- Where is this code called from?
- If your CMenu class is a MFC one, then you should probably have posted this question in the Visual C++ Programming Forum
Victor Nijegorodov
-
July 27th, 2010, 04:53 PM
#3
Re: On menu item again
somebody please help me
here is the code
Code:
CString OnGetClick()
{
CMenu* submenu=menu.GetSubMenu(0);
ASSERT(submenu);
ASSERT(::ismenu(submenu->GetSafeHMenu()); // This line throws exception
CString str;
submenu->GetMenuString(1,str,NF_BYPOSITION);
return str;
}
-
July 27th, 2010, 04:56 PM
#4
Re: On menu item again
 Originally Posted by VictorN
- What exception?
- Where is this code called from?
- If your CMenu class is a MFC one, then you should probably have posted this question in the Visual C++ Programming Forum
1.2.The value in submenu looks valid, something like 0x0182981 but I don't know why the second assert validate its handle to false
3. Yes, but I posted it here I can't move it there to repeat the post
-
July 28th, 2010, 01:16 AM
#5
Re: On menu item again
 Originally Posted by Turingmachine
Code:
CString OnGetClick()
{
CMenu* submenu=menu.GetSubMenu(0);
ASSERT(submenu);
ASSERT(::ismenu(submenu->GetSafeHMenu()); // This line throws exception
CString str;
submenu->GetMenuString(1,str,NF_BYPOSITION);
return str;
}
1. What is this ismenu function? 
2. Where is this code called from?
Victor Nijegorodov
-
July 28th, 2010, 02:49 AM
#6
Re: On menu item again
1.It is IsMenu Api function
2.that code is actually from a on-command-range message map function
Code:
void OnPickItem(UINT nItem)
{
CMenu* submenu=menu.GetSubMenu(0);
ASSERT(submenu);
ASSERT(::IsMenu(submenu->GetSafeHMenu()); // This line throws exception
submenu->CheckMenuRadioItem(ID_APP1, ID_APP7, nItem, MF_BYCOMMAND);
}
-
July 28th, 2010, 02:57 AM
#7
Re: On menu item again
 Originally Posted by Turingmachine
1.It is IsMenu Api function
2.that code is actually from a on-command-range message map function
1. What command and what range?
2. Can't you debug?
3. You'll never get any useful help unless you provide a useful info about your problem.
Victor Nijegorodov
-
July 28th, 2010, 03:12 AM
#8
-
July 28th, 2010, 03:13 AM
#9
Re: On menu item again
I just redo an old program for fun,
I have a dialog, that when rightclicking on it will show me a popup menu, which includes
File
..Click File 1
..Click File 2
..Click File 3
..Click File 4
..Click File 5
Exit
Each of the |Click File i" Is defined as ID_APP1,....ID_APP5
in the message map, there I define
ON_COMMAND-RANGE(ID_APP1, ID_APP5, &Func)
and there I use the above function but when I run the application, I got an assertion failure right at that line during the debugging,
That isn't a valid menu handle while the previous line passes the ASSERT.
-
July 28th, 2010, 03:24 AM
#10
Re: On menu item again
Please help me till the end, I don't want to stop it right now, very urgent help SMS SMS SMS
-
July 28th, 2010, 03:29 AM
#11
-
July 28th, 2010, 03:35 AM
#12
Re: On menu item again
Exception only shows up after I pick one of those "Click File i", this means menu is valid
If I eliminate that OnPickItem from the program, things are fine
-
July 28th, 2010, 03:43 AM
#13
Re: On menu item again
 Originally Posted by Turingmachine
 Originally Posted by VictorN
... You again ignored to supply enough info. 
What is this "menu" object? Where is it come from? How could we know it was correctly loaded/created? 
Exception only shows up after I pick one of those "Click File i", this means menu is valid
If I eliminate that OnPickItem from the program, things are fine
So, you are still avoiding to answer my questions to make your problem clear...
OK!
I'll give up
and
Good luck.
Victor Nijegorodov
-
July 28th, 2010, 09:31 AM
#14
Re: On menu item again
TuringMachine. I have to tell you it's frustrating for the 'regular' folks here that do most of the answering, that when they ask direct questions the original poster doesn't answer them.
It would make it much easier for us to help you, if you answered the questions that are asked. Sometimes, the questions make not seem to be related, but the person trying to help usually asks them to help narrow down the problem.
Also, when ask to post the code - post the code. Giving a description of what you think the code is isn't going to help us (help you). We want to see the actual code.
At any rate, why do you need to get the submenu? You generally should be able to do what you need with OnCommandRange or OnUpdateCommandUI.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|