PB list in win32 enumeration callback?
Posted: Tue Jun 13, 2023 3:47 am
Any way to make this work without an extra container structure? Too bad it is not supported. It does compile, just errors out because it passes the value of the list element, instead of the list object itself (which PB does do in a normal procudure call).
Code: Select all
EnableExplicit
Structure Window
Handle.i
Title.s
EndStructure
Procedure EnumProc(hw, List lp.Window())
If IsWindowVisible_(hw)
AddElement(lp())
lp()\Handle = hw
;...
EndIf
ProcedureReturn #True
EndProcedure
Procedure EnumProc2(hw, List *lp.Window())
If IsWindowVisible_(hw)
AddElement(*lp())
Define *s.Window = AllocateStructure(Window)
*s\Handle = hw
;...
*lp() = *s
EndIf
ProcedureReturn #True
EndProcedure
NewList wlist.Window()
; Global w.Window
; w\Handle = 1
; w\Title = "Test"
; AddElement(wlist())
; wlist() = w
; EnumWindows_(@EnumProc(), wlist())
NewList *wlist.Window()
EnumProc2(GetDesktopWindow_(), *wlist()) ; works fine
EnumWindows_(@EnumProc2(), *wlist()) ; crashes because the list is not provided