Page 1 of 4

Gadget flickering

Posted: Fri Jun 25, 2004 6:13 am
by halo
Every PB app I have ever seen has severe flickering when the window is resized. I used a SetWindowCallback @...etc., but it still happens. How can I make this stop?

Posted: Fri Jun 25, 2004 8:13 am
by LarsG
Perhaps you should check your message handling in the callback... You might be redrawing the window while it's resizing or something..
(just a thought that struck me) :roll:

Posted: Fri Jun 25, 2004 11:56 am
by Fred
To prevent whole window clear, you have to process the WM_ERASEBKGND message and return a null brush. But you will have to handle all the refresh yourself then.

Posted: Fri Jun 25, 2004 12:31 pm
by El_Choni
You can also try this to prevent gadget flickering:

Code: Select all

SetWindowLong_(WindowID(), #GWL_STYLE, GetWindowLong_(WindowID(), #GWL_STYLE)|#WS_CLIPCHILDREN)

Posted: Sun Jun 27, 2004 7:21 pm
by halo
That's kind of lame that PB can't make a window without extreme flickering. I experience this in EVERY pb app, including the editor, but don't get it with any other windows program. Maybe the developer should consider a command like the BlitzPlus SetGadgetLayout(), where you can lock the edges of a gadget to one side of the parent window.

Posted: Sun Jun 27, 2004 9:39 pm
by Paul
If you experience "flickering" it is because that is the way you have programmed it. It is up to the programmer to deal wth how the window and gadgets are redrawn when they are resized.
The easiest way is of course to just send a refresh, which is what will give you the flicker effect because everything is redrawn (and in a callback it can be redrawn hundreds of times a second). Since this is the easiest way, you will see everyone use this method. If you actually take the time to deal with it better, you can eliminate this.

By the way, running the BlitzPlus demo with a resizable form with gadgets on it... I also see flickering. Especially if you add a statusbar to the bottom.

Posted: Sun Jun 27, 2004 10:09 pm
by thefool
i belive you do something wrong. i have seen absolutely no flickering with pb programs. Not even 1 time.

Posted: Mon Jun 28, 2004 1:25 am
by halo
Well if that's the case, then the PureBasic IDE is programmed wrong, too.

Just look at this sample. When you resize the window, the whole window flashes on and off:

Code: Select all

;
; ------------------------------------------------------------
;
;   PureBasic - Gadget example file
;
;    (c) 2003 - Fantaisie Software
;
; ------------------------------------------------------------
;

#WindowWidth  = 640
#WindowHeight = 480


If OpenWindow(0, 0, 0, #WindowWidth, #WindowHeight, #PB_Window_SystemMenu | #PB_Window_ScreenCentered | #PB_Window_SizeGadget, "PureBasic - Gadget Demonstration")

  If CreateGadgetList(WindowID())
    TextGadget(7, 10, 5, 700, 15, "PureBasic splitter demonstation with Editor, ScrollArea, ExplorerTree and Web gadgets. Feel the power...")

    WebGadget(0, 10, 10, 300, 20, "http://www.purebasic.com")
    
    EditorGadget(1, 115, 10, 100, 190)
    For k=1 To 10
      AddGadgetItem(1, k-1, "Line "+Str(k))
    Next

    ExplorerTreeGadget(3, 115, 10, 100, 190, "", #PB_Explorer_AlwaysShowSelection|#PB_Explorer_FullRowSelect|#PB_Explorer_MultiSelect)

    ScrollAreaGadget(6, 0, 0, 400, 400, 1000, 1000, 1)
      ButtonGadget(20, 20, 20, 200, 200, "Scroll Area !")
    CloseGadgetList()
    
    SplitterGadget(2, 0, 0, #WindowWidth/2, #WindowHeight/2, 1, 0)
    SplitterGadget(4, 0, 0, #WindowWidth, #WindowHeight, 3, 2, #PB_Splitter_Vertical)
    SplitterGadget(5, 0, 25, #WindowWidth, #WindowHeight-25, 4, 6, #PB_Splitter_Vertical)
    
    SetGadgetState(5, 500)
  EndIf
  

  Repeat
    EventID = WaitWindowEvent()
    
    If EventID = #PB_Event_Gadget
      
      Select EventGadgetID()

        Case 8
          SetGadgetState(5, 333)
          SetGadgetState(2, 333)
          SetGadgetState(11, 5)
          
        Case 20
          Debug "ok" 
          
      EndSelect
      
    ElseIf EventID = #PB_Event_SizeWindow
      ResizeGadget(5, -1, -1, WindowWidth(), WindowHeight()-25) ; Our 'master' splitter gadget
      
    EndIf

  
  Until EventID = #PB_EventCloseWindow

EndIf

End  

Posted: Mon Jun 28, 2004 1:31 am
by PB
> Just look at this sample. When you resize the window, the whole window flashes on and off

Doesn't flash on/off for me. Perhaps your video card needs updated drivers?

Posted: Mon Jun 28, 2004 6:41 am
by PolyVector
It flickers so badly when I resize it, that I see more background than gadgets.... and i have a GeForce 4...... Maybe it's the OS?... I'm using XP Pro

Posted: Mon Jun 28, 2004 7:26 am
by thefool
im using xp pro too. No flickering here.

Posted: Mon Jun 28, 2004 3:29 pm
by DoubleDutch
I can see the graphcis in some of the gadgets disappear (in the example above) before they are redrawn.

The problem appears to be with the WM_ERASEBKGND taking too long before the gadgets are redrawn.

The problem goes away when the WM_ERASEBKGND is intercepted, but then the screen looks slightly messy.

-Anthony

Posted: Mon Jun 28, 2004 4:00 pm
by Sparkie
Minimal flickering at work PC:
WinXP Home SP1
single monitor
cheapo onboard 32mb S3 video
XP visual settings make no difference

Nasty flickering on home PC:
WinXP Home SP1
dual monitor
#1 AGP 32mb ATI All-In-Wonder Radeon
#2 PCI 32mb nVidia ???
XP visual settings make no difference (other than disabling *Show window contents while dragging*)

:x :?

..

Posted: Mon Jun 28, 2004 4:20 pm
by NoahPhense
zero flicker.. but then I don't need to view my box size as I'm dragging,
so it's turned off ... saves on system resources..

;)

- np

*edit*

I decided to try it, I turned on 'show contents while dragging' .. no flicker

** NVidia GeForce4 440 GO 128bit 64mb DDR **

It's probably your refresh rate.. turn it up ..

Posted: Mon Jun 28, 2004 4:38 pm
by Sparkie
zero flicker.. but then I don't need to view my box size as I'm dragging,
so it's turned off ... saves on system resources
I enable the XP eye candy because I want to see what others will see and it's my guess the average user (not programmer) has eye candy set high. :wink:

But now I'm not so sure what they'll see. :?
It's probably your refresh rate.. turn it up ..
I'll try this when I get home tonight.