PlanetSquires Forums

Support Forums => WinFBX - Windows Framework for FreeBASIC => Topic started by: Paul Squires on March 05, 2020, 11:36:17 AM

Title: TreeView subclass (WM_LBUTTONUP)
Post by: Paul Squires on March 05, 2020, 11:36:17 AM
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.


Title: Re: TreeView subclass (WM_LBUTTONUP)
Post by: Josť Roca on March 05, 2020, 12:22:40 PM
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.

Code: [Select]
   ' // 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
                  )
Title: Re: TreeView subclass (WM_LBUTTONUP)
Post by: Paul Squires on March 05, 2020, 12:38:37 PM
Awesome! Thanks Jose - that worked perfectly.
Really appreciate it.