|
|
|
04-29-2008, 08:37 AM
|
#1
|
Code Monkey
Join Date: Sep 2007
Location: Madison, WI
Posts: 857
|
Adding a submenu
Xenakios, this is for you.
Let's say you want to add a submenu to the end of the REAPER Edit menu that gives you a list the commands you've defined in your plugin. In your entry point function, after you've defined all of your command accelerators and IDs, do this:
Code:
HMENU hSubMenu = CreatePopupMenu();
MENUITEMINFO mi={sizeof(MENUITEMINFO),};
mi.fMask = MIIM_TYPE | MIIM_ID;
mi.fType = MFT_STRING;
// Add a section like this for each of your commands
mi.wID = my_command_id_1;
mi.dwTypeData = "My command 1";
InsertMenuItem(hSubMenu, 0, TRUE, &mi);
// Here's command #2, make sure to increment InsertMenuItem index
mi.wID = my_command_id_2;
mi.dwTypeData = "My command 2";
InsertMenuItem(hSubMenu, 1, TRUE, &mi);
// add more commands as above, then add it to REAPER
// Index '1' in GetSubMenu returns the 2nd menu, in this case, the "Edit" menu
HMENU hMenu = GetSubMenu(GetMenu(GetMainHwnd()),1);
mi.fMask = MIIM_SUBMENU | MIIM_TYPE;
mi.hSubMenu = hSubMenu;
mi.dwTypeData = "My commands"; // Name of submenu
// Add to end of menu with GetMenuItemCount so if Justin adds/subtracts items nothing breaks
InsertMenuItem(hMenu, GetMenuItemCount(hMenu), TRUE, &mi);
Hope this helps!
|
|
|
04-29-2008, 08:39 AM
|
#2
|
Human being with feelings
Join Date: Feb 2007
Location: Oulu, Finland
Posts: 8,062
|
Heh, ok, thanks for this!
I was kind of hoping maybe an additional main menu item, next to "Help", but I think that's maybe too tricky to do...
Anyway, this will do just fine, as most of my new commands are somewhat "editing" related, so they fit nicely to a submenu in the edit-menu...
__________________
I am no longer part of the REAPER community. Please don't contact me with any REAPER-related issues.
|
|
|
04-29-2008, 08:44 AM
|
#3
|
Code Monkey
Join Date: Sep 2007
Location: Madison, WI
Posts: 857
|
Hehe, that's easy too, change the last bit of code above to:
Code:
HMENU hMenu = GetMenu(GetMainHwnd());
mi.fMask = MIIM_SUBMENU | MIIM_TYPE;
mi.hSubMenu = hSubMenu;
mi.dwTypeData = "My commands";
InsertMenuItem(hMenu, GetMenuItemCount(hMenu)-1, TRUE, &mi);
The differences are GetMenu() instead of GetSubMenu() (to put you on the top menu bar) and GetMenuItemCount-1 (otherwise you're to the right of the HW status "menu").
Last edited by sws; 04-29-2008 at 08:55 AM.
Reason: Clarification
|
|
|
04-29-2008, 09:59 AM
|
#4
|
Human being with feelings
Join Date: Mar 2007
Posts: 794
|
Great stuff SWS!
__________________
REAPER? Oh yes...
|
|
|
04-29-2008, 04:40 PM
|
#5
|
Human being with feelings
Join Date: Feb 2007
Location: Oulu, Finland
Posts: 8,062
|
Yes, seems to work :
__________________
I am no longer part of the REAPER community. Please don't contact me with any REAPER-related issues.
|
|
|
Thread Tools |
|
Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -7. The time now is 10:39 PM.
|