|
-
February 8th, 2007, 08:41 AM
#1
Reduce flickering
Hey guys,
I am using a CListBoxEBX control from this project, DrawItem function is overriden.
http://www.codeguru.com/cpp/controls...cle.php/c4745/
When I fill this list box intensively with lots of items per second i see a lot of
flickering.
What are usual techniques in GDI area to reduce flickering as much as possible?
thanks
-
February 8th, 2007, 08:56 AM
#2
Re: Reduce flickering
One common technique is Double Buffering. You should find a lot of material on the Internet regarding this topic.
Har Har
-
February 8th, 2007, 08:56 AM
#3
Re: Reduce flickering
For controls like the Listbox, you can suspend updates while making multiple changes. I haven't tested this myself, but CWnd::LockWindowUpdate() and CWnd:UnlockWindowUpdate() seem to be what you're looking for. I'd be curious if this worked for you.
In .NET-land, you would use SuspendLayout() and ResumeLayout(), but there doesn't seem to be an equivalent in MFC.
-
February 8th, 2007, 09:13 AM
#4
Re: Reduce flickering
 Originally Posted by PadexArt
One common technique is Double Buffering. You should find a lot of material on the Internet regarding this topic.
Double Buffering of what, PadexArt?
-
February 8th, 2007, 09:44 AM
#5
Re: Reduce flickering
You might want to try CWnd::SetRedraw ().
Gort...Klaatu, Barada Nikto!
-
February 8th, 2007, 10:10 AM
#6
Re: Reduce flickering
 Originally Posted by Mike Harnad
You might want to try CWnd::SetRedraw ().
yes, before updating the list (either removal or adding an item) I disable redrawing and enable it after
-
February 8th, 2007, 10:15 AM
#7
Re: Reduce flickering
 Originally Posted by nazgul27
Double Buffering of what, PadexArt?
double buffering of your drawings. ..
First do all the drawings to a temp buffer. . and then. . write the tempbuffer to the DC. Result : no more filckering.
-
February 8th, 2007, 11:03 AM
#8
Re: Reduce flickering
Double buffering (or rather, offscreen drawing - double buffering is something else, strictly speaking ) would be overkill in this case, and totally unnecessary.
Like Mike said: Call SetRedraw(false) before inserting / removing items, and SetRedraw(true), follwed by Invalidate(), after you're done with your bulk item operation.
-
February 8th, 2007, 12:33 PM
#9
Re: Reduce flickering
Some form of optimizied drawing should be employed to ensure flickering is not affecting other operations ( such as scrolling). In some cases it is desirable to see something is happening but with a minimal flicker and SetRedraw cannot help there.
Har Har
-
February 8th, 2007, 12:49 PM
#10
Re: Reduce flickering
Have you tried using int InitStorage( int nItems, UINT nBytes ) with the number of items to speed up the loading process.
Jim
ATP BE400 CE500 (C550B-SPW) CE560XL MU300 CFI CFII
"The speed of non working code is irrelevant"... Of course that is just my opinion, I could be wrong.
"Nothing in the world can take the place of persistence. Talent will not; nothing is more common than unsuccessful men with talent. Genius will not; unrewarded genius is almost a proverb. Education will not; the world is full of educated derelicts. Persistence and determination are omnipotent. The slogan 'press on' has solved and always will solve the problems of the human race."...Calvin Coolidge 30th President of the USA.
-
February 8th, 2007, 02:21 PM
#11
Re: Reduce flickering
 Originally Posted by gstercken
Double buffering (or rather, offscreen drawing - double buffering is something else, strictly speaking  ) would be overkill in this case, and totally unnecessary.
Like Mike said: Call SetRedraw(false) before inserting / removing items, and SetRedraw(true), follwed by Invalidate(), after you're done with your bulk item operation.
actually there is no bulk operation. The items are inserted on run time one by one. But there are times when the number of those items is huge, about 100 items per second.
This control is a self redrawing control. Before any Remove/Add operation I disable redraw and enable it after but it does not help.
When I added OnEraseBackground handler and return FALSE from there the flickering is gone. but the only disadvantage is when the listbox is not full the background is not invalidated in case it's overlapped with something but it's not that nasty since the control gets filled pretty quickly
-
February 8th, 2007, 02:27 PM
#12
Re: Reduce flickering
Did you try my above suggestion ??
Jim
ATP BE400 CE500 (C550B-SPW) CE560XL MU300 CFI CFII
"The speed of non working code is irrelevant"... Of course that is just my opinion, I could be wrong.
"Nothing in the world can take the place of persistence. Talent will not; nothing is more common than unsuccessful men with talent. Genius will not; unrewarded genius is almost a proverb. Education will not; the world is full of educated derelicts. Persistence and determination are omnipotent. The slogan 'press on' has solved and always will solve the problems of the human race."...Calvin Coolidge 30th President of the USA.
-
February 8th, 2007, 02:44 PM
#13
Re: Reduce flickering
 Originally Posted by Vanaj
Did you try my above suggestion ??
if the number of items is not know before their insertion, he cannot use InitStorage.
-
February 8th, 2007, 02:46 PM
#14
Re: Reduce flickering
The items are inserted on run time one by one. But there are times when the number of those items is huge, about 100 items per second.
When an item is inserted, disable Redraw, and start a timer (restart timer if already started). When timer expires, enable re-draw and invalidate. A timer of about 0.75 seconds is what I like.
No "flicker" but fairly quick updates
TheCPUWizard is a registered trademark, all rights reserved. (If this post was helpful, please RATE it!)
2008, 2009,2010
In theory, there is no difference between theory and practice; in practice there is.
* Join the fight, refuse to respond to posts that contain code outside of [code] ... [/code] tags. See here for instructions 
* How NOT to post a question here
* Of course you read this carefully before you posted
* Need homework help? Read this first
-
February 8th, 2007, 02:52 PM
#15
Re: Reduce flickering
 Originally Posted by Alin
if the number of items is not know before their insertion, he cannot use InitStorage.
One can make an educated guess...but he has not said this value is unknown and anything greater than 100 WILL help and 500 is better even if only 150 is loaded. Mine loads 4,000+ with NO flicker and InitStorage() is run before loading using values from database returns.
Jim
ATP BE400 CE500 (C550B-SPW) CE560XL MU300 CFI CFII
"The speed of non working code is irrelevant"... Of course that is just my opinion, I could be wrong.
"Nothing in the world can take the place of persistence. Talent will not; nothing is more common than unsuccessful men with talent. Genius will not; unrewarded genius is almost a proverb. Education will not; the world is full of educated derelicts. Persistence and determination are omnipotent. The slogan 'press on' has solved and always will solve the problems of the human race."...Calvin Coolidge 30th President of the USA.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|