I've achieved the detection of right click on listicon header (not possible with purebasic function) by subclassing the gadget but I'm surprised that it's working that way.
Look at the code, the right click event is triggered only on header? Why not in the entire listicon ?
Code: Select all
Global oldproc
Procedure SubClass_LV(hwnd, msg, wparam, lparam)
Protected result = CallWindowProc_(oldproc, hwnd, msg, wparam, lparam)
Protected *nmh.NMHDR
If msg = #WM_NOTIFY
*nmh = lparam
Select *nmh\code
Case #NM_RCLICK
Debug "rclick"
EndSelect
EndIf
; Another solution
; If msg = #WM_PARENTNOTIFY And wparam = #WM_RBUTTONDOWN
; Debug "rclick"
; EndIf
ProcedureReturn result
EndProcedure
If OpenWindow(0, 100, 100, 300, 100, "ListIcon Example", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
ListIconGadget(0, 5, 5, 290, 90, "Name", 100, #PB_ListIcon_FullRowSelect | #PB_ListIcon_AlwaysShowSelection)
AddGadgetColumn(0, 1, "Address", 250)
AddGadgetItem(0, -1, "Harry Rannit"+Chr(10)+"12 Parliament Way, Battle Street, By the Bay")
AddGadgetItem(0, -1, "Ginger Brokeit"+Chr(10)+"130 PureBasic Road, BigTown, CodeCity")
oldproc = SetWindowLongPtr_(GadgetID(ListView_ConsoleRA), #GWL_WNDPROC, @SubClass_LV())
Repeat
Event = WaitWindowEvent()
Until Event = #PB_Event_CloseWindow
EndIf