 |
|
 |
I don't want to add and delete submenu item only I want to change Submenu's caption. is it possible?
How can I change a submenus caption at runtime ?
|
|
|
|
 |
|
 |
When a menu is empty. Say a plugin directory that starts with nothing and fills in the menu with data. I get a fail. I also cannot seem to properly add a submenu item to a menu when I use more than one submenu. It only adds to the last submenu. I may rewrite a little of the code to fix this if it comes up. Other than that I like.
Darroll
Not one person lives in the present. Only the past. I can prove it.
|
|
|
|
 |
|
 |
Open the .h file and replace CMainFrame with CDialog, repeat in the .cpp file. That's it. But I am sure you figured that out already.
Darroll
Not one person lives in the present. Only the past. I can prove it.
|
|
|
|
 |
|
 |
What if i wanted to let the user add up to 1000 new menu items... I would have to create 1000 resource IDs for each menu item. Is there anyway around this? (ie dynamically creating resource IDs?)
Thanks,
Che
menge00@yahoo.com
|
|
|
|
 |
|
 |
All a Resource ID is a UINT, what ou can do is set a very high number to be your start of resources. I use 500000. I then use the OnCommand() function overload to check if the wParam is == to the resourceID I assigned to a dll that passed my check. I hope this wasn't confusing.
Darroll
Not one person lives in the present. Only the past. I can prove it.
|
|
|
|
 |
|
 |
Hi,
If i want to add more menus to my application such as FILE, EDIT, SETUP, MEASURE 1, MEASURE 2, MEASURE 3, VIEW, CLIP, help....
then under the FILE, i want open image, save image, save as...etc. under the EDIT, i want copy, cut, paste...etc.. and so on. how can i do this? Can you pls help? thanks a million...
|
|
|
|
 |
|
 |
Hi,
If i want to add more menus to my application such as FILE, EDIT, SETUP, MEASURE 1, MEASURE 2, MEASURE 3, VIEW, CLIP, help....
then under the FILE, i want open image, save image, save as...etc. under the EDIT, i want copy, cut, paste...etc.. and so on. how can i do this? Can you pls help? thanks a million...
|
|
|
|
 |
|
 |
what's function AddSubMenu, AddSubmenuItem?
MFC doesn't include thats function.
|
|
|
|
 |
|
 |
This works only if that item already had 1 submenu and you are adding an extra item in there. But I want to create the whole submenu. How can I do that?
I have FILE EDIT VIEW on the top level
Under VIEW I have A B C
(none of which have any submenu items). I want to add a submenu to A which drops down as 1 2 3 (The items 1, 2, 3 are NOT defined in the RC file). Do you know how I could do this?
|
|
|
|
 |
|
 |
I do not quite understand. The way I see it, what you want is exactly what it does.
|
|
|
|
 |
|
 |
I know, this question is not to your code. I have problems with normal, simple enabling and graying menu items.
Commands like:
AfxGetMainWnd()->GetMenu()->EnableMenuItem(ID_VIEW_TOOLBAR,MF_GRAYED|MF_BYCOMMAND);
AfxGetMainWnd()->GetMenu()->GetSubMenu(2)->EnableMenuItem(0,MF_GRAYED|MF_BYPOSITION);
or
AfxGetMainWnd()->GetMenu()->GetSubMenu(2)->EnableMenuItem(ID_VIEW_TOOLBAR,MF_GRAYED|MF_BYCOMMAND);
following with:
AfxGetMainWnd()->DrawMenuBar();
AfxGetMainWnd()->RedrawWindow();
didn't function (the items remained enabled), even though the Status of menu items has been changed (when I tried to call the some function for the second time, the return value (=previous state) was as I set it).
Noticable is, that command
Normal AfxGetMainWnd()->GetMenu()->EnableMenuItem(0,MF_GRAYED|MF_BYPOSITION);
worked properly.
Could You help me with my problem, please?
Thank You very much...
|
|
|
|
 |
|
 |
Hi all.
I already know the solution, though I'm getting quite a lot of mails how did I solve this problem.
Window's main menu has items, which are submenus, and submenus has items
which are usually final items, or (somtimes) further submenus. Usual menu looks like this:
menu=
submenu1 submenu2 submenu3 ....
item11 item21 item31
item12 item22 ...
... ...
etc.
But the menus are stored dynamically, means: menu has only pointers to
each submenu, and when You call GetSubmenu(GetMainMenu(MainWindow,...));
it returns You the pointer to that submenu. But it is stored in some other
way (I've forgotten how and don't understand why), so when You set this
item, it seams to be changed (no error code). But it loads every time
dynamically - from the previous definition (From the resource file or menu
created firs time) and draws as You created it for the first time.
It is running on the main menu correctly, because it does not
reload from the resource. The main menu remains same all the time.
So the solution is:
when submenu1 has defined constatnt MI_ITEM1, submenu2 MI_ITEM2, etc:
//In windows API:
switch (msg)
case WM_COMMAND :
switch ( LOWORD(wParam) ) {
case ( MI_ITEM1 ) :
//Dynamically create submenu
PopupMenu = CreateMenu(...);
AppendMenu(PopupMenu, "Label 11", ..., CMD_ITEM11);
...
// show submenu:
TrackPopupMenuEx(PopupMenu, TPM_LEFTALIGN |
TPM_LEFTBUTTON, actualpos.x, actualpos.y, hWnd, NULL);
return TRUE;
switch (CMD_ITEM11) : ActionItem11();
// Using MFC:
CWhatEver::OnSubmenu1Click ( CWnd *pWnd, CPoint actualpos)
{
...
//Dynamically create submenu
PopupMenu = CreateMenu(...);
AppendMenu(PopupMenu, "Label 11", ..., CMD_ITEM11);
...
// show submenu:
TrackPopupMenuEx(PopupMenu, TPM_LEFTALIGN |
TPM_LEFTBUTTON, actualpos.x, actualpos.y, hWnd, NULL);
...
}
CWhatEver::OnItem11Click ( CWnd *pWnd, CPoint actualpos)
//means, when You click CMD_ITEM1
{
...
ActionItem11();
...
}
I hope it was understandable .
Email me for further questions.
Greetings
Martin Vrbovsky.
|
|
|
|
 |
|
 |
look at BOOL CMainFrame::OnIdle() in MainFrm.cpp : implmentation of the CMainFrame class
|
|
|
|
 |
|