Page 1 of 1

Drawing on black background

Posted: Tue Oct 12, 2010 2:43 am
by urland
Drawing on an opened window with the default background color works but changing the window background color to black prevents things like Box() from showing. Is this a Windows thing? I'm using XP Pro SP3, PB 4.51

Code: Select all

If OpenWindow(0,0,0,400,300,"Test")
   SetWindowColor(0,RGB(0,0,0))
   StartDrawing(WindowOutput(0))
   DrawingMode(#PB_2DDrawing_Outlined)
   Box(20,20,350,250,RGB(255,255,255))
   StopDrawing()
   While WaitWindowEvent() <> #PB_Event_CloseWindow
   Wend
EndIf
Thank you.

Re: Drawing on black background

Posted: Tue Oct 12, 2010 3:42 am
by netmaestro
Your difficulty is in event handling. SetWindowColor() causes an invalidation of the window DC, preventing the shortcut of drawing to the window before handling events. Here is the proper way to draw to WindowOutput() with persistence:

Code: Select all

If OpenWindow(0,0,0,400,300,"Test")
  SetWindowColor(0,RGB(0,0,0))
  Repeat
    ev = WaitWindowEvent() 
    If ev= #PB_Event_Repaint
      StartDrawing(WindowOutput(0))
        DrawingMode(#PB_2DDrawing_Outlined)
        Box(20,20,350,250,RGB(255,255,255))
      StopDrawing()
    EndIf
  Until ev = #PB_Event_CloseWindow
EndIf

Re: Drawing on black background

Posted: Tue Oct 12, 2010 4:10 am
by urland
Thank you for your help. Much appreciated.