Gadget flickering
- NoahPhense
- Addict
- Posts: 1999
- Joined: Thu Oct 16, 2003 8:30 pm
- Location: North Florida
..
I have the solution. It just need to be converted from another language.
- np
- np
Last edited by NoahPhense on Tue Jun 29, 2004 1:58 am, edited 2 times in total.
> I just tried the exact same code again, and now I get the same nasty
> flickering like my home PC.
Confirmed: Your original post is now flickering for me too! 8O
It's probably related to how intensive the CPU is working, because
I haven't done anything different to before, yet before it didn't
flicker for me either. Weird. To me, the "flickering" looks a bit
like "mouse pointer trails", if you've ever seen those, but done
to the window instead of the mouse. I haven't changed my screen
resolution, refresh rate, or any other display settings. Strange!
> flickering like my home PC.
Confirmed: Your original post is now flickering for me too! 8O
It's probably related to how intensive the CPU is working, because
I haven't done anything different to before, yet before it didn't
flicker for me either. Weird. To me, the "flickering" looks a bit
like "mouse pointer trails", if you've ever seen those, but done
to the window instead of the mouse. I haven't changed my screen
resolution, refresh rate, or any other display settings. Strange!
-
- Enthusiast
- Posts: 499
- Joined: Wed Sep 17, 2003 9:17 pm
- Location: Southern California
- Contact:
I was tinkering with my 'solution' trying to get it to work for my SkinBuilder app I'm designing... this thing is far more complicated (and flickers far more) than the example apps here...
Best solution to date (for me):
When processing the #PB_Event_SizeWindow event, resize all your gadgets as you normally would.
Then, insert this line at the very end of your size routine:
This is a bit inefficient since some of the window/gadgets have already been drawn, but maybe someone can optimize it?
Edit:
This works just as well (and it's easier on the keyboard) :
Best solution to date (for me):
When processing the #PB_Event_SizeWindow event, resize all your gadgets as you normally would.
Then, insert this line at the very end of your size routine:
Code: Select all
RedrawWindow_(WindowID(#Window_Main),0,0,#RDW_INTERNALPAINT|#RDW_UPDATENOW)
Edit:
This works just as well (and it's easier on the keyboard) :
Code: Select all
UpdateWindow_(WindowID())
Last edited by PolyVector on Tue Jun 29, 2004 6:25 am, edited 2 times in total.
- NoahPhense
- Addict
- Posts: 1999
- Joined: Thu Oct 16, 2003 8:30 pm
- Location: North Florida
..
Try this..
...
full listing
Question, has anyone tried what Fred has suggested on page 1?
- np
Code: Select all
SetWindowLong_(WindowID(#Window_0), #GWL_EXSTYLE, GetWindowLong_(WindowID(#Window_0), #GWL_EXSTYLE) | $02000000) ; #WS_EX_COMPOSITED)
full listing
Code: Select all
Declare Resize()
Enumeration
#Window_0
EndEnumeration
Enumeration
#Listview_0
#String_0
#Button_0
#Text_0
EndEnumeration
; don't really need to be global..
Global cx.l, cy.l, wpi.l, f.l
Procedure Open_Window_0()
If OpenWindow(#Window_0, 311, 255, 596, 292, #PB_Window_SystemMenu | #PB_Window_SizeGadget | #PB_Window_TitleBar | #PB_Window_ScreenCentered , "blah..")
; **
SetWindowLong_(WindowID(#Window_0), #GWL_EXSTYLE, GetWindowLong_(WindowID(#Window_0), #GWL_EXSTYLE) | $02000000) ; #WS_EX_COMPOSITED)
If CreateGadgetList(WindowID())
ListViewGadget(#Listview_0, 0, 5, 290, 175)
StringGadget(#String_0, 300, 5, 295, 175, "")
ButtonGadget(#Button_0, 5, 185, 285, 105, "")
TextGadget(#Text_0, 325, 205, 155, 30, "This is a test...")
ReSize()
EndIf
EndIf
EndProcedure
Open_Window_0()
Repeat
Event = WaitWindowEvent()
If Event = #PB_EventGadget
; Debug "WindowID: " + Str(EventWindowID())
GadgetID = EventGadgetID()
If GadgetID = #Listview_0
;
ElseIf GadgetID = #String_0
;
ElseIf GadgetID = #Button_0
;
EndIf
ElseIf Event = #PB_Event_SizeWindow
ReSize()
EndIf
Until Event = #PB_EventCloseWindow
End
;
Procedure ReSize()
f = #SWP_NOACTIVATE|#SWP_NOZORDER
cy = WindowHeight()
cx = WindowWidth()
hw = cx/2
hh = cy/2
wpi = BeginDeferWindowPos_(4) ; Pass the number of windows To be re-sized
; Params For DeferWindowPos
; 1) The value passed from BeginDeferWindowPos
; 2) The Window handle (retrieved from GetDlgItem)
; 3) A value specifing 'Z-order' (ignored here)
; 4) x,y,w,h of window
; 5) Flags (the values in 'f' seem To work best
DeferWindowPos_(wpi,GetDlgItem_(WindowID(#Window_0),0),0,0,0,hw,hh,f)
DeferWindowPos_(wpi,GetDlgItem_(WindowID(#Window_0),1),0,hw+1,0,(cx-(hw+1)),hh,f)
DeferWindowPos_(wpi,GetDlgItem_(WindowID(#Window_0),2),0,0,hh+1,hw,cy-(hh+1),f)
DeferWindowPos_(wpi,GetDlgItem_(WindowID(#Window_0),3),0,hw+1,hh+1,(cx-(hw+1)),cy-(hh+1),f)
EndDeferWindowPos_(wpi)
wpi = 0 ; clearit
EndProcedure
- np
-
- Enthusiast
- Posts: 499
- Joined: Wed Sep 17, 2003 9:17 pm
- Location: Southern California
- Contact:
@NoahPhense
Your code updates HORRIBLY slow when the window is large on my computer... If I take out this line, it solves the major slowdown, but flickering still occurs...
I do, however, like the DeferWindowPos_() part... I'll be using it 
I did try Fred's method when he posted it, but couldn't get it to work correctly...
Your code updates HORRIBLY slow when the window is large on my computer... If I take out this line, it solves the major slowdown, but flickering still occurs...
Code: Select all
SetWindowLong_(WindowID(#Window_0), #GWL_EXSTYLE, GetWindowLong_(WindowID(#Window_0), #GWL_EXSTYLE) | $02000000) ; #WS_EX_COMPOSITED)

I did try Fred's method when he posted it, but couldn't get it to work correctly...
- DoubleDutch
- Addict
- Posts: 3220
- Joined: Thu Aug 07, 2003 7:01 pm
- Location: United Kingdom
- Contact:
I treid freds method on my ConsoleX library - it flickered on resize on my machine.
It stopped the flicker completely. This was a resizing window screen.
But if you try it with gadgets it seem to still flicker.
Code: Select all
If Message=#WM_ERASEBKGND
Result=-1 ; or #NULL the result is the same...
EndIf
But if you try it with gadgets it seem to still flicker.

Has anybody tried adding #WS_CLIPCHILDREN to the window #GWL_STYLE, as I suggested? (I think OpenWindow should use it by default)
Has always worked for me.Excludes the area occupied by child windows [gadgets] when drawing occurs within the parent window. This style is used when creating the parent window.
El_Choni
- NoahPhense
- Addict
- Posts: 1999
- Joined: Thu Oct 16, 2003 8:30 pm
- Location: North Florida
..
I tried it. Can't say if it worked or not. Because I've yet to encounterEl_Choni wrote:Has anybody tried adding #WS_CLIPCHILDREN to the window #GWL_STYLE, as I suggested? (I think OpenWindow should use it by default)
Has always worked for me.Excludes the area occupied by child windows [gadgets] when drawing occurs within the parent window. This style is used when creating the parent window.
any flicker on any window, yet..

- np
- NoahPhense
- Addict
- Posts: 1999
- Joined: Thu Oct 16, 2003 8:30 pm
- Location: North Florida
..
No I just meant that I don't have flickering, so it's hard for me to codehalo wrote:There shouldn't be anything wrong with the code. I did not write this. I just copied it out of the "samples" directory because I knew it would flicker, just like every other PureBasic program I run.
for something I cannot see. But I'm still trying..

- np
Try this out.. lemme know what happens:
no_flicker.rar
-
- Enthusiast
- Posts: 499
- Joined: Wed Sep 17, 2003 9:17 pm
- Location: Southern California
- Contact:
I Know what the problem was with using WS_CLIPCHILDREN... you can't simply use it on the main window... you must use it on all gadgets that are parents of anything that gets resized... When you do this, there is absolutly no flickering!Has anybody tried adding #WS_CLIPCHILDREN to the window #GWL_STYLE, as I suggested? (I think OpenWindow should use it by default)

Code: Select all
Procedure ReduceFlicker_Enum(handle.l,Param.l)
SetWindowLong_(handle,#GWL_STYLE,GetWindowLong_(handle,#GWL_STYLE)|#WS_CLIPCHILDREN)
ProcedureReturn #True
EndProcedure
Procedure ReduceFlicker(WindowNumber.l)
ReduceFlicker_Enum(WindowID(WindowNumber),0)
EnumChildWindows_(WindowID(WindowNumber),@ReduceFlicker_Enum(),0)
EndProcedure
Then call UpdateWindow_(WindowID(WindowNum)) after you resize all your gadgets on the #PB_Event_SizeWindow event...
It has near-perfect results for me... Although there is some garbling on some things...hrmmmmm
- tinman
- PureBasic Expert
- Posts: 1102
- Joined: Sat Apr 26, 2003 4:56 pm
- Location: Level 5 of Robot Hell
- Contact:
Putting
around your resize code seems to help here although there is still some slight flickering on my system.
@PolyVector: are there any problems making all gadgets have the clipchildren style? Is it safe to use on gadgets which have no children?
Code: Select all
LockWindowUpdate_(WindowID())
...
LockWindowUpdate_(0)
UpdateWindow_(WindowID())
@PolyVector: are there any problems making all gadgets have the clipchildren style? Is it safe to use on gadgets which have no children?
If you paint your butt blue and glue the hole shut you just themed your ass but lost the functionality.
(WinXPhSP3 PB5.20b14)
(WinXPhSP3 PB5.20b14)
- DoubleDutch
- Addict
- Posts: 3220
- Joined: Thu Aug 07, 2003 7:01 pm
- Location: United Kingdom
- Contact:
This method works great... 
UNLESS
your using "PanelGadget":(
With PanelGadget the backgound of the PanelGadget is not erased on resize when you use your modification.
Is panelgadget created by PureBasic or Windows itself?
If its by PureBasic, FRED can u look into this? FRED, if you want to see what I mean I can send you an exe.
-Anthony

UNLESS
your using "PanelGadget":(
With PanelGadget the backgound of the PanelGadget is not erased on resize when you use your modification.
Is panelgadget created by PureBasic or Windows itself?
If its by PureBasic, FRED can u look into this? FRED, if you want to see what I mean I can send you an exe.
-Anthony
- DoubleDutch
- Addict
- Posts: 3220
- Joined: Thu Aug 07, 2003 7:01 pm
- Location: United Kingdom
- Contact: