2010-06-07 02:23:58 +00:00
|
|
|
#include "stdafx.h"
|
2008-09-18 03:15:49 +00:00
|
|
|
|
|
|
|
CBaseMenu::CBaseMenu () :
|
2015-01-27 05:07:44 +00:00
|
|
|
m_MenuHandle((HMENU)CreateMenu())
|
2008-09-18 03:15:49 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2015-01-27 05:07:44 +00:00
|
|
|
bool CBaseMenu::AddMenu(HMENU hMenu, MenuItemList Items ) {
|
2008-09-18 03:15:49 +00:00
|
|
|
if (Items.begin() == Items.end()) { return false; }
|
|
|
|
|
|
|
|
UINT ItemID, uFlags;
|
|
|
|
stdstr Text;
|
|
|
|
stdstr String;
|
|
|
|
for (MenuItemList::iterator MenuItem = Items.begin(); MenuItem != Items.end(); MenuItem++) {
|
|
|
|
ItemID = MenuItem->ID;
|
|
|
|
uFlags = MF_STRING;
|
|
|
|
Text = _Lang->GetString(MenuItem->Title).c_str();
|
|
|
|
|
|
|
|
if (MenuItem->Title == EMPTY_STRING && MenuItem->ManualString.length() > 0) {
|
|
|
|
Text = MenuItem->ManualString;
|
|
|
|
}
|
|
|
|
if (ItemID == SPLITER) {
|
|
|
|
uFlags |= MF_SEPARATOR;
|
|
|
|
}
|
|
|
|
if (MenuItem->ItemTicked) {
|
|
|
|
uFlags |= MFS_CHECKED;
|
|
|
|
}
|
|
|
|
if (MenuItem->ItemEnabled) {
|
|
|
|
uFlags |= MFS_ENABLED;
|
|
|
|
} else {
|
|
|
|
uFlags |= MFS_DISABLED;
|
|
|
|
}
|
|
|
|
|
|
|
|
MenuItemList * SubMenu = (MenuItemList *)MenuItem->SubMenu;
|
|
|
|
if (ItemID == SUB_MENU && HIWORD(SubMenu) != 0 && (SubMenu->begin() != SubMenu->end())) {
|
|
|
|
ItemID = (UINT)CreatePopupMenu();
|
|
|
|
uFlags |= MF_POPUP;
|
|
|
|
|
2015-01-27 05:07:44 +00:00
|
|
|
AddMenu((HMENU)ItemID,*SubMenu);
|
2008-09-18 03:15:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (ItemID == ID_PLUGIN_MENU)
|
|
|
|
{
|
|
|
|
ItemID = (UINT)MenuItem->SubMenu;
|
|
|
|
uFlags |= MF_POPUP;
|
|
|
|
MENUITEMINFO lpmii;
|
|
|
|
|
|
|
|
lpmii.cbSize = sizeof(MENUITEMINFO);
|
|
|
|
lpmii.fMask = MIIM_STATE;
|
|
|
|
lpmii.fState = 0;
|
|
|
|
SetMenuItemInfo((HMENU)ItemID, (DWORD)MenuItem->SubMenu, FALSE,&lpmii);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (MenuItem->ShotCut.empty() == false) {
|
|
|
|
String = Text;
|
|
|
|
String += "\t";
|
|
|
|
String += MenuItem->ShotCut;
|
|
|
|
Text = String;
|
|
|
|
}
|
|
|
|
AppendMenu((HMENU)hMenu,uFlags,ItemID,Text.c_str());
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-11-14 20:51:06 +00:00
|
|
|
/*void MENU_SHORT_CUT::RemoveItem ( MENU_SHORT_CUT_KEY * ShortCut )
|
2008-09-18 03:15:49 +00:00
|
|
|
{
|
|
|
|
for (SHORTCUT_KEY_LIST::iterator item = m_AccelList.begin(); item != m_AccelList.end(); item++) {
|
|
|
|
if (ShortCut == &*item) {
|
|
|
|
m_AccelList.erase(item);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-11-14 20:51:06 +00:00
|
|
|
}*/
|
2008-09-18 03:15:49 +00:00
|
|
|
|