Hi,
I am trying to create a plugin to add an extra menu item in codeblocks.
Is there any guide, I can refer?
I referred this article, http://wiki.codeblocks.org/index.php/Creating_a_Plug-in_which_modifies_CB's_Menus
But its outdated and giving errors on using the api mentioned. Is there any updated one?
I tried to build the menu plugin following the above link, but I struck into submenu part.
Adding a submenu
Let's take our manipulation of the menu 1 step further. Let's create a submenu, which has its own entries. Since a submenu is nothing more then a menu, we first need to create a new menu object; this new object has to live as long as the plug-in itself, so it can not be a local variable, it needs to be stored in the class itself. Therefor we added the member m_SubMenu1, initialized to NULL, and released during the destructor. We will allocate it now :
m_SubMenu1 = new wxMenu();
And we append this new menu to our EditMenu :
EditMenu->Append(idSubMenu1, _("SubMenu1"), m_SubMenu1);
Build Log
\Users\zbcqcm\Documents\Codeblocks_SVN\MenuPlugin\MenuPlugin.cpp -o .objs\MenuPlugin.o
mingw32-g++.exe -shared -Wl,--dll -LC:\zbcqcm\codeblocks_svn_code\code\src\devel -LC:\wxMSW-2.8.12\wxMSW-2.8.12\lib\gcc_dll -LC:\wxMSW-2.8.12\wxMSW-2.8.12\lib\gcc_dll -L"C:\Program Files (x86)\CodeBlocks" .objs\MenuPlugin.o -o MenuPlugin.dll -mthreads -lcodeblocks -lwxmsw28u
C:\Users\zbcqcm\Documents\Codeblocks_SVN\MenuPlugin\MenuPlugin.cpp: In member function 'virtual void MenuPlugin::BuildMenu(wxMenuBar*)':
C:\Users\zbcqcm\Documents\Codeblocks_SVN\MenuPlugin\MenuPlugin.cpp:79:5: error: 'm_SubMenu1' was not declared in this scope
m_SubMenu1 = new wxMenu();
^
C:\Users\zbcqcm\Documents\Codeblocks_SVN\MenuPlugin\MenuPlugin.cpp:80:22: error: 'idSubMenu1' was not declared in this scope
EditMenu->Append(idSubMenu1, _("SubMenu1"), m_SubMenu1);
error: 'm_SubMenu1' was not declared in this scope
In C++, to use a member variable, you have to define it first, then use it. :) This is the same reason of the error about "idSubMenu1".