MCPcopy Create free account
hub / github.com/SOUI2/soui / TrackPopupMenu

Method TrackPopupMenu

SOUI/src/helper/SMenuEx.cpp:630–675  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

628 }
629
630 UINT SMenuEx::TrackPopupMenu(UINT flag, int x, int y, HWND hOwner, int nScale)
631 {
632 if (!IsWindow()) return (UINT)-1;
633 if (!s_MenuData)
634 s_MenuData = new SMenuExRunData(hOwner, nScale);
635 else
636 s_MenuData->AddRef();
637
638 HWND hActive = hOwner;
639 if (!hOwner || !::IsWindowEnabled(hOwner)) hActive = ::GetActiveWindow();
640
641 HWND hRoot = hActive;
642 while (::GetParent(hRoot))
643 {
644 hRoot = ::GetParent(hRoot);
645 }
646 SetForegroundWindow(hRoot);
647
648 ShowMenu(flag, x, y);
649 RunMenu(hRoot);
650 HideMenu(FALSE);
651
652 if (hActive)
653 {
654 CPoint pt;
655 GetCursorPos(&pt);
656 ::ScreenToClient(hActive, &pt);
657 ::PostMessage(hActive, WM_MOUSEMOVE, 0, MAKELPARAM(pt.x, pt.y));
658 }
659
660 int nRet = s_MenuData->GetCmdID();
661 if (0 == s_MenuData->Release())
662 {
663 s_MenuData = NULL;
664 }
665 if (flag & TPM_RETURNCMD)
666 {
667 return nRet;
668 }
669 else
670 {
671 ::SendMessage(hOwner, WM_COMMAND, MAKEWPARAM(nRet, 0), 0);
672 return TRUE;
673 }
674
675 }
676
677 void SMenuEx::ShowMenu(UINT uFlag, int x, int y)
678 {

Callers

nothing calls this directly

Calls 8

IsWindowFunction · 0.85
IsWindowEnabledFunction · 0.85
ScreenToClientFunction · 0.85
PostMessageFunction · 0.85
SendMessageFunction · 0.85
GetCmdIDMethod · 0.80
AddRefMethod · 0.45
ReleaseMethod · 0.45

Tested by

no test coverage detected