Code: Select all
Procedure.l _CompareFunc(lParam1.l, lParam2.l, lParamSort.l)
 ;only for testing - I give out the parameters
 Debug "------------------"
 Debug lParam1 ;should not be zero...
 Debug lParam2 ;should not be zero...
 Debug lParamSort ;my own parameter - this one works...
 ProcedureReturn 1 ;only for testing - give something back - this works too
EndProcedure
Structure TVSORTCB
 hParent.l
 lpfnCompare.l
 lParam.l
EndStructure
DefType.TVSORTCB psort
If OpenWindow(0, 264, 183, 491, 377, #PB_Window_SystemMenu | #PB_Window_TitleBar | #PB_Window_ScreenCentered , "SortTree")=0
 End
EndIf
If CreateGadgetList(WindowID())=0
 End
EndIf
TreeGadget(1, 10, 70, 470, 300)
VHndl=AddGadgetItem (1, -1, "Root")
OpenTreeGadgetNode(1)
AddGadgetItem (1, -1, "Zenia")
AddGadgetItem (1, -1, "Michael")
AddGadgetItem (1, -1, "Andy")
AddGadgetItem (1, -1, "Chris")
CloseTreeGadgetNode(1)
ButtonGadget(2, 10, 10, 40, 20, "Sort")
While EventGadgetID()<>2 ;very easy event trapping - only for testing
 WaitWindowEvent()
Wend
psort\hParent=VHndl
psort\lpfnCompare=@_CompareFunc()
psort\lParam=5 ;my own parameter
;SendMessage_(GadgetID(1),#TVM_SORTCHILDREN,#False,VHndl)
;the message above works (like described by freak)
SendMessage_(GadgetID(1),#TVM_SORTCHILDRENCB,0,@psort)
While WindowEvent()<>#PB_Event_CloseWindow:Delay(1):Wend
End
Best Regards
Andy