I use ButtonImageGadgets inside a CanvasGadget container that itself sits within a ContainerGadget.
When the window is resized or the splitter moved, the ButtonImageGadget sometimes loses its image. Moving the mouse over the gadget restores the image. RedrawWindow_() makes it a little better, but it still happens.
Does anyone have any ideas? This only happens on Windows.
Code: Select all
Enumeration
#Container
#Canvas
#String
#Button
#Splitter
EndEnumeration
Procedure DrawCanvas()
If StartDrawing(CanvasOutput(#Canvas))
Box(0, 0, OutputWidth(), OutputHeight(), RGB(220, 220, 220))
DrawingMode(#PB_2DDrawing_Transparent)
DrawText(10, 60, "Hello World")
StopDrawing()
EndIf
EndProcedure
Procedure OnWindowSized()
ResizeGadget(#Splitter, #PB_Ignore, #PB_Ignore, WindowWidth(0), WindowHeight(0))
EndProcedure
Procedure OnContainerResized()
ResizeGadget(#Canvas, #PB_Ignore, #PB_Ignore, GadgetWidth(#Container), GadgetHeight(#Container))
RedrawWindow_(GadgetID(#Button), 0, 0, #RDW_INVALIDATE)
DrawCanvas()
EndProcedure
CreateImage(0, 16, 16, 24, #Blue)
If OpenWindow(0, 0, 0, 640, 480, "", #PB_Window_SystemMenu | #PB_Window_ScreenCentered | #PB_Window_SizeGadget)
BindEvent(#PB_Event_SizeWindow, @OnWindowSized(), 0)
StringGadget(#String, 0, 0, 10, 10, "...")
ContainerGadget(#Container, 0, 0, 100, 100)
CanvasGadget(#Canvas, 0, 0, GadgetWidth(#Container), GadgetHeight(#Container), #PB_Canvas_Container)
ButtonImageGadget(#Button, 10, 10, 25, 25, ImageID(0))
CloseGadgetList()
CloseGadgetList()
SplitterGadget(#Splitter, 0, 0, 640, 480, #String, #Container, #PB_Splitter_Vertical)
BindGadgetEvent(#Container, @OnContainerResized(), #PB_EventType_Resize)
PostEvent(#PB_Event_Gadget, 0, #Container, #PB_EventType_Resize)
Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf