From a84f13194da3bd7ba45d5edd84229043369f2324 Mon Sep 17 00:00:00 2001 From: George Hazan <ghazan@miranda.im> Date: Thu, 29 Apr 2021 15:32:53 +0300 Subject: fix for menu position calculation --- src/mir_core/src/CCtrlListBox.cpp | 10 ++++++---- src/mir_core/src/CCtrlListView.cpp | 5 +++-- src/mir_core/src/CCtrlTreeView.cpp | 8 +++++--- 3 files changed, 14 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/mir_core/src/CCtrlListBox.cpp b/src/mir_core/src/CCtrlListBox.cpp index 34980c05a3..da75fefe19 100644 --- a/src/mir_core/src/CCtrlListBox.cpp +++ b/src/mir_core/src/CCtrlListBox.cpp @@ -47,12 +47,14 @@ void CCtrlListBox::GetCaretPos(CContextMenuPos &pos) const if (pos.iCurr != -1) { RECT rc; GetItemRect(pos.iCurr, &rc); - pos.pt.x = rc.left; - pos.pt.y = rc.top; + pos.pt.x = rc.left + 8; + pos.pt.y = rc.top + 8; + ClientToScreen(m_hwnd, &pos.pt); + return; } - else CSuper::GetCaretPos(pos); } - else CSuper::GetCaretPos(pos); + + CSuper::GetCaretPos(pos); } ///////////////////////////////////////////////////////////////////////////////////////// diff --git a/src/mir_core/src/CCtrlListView.cpp b/src/mir_core/src/CCtrlListView.cpp index 0156aeab6e..9573cc0b02 100644 --- a/src/mir_core/src/CCtrlListView.cpp +++ b/src/mir_core/src/CCtrlListView.cpp @@ -159,8 +159,9 @@ void CCtrlListView::GetCaretPos(CContextMenuPos &pos) const if (pos.iCurr != -1) { RECT rc; GetItemRect(pos.iCurr, &rc, TRUE); - pos.pt.x = rc.left; - pos.pt.y = rc.top; + pos.pt.x = rc.left + 8; + pos.pt.y = rc.top + 8; + ClientToScreen(m_hwnd, &pos.pt); return; } } diff --git a/src/mir_core/src/CCtrlTreeView.cpp b/src/mir_core/src/CCtrlTreeView.cpp index 3edabcd61a..056f149588 100644 --- a/src/mir_core/src/CCtrlTreeView.cpp +++ b/src/mir_core/src/CCtrlTreeView.cpp @@ -557,12 +557,13 @@ void CCtrlTreeView::GetCaretPos(CContextMenuPos &pos) const HTREEITEM hItem = GetSelection(); if (hItem != nullptr) { pos.pCtrl = this; - pos.iCurr = (INT_PTR)hItem; + pos.hItem = hItem; RECT rc; GetItemRect(hItem, &rc, TRUE); - pos.pt.x = rc.left; - pos.pt.y = rc.top; + pos.pt.x = rc.left + 8; + pos.pt.y = rc.top + 8; + ClientToScreen(m_hwnd, &pos.pt); return; } } @@ -570,6 +571,7 @@ void CCtrlTreeView::GetCaretPos(CContextMenuPos &pos) const else { TVHITTESTINFO hti; hti.pt = pos.pt; + ScreenToClient(m_hwnd, &hti.pt); if (HitTest(&hti) && (hti.flags & TVHT_ONITEM)) { pos.hItem = hti.hItem; return; -- cgit v1.2.3