Old 04-29-2008, 08:37 AM   #1
sws
Code Monkey
 
sws's Avatar
 
Join Date: Sep 2007
Location: Madison, WI
Posts: 857
Default 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!
sws is offline   Reply With Quote
Old 04-29-2008, 08:39 AM   #2
Xenakios
Human being with feelings
 
Xenakios's Avatar
 
Join Date: Feb 2007
Location: Oulu, Finland
Posts: 8,062
Default

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.
Xenakios is offline   Reply With Quote
Old 04-29-2008, 08:44 AM   #3
sws
Code Monkey
 
sws's Avatar
 
Join Date: Sep 2007
Location: Madison, WI
Posts: 857
Default

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
sws is offline   Reply With Quote
Old 04-29-2008, 09:59 AM   #4
Deric
Human being with feelings
 
Join Date: Mar 2007
Posts: 794
Default

Great stuff SWS!
__________________
REAPER? Oh yes...
Deric is offline   Reply With Quote
Old 04-29-2008, 04:40 PM   #5
Xenakios
Human being with feelings
 
Xenakios's Avatar
 
Join Date: Feb 2007
Location: Oulu, Finland
Posts: 8,062
Default

Yes, seems to work :

__________________
I am no longer part of the REAPER community. Please don't contact me with any REAPER-related issues.
Xenakios is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 10:39 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.