From 385e9fc6fffe35fff080fdcb564b835a334c8feb Mon Sep 17 00:00:00 2001 From: George Hazan Date: Thu, 21 Jan 2016 11:19:18 +0000 Subject: fix for moving menu item to the first position in a submenu git-svn-id: http://svn.miranda-ng.org/main/trunk@16132 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- src/mir_core/src/mir_core.def | 2 +- src/mir_core/src/mir_core64.def | 2 +- src/mir_core/src/ui_utils.cpp | 17 +++++++++++------ 3 files changed, 13 insertions(+), 8 deletions(-) (limited to 'src/mir_core') diff --git a/src/mir_core/src/mir_core.def b/src/mir_core/src/mir_core.def index c5ff0c1fbc..3263fd854b 100644 --- a/src/mir_core/src/mir_core.def +++ b/src/mir_core/src/mir_core.def @@ -933,7 +933,7 @@ mir_wstrcmpi @280 ?SelectRange@CCtrlTreeView@@QAEXPAU_TREEITEM@@0@Z @1091 NONAME ?Unselect@CCtrlTreeView@@QAEXPAU_TREEITEM@@@Z @1092 NONAME ?UnselectAll@CCtrlTreeView@@QAEXXZ @1093 NONAME -?MoveItemAbove@CCtrlTreeView@@AAEPAU_TREEITEM@@PAU2@0@Z @1094 NONAME +?MoveItemAbove@CCtrlTreeView@@AAEPAU_TREEITEM@@PAU2@00@Z @1094 NONAME ?GetCurrPage@CCtrlPages@@AAEPAUTPageInfo@1@XZ @1095 NONAME ?Fail@CDlgBase@@QAEXXZ @1096 NONAME ?OnApply@CCtrlPages@@MAEXXZ @1097 NONAME diff --git a/src/mir_core/src/mir_core64.def b/src/mir_core/src/mir_core64.def index 3d660b330c..5fa704f8d9 100644 --- a/src/mir_core/src/mir_core64.def +++ b/src/mir_core/src/mir_core64.def @@ -933,7 +933,7 @@ mir_wstrcmpi @280 ?SelectRange@CCtrlTreeView@@QEAAXPEAU_TREEITEM@@0@Z @1091 NONAME ?Unselect@CCtrlTreeView@@QEAAXPEAU_TREEITEM@@@Z @1092 NONAME ?UnselectAll@CCtrlTreeView@@QEAAXXZ @1093 NONAME -?MoveItemAbove@CCtrlTreeView@@AEAAPEAU_TREEITEM@@PEAU2@0@Z @1094 NONAME +?MoveItemAbove@CCtrlTreeView@@AEAAPEAU_TREEITEM@@PEAU2@00@Z @1094 NONAME ?GetCurrPage@CCtrlPages@@AEAAPEAUTPageInfo@1@XZ @1095 NONAME ?Fail@CDlgBase@@QEAAXXZ @1096 NONAME ?OnApply@CCtrlPages@@MEAAXXZ @1097 NONAME diff --git a/src/mir_core/src/ui_utils.cpp b/src/mir_core/src/ui_utils.cpp index 9559a7fabd..de9d41bb11 100644 --- a/src/mir_core/src/ui_utils.cpp +++ b/src/mir_core/src/ui_utils.cpp @@ -1383,7 +1383,7 @@ void CCtrlTreeView::OnInit() Subclass(); } -HTREEITEM CCtrlTreeView::MoveItemAbove(HTREEITEM hItem, HTREEITEM hInsertAfter) +HTREEITEM CCtrlTreeView::MoveItemAbove(HTREEITEM hItem, HTREEITEM hInsertAfter, HTREEITEM hParent) { if (hItem == NULL || hInsertAfter == NULL) return NULL; @@ -1411,7 +1411,7 @@ HTREEITEM CCtrlTreeView::MoveItemAbove(HTREEITEM hItem, HTREEITEM hInsertAfter) tvis.itemex.stateMask = tvis.itemex.state; tvis.itemex.lParam = saveOldData; - tvis.hParent = (hInsertAfter == TVI_FIRST) ? NULL : GetParent(hInsertAfter); + tvis.hParent = hParent; tvis.hInsertAfter = hInsertAfter; return InsertItem(&tvis); } @@ -1460,26 +1460,31 @@ LRESULT CCtrlTreeView::CustomWndProc(UINT msg, WPARAM wParam, LPARAM lParam) else if (hti.flags & TVHT_BELOW) hti.hItem = TVI_LAST; + HTREEITEM insertAfter = hti.hItem; + HTREEITEM hParent = (insertAfter == TVI_FIRST) ? NULL : GetParent(insertAfter); + if (GetChild(insertAfter) != NULL) { + hParent = insertAfter; + insertAfter = TVI_FIRST; + } + HTREEITEM FirstItem = NULL; if (m_bMultiSelect) { LIST<_TREEITEM> arItems(10); GetSelected(arItems); // Proceed moving - HTREEITEM insertAfter = hti.hItem; - HTREEITEM hParent = GetParent(hti.hItem); for (int i = 0; i < arItems.getCount(); i++) { if (!insertAfter) break; if (GetParent(arItems[i]) != hParent) // prevent subitems from being inserted at the same level continue; - insertAfter = MoveItemAbove(arItems[i], insertAfter); + insertAfter = MoveItemAbove(arItems[i], insertAfter, hParent); if (!i) FirstItem = insertAfter; } } - else FirstItem = MoveItemAbove(m_hDragItem, hti.hItem); + else FirstItem = MoveItemAbove(m_hDragItem, insertAfter, hParent); if (FirstItem) SelectItem(FirstItem); -- cgit v1.2.3