1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
//https://stackoverflow.com/questions/30135494/win32-api-c-menu-bar
//https://docs.microsoft.com/en-us/windows/win32/menurc/using-menus
#include <string>
#include "MenuManager.h"
#include "../EditorManager.h"
const int IDM_FILE_NEW = 10;
const int IDM_ASSET = 20;
using namespace std;
MenuManager::MenuManager()
: m_Menus()
{
}
void MenuManager::Init()
{
ContainerWindow* mainWnd = EditorManager::Instance()->GetMainWindow();
Assert(mainWnd != NULL);
HMENU hMenubar = CreateMenu();
HMENU hMenu = CreateMenu();
HMENU hSubMenu = CreatePopupMenu();
HMENU asserMenu = CreateMenu();
AppendMenuW(hMenu, MF_STRING, IDM_FILE_NEW, L"&New");
AppendMenuW(hMenu, MF_SEPARATOR, 0, NULL);
AppendMenuW(asserMenu, MF_STRING, IDM_ASSET, L"Import &mail &assets");
AppendMenuW(hSubMenu, MF_STRING | MF_POPUP, (UINT_PTR)asserMenu, L"Import &mail");
AppendMenuW(hMenu, MF_STRING | MF_POPUP, (UINT_PTR)hSubMenu, L"&Import");
AppendMenuW(hMenubar, MF_POPUP, (UINT_PTR)hMenu, L"&File");
AppendMenuW(hMenu, MF_STRING, IDM_FILE_NEW + 5, L"New 2");
//InsertMenu(hMenu, 1, MF_SEPARATOR | MF_BYPOSITION, 0, NULL);
SetMenu(mainWnd->GetWindowHandle(), hMenubar);
}
void MenuManager::AddMenuItem(std::string name, int order)
{
log_info_tag("Menu", " Add menu item \"%s\"", name);
}
void MenuManager::HandleMenuItemEvent(HMENU menu, unsigned int menuId, unsigned int flags)
{
log_info_tag("Menu", "menuId=%d, flags=%d",menuId, flags);
if (flags & MF_CHECKED) // clicked
{
log_info_tag("Menu", "checked");
}
}
|