I finally got to select TreeView items with the right mouse button (RMB).
I include Window Callback (might be not necessary) and a PopUpMenu to test it.
Code: Select all
Global RMB.l,hWnd.l
Procedure.l MyWindowCallBack(WindowID.l,Message.l,wParam.l,lParam.l)
If WindowID=hWnd And Message=#WM_CONTEXTMENU ;detect RMB click inside main window
RMB=lParam
EndIf
ProcedureReturn #PB_ProcessPureBasicEvents
EndProcedure
If CreatePopupMenu(0)
MenuItem(1, "opt1...")
MenuBar()
MenuItem(2, "opt2...")
EndIf
hWnd=OpenWindow(0,200,200,150,420,"Title",#PB_Window_SizeGadget|#PB_Window_MaximizeGadget|#PB_Window_MinimizeGadget)
TreeGadget(1,0,0,150,420)
For t=1 To 30
AddGadgetItem(1,-1,"item"+Hex(t))
Next
SetWindowCallback(@MyWindowCallBack())
Repeat
EventID.l=WaitWindowEvent()
Select EventID
Case #PB_Event_Gadget
Select EventGadget()
Case 1;
If RMB
var.TV_HITTESTINFO\pt\y=RMB>>16-WindowY(0)-$18
SendMessage_(GadgetID(1),#TVM_HITTEST,0,var)
SendMessage_(GadgetID(1),#TVM_SELECTITEM,#TVGN_CARET,var\hItem)
DisplayPopupMenu(0,hWnd)
RMB=0
EndIf
EndSelect
EndSelect
Until EventID=#PB_Event_CloseWindow
Nobody can hate WinAPI incoherences like me

AL