Drawing on a Window is overwritten

Just starting out? Need help? Post your questions and find answers here.
Niffo
Enthusiast
Enthusiast
Posts: 504
Joined: Tue Jan 31, 2006 9:43 am
Location: France

Drawing on a Window is overwritten

Post by Niffo »

OpenWindow(0, 100, 100, 300, 200, "Test")

StartDrawing(WindowOutput(0))
Box(50, 50, 50, 50, 0)
StopDrawing()

Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
Niffo
Fred
Administrator
Administrator
Posts: 18224
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: [5.10b5] Drawing on a Window is overwritten

Post by Fred »

You need to handle the #PB_Window_Repaint event, you can't known when the OS will ask for refresh.
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Re: Drawing on a Window is overwritten

Post by ts-soft »

example:

Code: Select all

OpenWindow(0, 100, 100, 300, 200, "Test")

Repeat
  Select WaitWindowEvent()
    Case #PB_Event_CloseWindow
      Break
    Case #PB_Event_Repaint
      StartDrawing(WindowOutput(0))
      Box(50, 50, 50, 50, 0)
      StopDrawing()      
  EndSelect
ForEver
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
Image
WilliamL
Addict
Addict
Posts: 1252
Joined: Mon Aug 04, 2008 10:56 pm
Location: Seattle, USA

Re: Drawing on a Window is overwritten

Post by WilliamL »

I make the drawing part of the window a procedure then just call it when I first show the window and then when the repaint event happens. If the repaint event is called by opening the window then you will only have to call the drawing procedure by the event.

I had a posting about this somewhere but I can't find it now...
MacBook Pro-M1 (2021), Sequoia 15.4, PB 6.20
Post Reply