The following code creates a dialog with a canvas on it. When resizing the window I get a #PB_Event_SizeWindow, so far so good. Processing this within the event loop works as usual: it is called after releasing the left button on the mouse. Usually I can circumvent this by binding the event via BindEvent, then it is processed whenever the window is resized, even while holding the mousebutton. This doesn't work if I create my canvas on a window with the dialog library: The function is called, but the canvas is not redrawn.
Code: Select all
Runtime Enumeration Gadgets
#Canvas
EndEnumeration
Procedure ResizeHandler()
StartDrawing(CanvasOutput(#Canvas))
Box(0,0,GadgetWidth(#Canvas),GadgetHeight(#Canvas),GetSysColor_(#COLOR_BTNFACE))
StopDrawing()
EndProcedure
XML$ = "<window id='#PB_Any' name='test' width='300' height='400' flags='#PB_Window_SizeGadget | #PB_Window_SystemMenu | #PB_Window_ScreenCentered'>"+
"<canvas id='#Canvas'/>"+
"</window>"
ParseXML(0, XML$)
CreateDialog(0)
OpenXMLDialog(0, 0, "test")
MainWindow=DialogWindow(0)
ResizeHandler()
BindEvent(#PB_Event_SizeWindow,@ResizeHandler(),MainWindow)
Repeat
Event = WaitWindowEvent()
Until Event = #PB_Event_CloseWindow
For comparison, the same done with normal controls:
Code: Select all
Runtime Enumeration Gadgets
#Canvas
EndEnumeration
Procedure ResizeHandler()
Debug ElapsedMilliseconds()
StartDrawing(CanvasOutput(#Canvas))
Box(0,0,GadgetWidth(#Canvas),GadgetHeight(#Canvas),GetSysColor_(#COLOR_BTNFACE))
StopDrawing()
EndProcedure
OpenWindow(0,0,0,300,400,"Test",#PB_Window_ScreenCentered | #PB_Window_SystemMenu | #PB_Window_SizeGadget)
CanvasGadget(#Canvas,10,10,280,380)
ResizeHandler()
BindEvent(#PB_Event_SizeWindow,@ResizeHandler(),MainWindow)
Repeat
Event = WaitWindowEvent()
Until Event = #PB_Event_CloseWindow