Added context menu on right click in treeviews

svn path=/trunk/; revision=29384
This commit is contained in:
Gregor Brunmar 2007-10-03 19:45:39 +00:00
parent 62cb1ae6bf
commit 7d65442299
2 changed files with 39 additions and 0 deletions

View file

@ -172,3 +172,26 @@ Index: treeview.c
if (infoPtr->cdmode & CDRF_NOTIFYPOSTPAINT)
infoPtr->cdmode =
TREEVIEW_SendCustomDrawNotify(infoPtr, CDDS_POSTPAINT, hdc, rect);
@@ -4160,6 +4158,22 @@
static LRESULT
TREEVIEW_RButtonUp(const TREEVIEW_INFO *infoPtr, const POINT *pPt)
{
+ TVHITTESTINFO ht;
+
+ ht.pt = *pPt;
+
+ TREEVIEW_HitTest(infoPtr, &ht);
+
+ if (ht.hItem)
+ {
+ /* Change to screen coordinate for WM_CONTEXTMENU */
+ ClientToScreen(infoPtr->hwnd, &ht.pt);
+
+ /* Send a WM_CONTEXTMENU message in response to the RBUTTONUP */
+ SendMessageW(infoPtr->hwnd, WM_CONTEXTMENU,
+ (WPARAM)infoPtr->hwnd, MAKELPARAM(ht.pt.x, ht.pt.y));
+ }
+
return 0;
}

View file

@ -4158,6 +4158,22 @@ TREEVIEW_RButtonDown(TREEVIEW_INFO *infoPtr, LPARAM lParam)
static LRESULT
TREEVIEW_RButtonUp(const TREEVIEW_INFO *infoPtr, const POINT *pPt)
{
TVHITTESTINFO ht;
ht.pt = *pPt;
TREEVIEW_HitTest(infoPtr, &ht);
if (ht.hItem)
{
/* Change to screen coordinate for WM_CONTEXTMENU */
ClientToScreen(infoPtr->hwnd, &ht.pt);
/* Send a WM_CONTEXTMENU message in response to the RBUTTONUP */
SendMessageW(infoPtr->hwnd, WM_CONTEXTMENU,
(WPARAM)infoPtr->hwnd, MAKELPARAM(ht.pt.x, ht.pt.y));
}
return 0;
}