MCPcopy Create free account
hub / github.com/TranslucentTB/TranslucentTB / ShowClassicContextMenu

Method ShowClassicContextMenu

TranslucentTB/tray/basecontextmenu.cpp:188–208  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

186}
187
188void BaseContextMenu::ShowClassicContextMenu(const wuxc::MenuFlyout &flyout, POINT pt)
189{
190 const auto guard = wil::scope_exit([this]
191 {
192 CleanupClassicContextMenu();
193 });
194
195 if (const auto menu = BuildClassicContextMenu(flyout))
196 {
197 SetLastError(NO_ERROR);
198 const unsigned int item = TrackPopupMenu(menu, TPM_RETURNCMD | TPM_LEFTALIGN, pt.x, pt.y, 0, m_WindowHandle, nullptr);
199 if (item)
200 {
201 TriggerClassicContextMenuItem(item);
202 }
203 else if (const DWORD lastErr = GetLastError(); lastErr != NO_ERROR) // can return 0 if the menu is dismissed
204 {
205 HresultHandle(HRESULT_FROM_WIN32(lastErr), spdlog::level::warn, L"Failed to open context menu.");
206 }
207 }
208}
209
210void BaseContextMenu::MoveHiddenWindow(RECT &rect)
211{

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected