aviad1
aviad1

Reputation: 354

C/C++ Common Controls detecting double-click of TVItem

Is there any way to detect if a tree view control (and specifically a TVITEM) is double clicked using Common Controls & WINAPI? I mean in my wndproc function of a form.

If so, what are the msg, wParam & lParam in that case?

Upvotes: 2

Views: 178

Answers (1)

catnip
catnip

Reputation: 25388

A treeview control sends an NM_DBLCLK notification when you double-click it, with uMsg = WM_NOTIFY and lParam pointing to an NMHDR structure as per the documentation.

You can then send the treeview control a TVM_HITTEST message to determine the item under the cursor, something like:

TVHITTESTINFO tvhti = {};
GetCursorPos (&tvhti.pt);
ScreenToClient (hTreeView, &tvhti.pt);
SendMessage (hTreeView, TVM_HITTEST, 0, (LPARAM) &tvhti);

See the documentation for the values returned by TVM_HITTEST.

Upvotes: 3

Related Questions