diff options
author | George Hazan <ghazan@miranda.im> | 2023-03-28 14:15:31 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2023-03-28 14:15:31 +0300 |
commit | 73247c72e12b8047f1541d6525c4ab151b505b43 (patch) | |
tree | 87fe5f95d2bdceab2119f7e336a7aba980d44925 /src/mir_app | |
parent | 3986f667cb0f3fffeaee637dcee097b582e240ca (diff) |
fixes #3467 (MyHandle must always be first)
Diffstat (limited to 'src/mir_app')
-rw-r--r-- | src/mir_app/src/contacts.cpp | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/src/mir_app/src/contacts.cpp b/src/mir_app/src/contacts.cpp index 55f55b5bff..7fc760e550 100644 --- a/src/mir_app/src/contacts.cpp +++ b/src/mir_app/src/contacts.cpp @@ -335,6 +335,7 @@ public: {
m_nameOrder.SetFlags(MTREE_DND);
m_nameOrder.OnBeginDrag = Callback(this, &CContactOptsDlg::OnBeginDrag);
+ m_nameOrder.OnEndDrag = Callback(this, &CContactOptsDlg::OnEndDrag);
}
bool OnInitDialog() override
@@ -367,11 +368,29 @@ public: return true;
}
- void OnBeginDrag(CCtrlTreeView::TEventInfo *evt)
+ bool OnBeginDrag(CCtrlTreeView::TEventInfo *evt)
{
LPNMTREEVIEW pNotify = evt->nmtv;
- if (pNotify->itemNew.lParam == 0 || pNotify->itemNew.lParam == _countof(nameOrderDescr) - 1)
- pNotify->hdr.code = 0; // deny dragging
+ return (pNotify->itemNew.lParam != 0 && pNotify->itemNew.lParam != _countof(nameOrderDescr)-1);
+ }
+
+ bool OnEndDrag(CCtrlTreeView::TEventInfo *evt)
+ {
+ auto &hti = *evt->ntvhi;
+
+ // do not allow to move selection over the first item
+ if (hti.flags & TVHT_ABOVE)
+ return false;
+
+ // do not allow to move selection below the last item either
+ TVITEMEX tvi;
+ tvi.mask = TVIF_HANDLE | TVIF_PARAM;
+ tvi.hItem = hti.hItem;
+ m_nameOrder.GetItem(&tvi);
+ if (tvi.lParam == _countof(nameOrderDescr) - 1)
+ return false;
+
+ return true;
}
};
|