CanvasGadget change background color
Posted: Sun Jun 01, 2014 9:04 pm
CanvasGadget - change background color !
For fixing many flickering problems
For fixing many flickering problems
http://www.purebasic.com
https://www.purebasic.fr/english/
I use different background colors, but I have no flickering problems.walbus wrote:many flickering problems
Code: Select all
OpenWindow(0,300,300,600,600,"",#PB_Window_SystemMenu | #PB_Window_SizeGadget)
CanvasGadget(0,0,0,600,600)
StartDrawing(CanvasOutput(0))
Box(0,0,WindowWidth(0),WindowHeight(0),RGB(0,0,255))
StopDrawing()
min_win_x=300 : min_win_y=300 : max_win_x=1200 : max_win_y=1200
WindowBounds(0,min_win_x,min_win_y-MenuHeight(),max_win_x,max_win_y-MenuHeight()) ; Min and max window
Global win_resized
Procedure SizeWindowHandler()
Shared max_win_x,max_win_y
If EventWindow()=0 ; Window 0
If Not win_resized
CanvasGadget(0,0,0,max_win_x,max_win_y) ; Flicker fix
StartDrawing(CanvasOutput(0))
Box(0,0,max_win_x,max_win_y,RGB(0,0,255))
StopDrawing()
EndIf
win_resized=1
EndIf
EndProcedure
BindEvent (#PB_Event_SizeWindow,@SizeWindowHandler())
Repeat
If win_resized
win_resized=0
CanvasGadget(0,0,0,WindowWidth(0),WindowHeight(0))
StartDrawing(CanvasOutput(0))
Box(0,0,WindowWidth(0),WindowHeight(0),RGB(0,0,255))
StopDrawing()
EndIf
Until WaitWindowEvent()=#PB_Event_CloseWindow
Code: Select all
Enumeration
#Window
#Gadget
EndEnumeration
Procedure SizeWindowHandler()
ResizeGadget(#Gadget, 0, 0, WindowWidth(#Window), WindowHeight(#Window))
If StartDrawing(CanvasOutput(#Gadget))
Box(0, 0, OutputWidth(), OutputHeight(), RGB(0,0,255))
StopDrawing()
EndIf
EndProcedure
OpenWindow(#Window, 300, 300, 600, 600, "Canvas Example", #PB_Window_SystemMenu|#PB_Window_SizeGadget|#PB_Window_ScreenCentered)
WindowBounds(#Window, 300, 300, 1200, 1200)
CanvasGadget(#Gadget,0,0,600,600)
SizeWindowHandler()
BindEvent(#PB_Event_SizeWindow, @SizeWindowHandler(), #Window)
Repeat
Until WaitWindowEvent()=#PB_Event_CloseWindow