I know that some functions doesn't need callbacks and I am now working on a project where I want to avoid using them..
so, here is the code I want to have without callback:
Code: Select all
#TVGN_DROPHILITE = 8
Procedure WinCallback(hwnd, msg, wparam, lparam)
result = #PB_ProcessPureBasicEvents
Select msg
Case #WM_NOTIFY
*pnmhdr.NMHDR = lparam
; --> If TreeGadget receives a right click, select the item
If *pnmhdr\hwndFrom = GadgetID(0) And *pnmhdr\code = #NM_RCLICK
; --> hItem = The handle to item that has been right clicked
hItem = SendMessage_(*pnmhdr\hwndFrom, #TVM_GETNEXTITEM, #TVGN_DROPHILITE, 0)
; --> Select that item
SendMessage_(*pnmhdr\hwndFrom, #TVM_SELECTITEM, #TVGN_CARET, hItem)
EndIf
EndSelect
ProcedureReturn result
EndProcedure
If OpenWindow(0, 0, 0, 350, 200, #PB_Window_SystemMenu | #PB_Window_ScreenCentered, "Sparkies TreeGadget - Right Click Selects") And CreateGadgetList(WindowID(0))
TreeGadget(0, 10, 10, 180, 180)
For i = 0 To 5
AddGadgetItem (0, -1, "Item "+ Str(i))
AddGadgetItem (0, -1, "Parent " + Str(i))
OpenTreeGadgetNode(0)
AddGadgetItem(0, -1, "Sub Item 1")
AddGadgetItem(0, -1, "Sub Item 2")
AddGadgetItem(0, -1, "Sub Item 3")
AddGadgetItem(0, -1, "Sub Item 4")
CloseTreeGadgetNode(0)
Next
SetWindowCallback(@WinCallback())
Repeat
event = WaitWindowEvent()
Until event = #PB_Event_CloseWindow
EndIf
End
I just want to avoid using a callback, please don't ask why.
Thanks!