在emwin官方例程WIDGET_Menu.c中可以实现在菜单栏的基础下增加子菜单。我就尝试在按键中尝试添加菜单栏,实现点击按键弹出菜单栏。但是呢不成功。以下部位是我根据前者修改的。麻烦大神指引下。
static void _AddMenuItem(MENU_Handle hMenu, MENU_Handle hSubmenu, const char* pText, U16 Id, U16 Flags) {
MENU_ITEM_DATA Item;
Item.pText = pText;
Item.hSubmenu = hSubmenu;
Item.Flags = Flags;
Item.Id = Id;
MENU_AddItem(_hBut, &Item);
//MENU_AddItem();
}
// USER START (Optionally insert additional static code)
// USER END
static WM_HWIN _CreateMenu(WM_HWIN hParent) {
// MENU_Handle hMenuFile;
// MENU_Handle hMenuEdit;
// MENU_Handle hMenuHelp;
// MENU_Handle hMenuRecent;
_hBut = BUTTON_Create(142, 100, 36, 40, ID_BOTTON_4, WM_CF_SHOW);
// hMenuFile = MENU_CreateEx(0, 0, 0, 0, _hBut, 0, MENU_CF_VERTICAL, 0);
_AddMenuItem(_hBut, 0, "New", ID_MENU_FILE_NEW, 0);
_AddMenuItem(_hBut, 0, "Open", ID_MENU_FILE_OPEN, 0);
_AddMenuItem(_hBut, 0, "Close", ID_MENU_FILE_CLOSE, MENU_IF_DISABLED);
_AddMenuItem(_hBut, 0, "Exit", ID_MENU_FILE_EXIT, 0);
return _hBut;
}
|