| 132 | } |
| 133 | |
| 134 | static int insertMenuItemHelper(HMENU menu, UINT id, UINT position, const tstring& text, |
| 135 | UINT fState = MFS_ENABLED, HMENU hSubMenu = nullptr) |
| 136 | { |
| 137 | MENUITEMINFO item_info; |
| 138 | ZeroMemory(&item_info, sizeof(item_info)); |
| 139 | item_info.cbSize = sizeof(MENUITEMINFO); |
| 140 | item_info.wID = id; |
| 141 | if(text.empty()) |
| 142 | { // Separator |
| 143 | item_info.fMask = MIIM_TYPE; |
| 144 | item_info.fType = MFT_SEPARATOR; |
| 145 | item_info.dwTypeData = nullptr; |
| 146 | } |
| 147 | else |
| 148 | { |
| 149 | item_info.fMask = MIIM_ID | MIIM_TYPE | MIIM_STATE | (hSubMenu != nullptr ? MIIM_SUBMENU : 0); |
| 150 | item_info.fType = MFT_STRING; |
| 151 | item_info.fState = fState; |
| 152 | item_info.dwTypeData = (LPTSTR)text.c_str(); |
| 153 | item_info.hSubMenu = hSubMenu; |
| 154 | } |
| 155 | if(0 == InsertMenuItem(menu, position, TRUE, &item_info)) |
| 156 | SYSERRORLOG(TEXT("InsertMenuItem")); |
| 157 | return id; |
| 158 | } |
| 159 | |
| 160 | STDMETHODIMP |
| 161 | DIFF_EXT::QueryContextMenu(HMENU menu, UINT position, UINT first_cmd, UINT /*last_cmd not used*/, UINT flags) |