I have a window with CTreeControl
. I am able to catch WM_MBUTTONDOWN
event in area of window (ON_WM_MBUTTONDOWN
macro), but not in area of CTreeControl
.
Is some way to catch this event for CTreeControl
?
Thanks.
Asked
Active
Viewed 98 times
0

Andrew Truckle
- 17,769
- 16
- 66
- 164

Michal Hadraba
- 347
- 1
- 11
-
I believe you will have to use an [`ON_CONTROL`](https://learn.microsoft.com/en-us/cpp/mfc/reference/message-map-macros-mfc#on_control) entry in the control parent's message map. – IInspectable Feb 08 '23 at 07:20
-
Do you have some exmaple? I have not idea how to use it... Thanks. – Michal Hadraba Feb 08 '23 at 16:27
-
Using SpyXX, I don't see any obvious messages the tree control sends back to its parent. And that ON_CONTROL macro is for handling WM_COMMAND notification messages like BN_CLICKED and such. You'll likely need to subclass the tree control to handle the WM_MBUTTONDOWN directly. – Ed Dore Feb 08 '23 at 17:33
-
In this discussion he derives his on tree control: https://microsoft.public.vc.mfc.narkive.com/X5490dmy/tree-control-onclick-vs-onlbuttonup and then handles `OnClick`. – Andrew Truckle Feb 08 '23 at 18:59
-
1@EdDore `ON_CONTROL` is for arbitrary messages. `ON_COMMAND` is for `WM_COMMAND`-based messages. – IInspectable Feb 08 '23 at 20:04
1 Answers
0
You could create a MFC class that inherits from CTreeCtrl and then create WM_MBUTTONDOWN from the class wizard.

Minxin Yu - MSFT
- 2,234
- 1
- 3
- 14