Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Hello there. I have the following s

Status
Not open for further replies.

dex1123

Programmer
May 9, 2000
35
BG
Hello there. I have the following situation. I have an owner-drawn listbox and I change the color of every item according to some rule. The problem is when I do have even two differently styled items in the list, I get monstrous flickering. Is there a way to prevent this and make the items not update when not needed? Thank you in advance. Any help will be appreciated.

best regards... Ivan
 
I would recommend optimizing the ondrawitem code as your best option for reducing flicker. Consider only changing the font color instead of font color and the brush color. Only fillrect the part that changes instead of the whole rect area.
Also, look at how you are implementing the rule you mentioned. If you are parsing out values from each item's string, make sure that you only are parsing the values needed for the rule. Consider changing the layout of the unparsed string so that the rule's values are easier to parse out.
These kinds of changes will always help smooth out the display. A few other ideas come to mind, but I don't know if they will help or not...

Once you figured out what style item is to be displayed, check the current values of font.color and brush.color. Only change them if they are not already the value you are seeking. This might speed things up a bit.
Also, every strings property (such has listbox.items) has an binary value associated with each string in the items property. I think it is called itemvalues in Delphi but I don't remember right now. You might want to preload these binary values with the "style" information prior to showing the listbox. That might cut out the parsing and rule calculating delays and make the display even better.
I hope some of this helped.
Peace,
Colt.
 
Thanks for the reply but my main purpose is to change the background color of the items which leads to brush color change. I tried doing it only in specific cases for specific items but this way it makes all the items in the lbox equivalently styled. What I need here is some kind of double-buffering the canvas and then displaying it.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top