MCPcopy Create free account
hub / github.com/BeneficialCode/WinArk / AddMenu

Method AddMenu

WinArk/OwnerDrawnMenu.cpp:49–74  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

47}
48
49bool COwnerDrawnMenuBase::AddMenu(HMENU hMenu) {
50 ATLASSERT(::IsMenu(hMenu));
51 CMenuHandle menu(hMenu);
52 UpdateMenu(menu, true);
53 auto count = menu.GetMenuItemCount();
54 MENUITEMINFO mii = { sizeof(mii) };
55 WCHAR text[16];
56 // c++11 �����ƶ�
57 for (decltype(count) i = 0; i < count; i++) {
58 mii.fMask = MIIM_SUBMENU | MIIM_ID;
59 if (menu.GetMenuItemInfo(i, TRUE, &mii) && mii.hSubMenu) {
60 AddSubMenu(mii.hSubMenu);
61 mii.fMask = MIIM_TYPE | MIIM_DATA;
62 mii.fType = MFT_OWNERDRAW;
63 mii.dwItemData = TopLevelMenu; // top level menu
64 ATLVERIFY(menu.SetMenuItemInfo(i, TRUE, &mii));
65 if (menu.GetMenuString(i, text, _countof(text), MF_BYPOSITION)) {
66 ItemData data;
67 data.Text = text;
68 data.Image = -1;
69 m_Items.insert({ mii.wID,data });
70 }
71 }
72 }
73 return true;
74}
75
76void COwnerDrawnMenuBase::AddSubMenu(CMenuHandle menu) {
77 UpdateMenu(menu);

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected