PlanetSquires Forums

Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: TreeView subclass (WM_LBUTTONUP)  (Read 156 times)

Paul Squires

  • Administrator
  • Guru Member
  • *****
  • Posts: 9206
  • Windows 10
    • PlanetSquires Software
TreeView subclass (WM_LBUTTONUP)
« 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.


Logged
Paul Squires
PlanetSquires Software
WinFBE Editor and Visual Designer

Josť Roca

  • Moderator
  • Guru Member
  • *****
  • Posts: 3255
Re: TreeView subclass (WM_LBUTTONUP)
« Reply #1 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
                  )

Paul Squires

  • Administrator
  • Guru Member
  • *****
  • Posts: 9206
  • Windows 10
    • PlanetSquires Software
Re: TreeView subclass (WM_LBUTTONUP)
« Reply #2 on: March 05, 2020, 12:38:37 PM »

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

Logged
Paul Squires
PlanetSquires Software
WinFBE Editor and Visual Designer