Gadget flickering

Everything else that doesn't fall into one of the other PB categories.
halo
Enthusiast
Enthusiast
Posts: 104
Joined: Mon Jan 26, 2004 2:49 am

Gadget flickering

Post 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?
LarsG
Enthusiast
Enthusiast
Posts: 713
Joined: Mon Jun 02, 2003 1:06 pm
Location: Norway
Contact:

Post 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:

AMD Athlon XP2400, 512 MB RAM, Hercules 3D Prophet 9600 256MB RAM, WinXP
PIII 800MHz, 320 MB RAM, Nvidia Riva Tnt 2 Mach 64 (32MB), WinXP + Linux
17" iMac, 1.8 GHz G5, 512 MB DDR-RAM, 80 GB HD, 64 MB Geforce FX 5200, SuperDrive, OSX
Fred
Administrator
Administrator
Posts: 18162
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Post 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.
El_Choni
TailBite Expert
TailBite Expert
Posts: 1007
Joined: Fri Apr 25, 2003 6:09 pm
Location: Spain

Post 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)
El_Choni
halo
Enthusiast
Enthusiast
Posts: 104
Joined: Mon Jan 26, 2004 2:49 am

Post 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.
User avatar
Paul
PureBasic Expert
PureBasic Expert
Posts: 1282
Joined: Fri Apr 25, 2003 4:34 pm
Location: Canada
Contact:

Post 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.
thefool
Always Here
Always Here
Posts: 5875
Joined: Sat Aug 30, 2003 5:58 pm
Location: Denmark

Post by thefool »

i belive you do something wrong. i have seen absolutely no flickering with pb programs. Not even 1 time.
halo
Enthusiast
Enthusiast
Posts: 104
Joined: Mon Jan 26, 2004 2:49 am

Post 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  
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Post 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?
PolyVector
Enthusiast
Enthusiast
Posts: 499
Joined: Wed Sep 17, 2003 9:17 pm
Location: Southern California
Contact:

Post 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
thefool
Always Here
Always Here
Posts: 5875
Joined: Sat Aug 30, 2003 5:58 pm
Location: Denmark

Post by thefool »

im using xp pro too. No flickering here.
User avatar
DoubleDutch
Addict
Addict
Posts: 3220
Joined: Thu Aug 07, 2003 7:01 pm
Location: United Kingdom
Contact:

Post 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
Sparkie
PureBatMan Forever
PureBatMan Forever
Posts: 2307
Joined: Tue Feb 10, 2004 3:07 am
Location: Ohio, USA

Post 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 :?
What goes around comes around.

PB 5.21 LTS (x86) - Windows 8.1
User avatar
NoahPhense
Addict
Addict
Posts: 1999
Joined: Thu Oct 16, 2003 8:30 pm
Location: North Florida

..

Post 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 ..
Sparkie
PureBatMan Forever
PureBatMan Forever
Posts: 2307
Joined: Tue Feb 10, 2004 3:07 am
Location: Ohio, USA

Post 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.
What goes around comes around.

PB 5.21 LTS (x86) - Windows 8.1
Post Reply