MCPcopy Create free account
hub / github.com/DDoSolitary/LxRunOffline / QueryContextMenu

Method QueryContextMenu

src/LxRunOfflineShellExt/ContextMenuHandler.cpp:63–104  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

61}
62
63IFACEMETHODIMP CContextMenuHandler::QueryContextMenu(
64 const HMENU hmenu,
65 const UINT indexMenu,
66 const UINT idCmdFirst,
67 const UINT idCmdLast,
68 const UINT uFlags
69) {
70 if (uFlags & CMF_DEFAULTONLY) {
71 return S_OK;
72 }
73 const auto distro_size = static_cast<UINT>(this->distros.size());
74 const auto menu_size = std::min(distro_size, idCmdLast - idCmdFirst + 1);
75 this->hsm = CreatePopupMenu();
76 if (!this->hsm) {
77 return HRESULT_FROM_WIN32(GetLastError());
78 }
79 for (UINT i = 0; i < menu_size; i++) {
80 MENUITEMINFO mi;
81 mi.cbSize = sizeof(mi);
82 mi.fMask = MIIM_FTYPE | MIIM_ID | MIIM_STRING;
83 mi.fType = MFT_STRING;
84 mi.wID = idCmdFirst + i;
85 mi.dwTypeData = const_cast<LPWSTR>(this->distros[i].c_str());
86 if (!InsertMenuItem(this->hsm, i, TRUE, &mi)) {
87 return HRESULT_FROM_WIN32(GetLastError());
88 }
89 }
90 const auto disabled = distro_size == 0;
91 static wchar_t item_name[] = L"LxRunOffline";
92 static wchar_t item_name_disabled[] = L"LxRunOffline (no distros)";
93 MENUITEMINFO mi;
94 mi.cbSize = sizeof(mi);
95 mi.fMask = MIIM_FTYPE | MIIM_STATE | MIIM_STRING | MIIM_SUBMENU;
96 mi.fType = MFT_STRING;
97 mi.fState = disabled ? MFS_DISABLED : MFS_ENABLED;
98 mi.dwTypeData = disabled ? item_name_disabled : item_name;
99 mi.hSubMenu = this->hsm;
100 if (!InsertMenuItem(hmenu, indexMenu, TRUE, &mi)) {
101 return HRESULT_FROM_WIN32(GetLastError());
102 }
103 return MAKE_HRESULT(SEVERITY_SUCCESS, FACILITY_NULL, menu_size);
104}
105
106IFACEMETHODIMP CContextMenuHandler::GetCommandString(UINT_PTR, UINT, UINT *, LPSTR, UINT) {
107 return E_NOTIMPL;

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected