THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 30/07/2012 at 10:10, xxxxxxxx wrote:
I'm sorry I have to say this. But the search option in this forum really sucks.
There are times when I know the subject has been covered. Yet it doesn't get found. Even with an advanced search.
I think there's a lot of good information that is getting wiped out from this forum.
Anyway. With the ranting over and out of the way.
This is some menu code that I know I got from here. Yet won't come up with a search.
This code is how to search through the menus:
BaseContainer *bc = GetMenuResource(String("M_EDITOR")); //Gets the items under the M_EDITOR section
if (!bc) return NULL;
LONG id;
GeData *last = NULL, *dat;
BrowseContainer browse(bc); //A built in function for iterating containers(Can't edit containers with it)
while (browse.GetNext(&id,&dat))
{
if(id==MENURESOURCE_SUBMENU) //Gets the submenu items of M_EDITOR
{
BaseContainer *dc = dat->GetContainer(); //Gets the container for the Gedata and assign a variable to it
String names = dc->GetString(MENURESOURCE_SUBTITLE); //Gets the names of the submenu items
GePrint(names);
if(dc && dc->GetString(MENURESOURCE_SUBTITLE)=="IDS_EDITOR_FILE") //If the container exists and we find this menu name in it
{
GePrint("found the IDS_EDITOR_FILE submenu");
last = dat;
break;
}
}
}
The problem is I don't know how to go one step deeper and get the individual items inside of the File menu. Then add your own item to the list.
I can only get TO the File menu..which is a submenu of M_EDITOR.
So this code is not complete enough to add your own file->menu item.:cry:
For adding a new custom menu to the top menu bar. That's easier:
//This code creates a new main menu at the top of the C4D UI interface when C4D starts up
//This method is found in the main.cpp file
//NOTE: you also need to uncomment EnhanceMainMenu(); found in the Bool PluginMessage(LONG id, void *data) method's switch statement
void EnhanceMainMenu(void)
{
// do this only if necessary - otherwise the user will end up with dozens of menus!
BaseContainer *bc = GetMenuResource(String("M_EDITOR")); //Gets the items under the M_EDITOR section
//BaseContainer *bc = GetMenuResource(String("M_CONSOLE")); //Gets the items under the M_CONSOLE section
if (!bc) return;
GeData *last = SearchPluginSubMenuResource();
LONG value = last->GetLong();
GePrint(LongToString(value));
BaseContainer sc;
sc.InsData(MENURESOURCE_SUBTITLE,String("MyMenu")); //Adds a new menu entry to the UI in memory only
if (last) bc->InsDataAfter(MENURESOURCE_STRING,sc,last); //Adds the new menu to the UI
UpdateMenus(); //Updates the menu changes
}
However.
Once you have that new menu. I have no idea how to add your plugin as a child of that custom menu.
So there's a lot of missing information on this subject that might be lost somewhere in the forum archives.
-ScottA