• Welcome to PlanetSquires Forums.
 

TreeView subclass (WM_LBUTTONUP)

Started by Paul Squires, March 05, 2020, 11:36:17 AM

Previous topic - Next topic

Paul Squires

Maybe someone might know the answer. Please see the attached project. It is based on Jose's TreeView template code but with the addition of a subclass in order to intercept the Mouse messages. I noticed in my larger project that I could not get the WM_LBUTTONUP message when the mouse is clicked on the node label/text. Anywhere else on the node and elsewhere on the tree I can get the WM_LBUTTONUP message. The WM_LBUTTONDOWN message fires in all cases. The attached sample project illustrates this behaviour.

My feeling is that when the mouse down fires that maybe the treeview itself captures the mouse in order to deal with things like drag/drop or initiating label editing and that's why I never get the WM_LBUTTONUP message. I might try looking for the message in the raw message handler to see if such a message is ever sent to the message queue.

If anyone has any insights on this then that'd be great.


Paul Squires
PlanetSquires Software
WinFBE Editor and Visual Designer

José Roca

Include the TVS_DISABLEDRAGDROP style. If TVS_DISABLEDRAGDROP is not set, SysTreeView32 eats the WM_LBUTTONUP message if an item's state image, icon or label is clicked.


   ' // Add a TreeView
   DIM hTreeView AS HWND
   DIM dwStyle AS DWORD = WS_VISIBLE OR WS_BORDER OR WS_TABSTOP OR TVS_HASBUTTONS OR TVS_HASLINES OR _
       TVS_LINESATROOT OR TVS_SHOWSELALWAYS OR TVS_DISABLEDRAGDROP
   hTreeView = pWindow.AddControl( _
                  "TreeView", , IDC_TREEVIEW, "", _
                  0, 0, 0, 0, dwStyle, -1, 0, _
                  Cast(SUBCLASSPROC, @TreeViewSubclassProc), _   ' // Address of the window callback procedure
                  IDC_TREEVIEW, _                   ' // The subclass ID
                  Cast(DWORD_PTR, 0) _              ' // Pointer to reference data
                  )


Paul Squires

Awesome! Thanks Jose - that worked perfectly.
Really appreciate it.

Paul Squires
PlanetSquires Software
WinFBE Editor and Visual Designer