TListbox OnMeasureItem problems

The OnMeasureItem event is only called when a new item is added.  Can it be set up to call it every time it is Invalidated?

My items change height a lot.  They cause the listbox to be repainted.  At the moment I have to cheat and set and unset a visual property to force a new measurement.  This results in a huge flicker.

eg.

Listbox.Ctl3d:=False;
Listbox.Ctl3d:=True;

Hmmm..
There must be an easy way round this!

Bryan
LVL 1
bcrotazAsked:
Who is Participating?
 
JimBob091197Connect With a Mentor Commented:
Hehe, as long as it works, don't fix it...

0
 
JimBob091197Commented:
I haven't tried this, but it may work:
  LockWindowUpdate(YourMainForm.Handle);
  ListBox.Ctl3d := False;
  ListBox.Ctl3d := True;
  LockWindowUpdate(0);

JB
0
 
bcrotazAuthor Commented:
I'll try it...
0
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

 
bijoynCommented:
Have u tried using the OnDrawItem instead of OnMeasureItem. I am not sure what exactly u are doing with the height of the items in the Listbox but OnDrawItem will be called every time u select a Item or scroll through the Item. Addtionally this event is called when u call the Listbox's Invalidate  method.

Bijoy
0
 
bcrotazAuthor Commented:
I am using OnDrawItem to draw the items.  OnMeasureItem enables you to have variable height items.
0
 
bcrotazAuthor Commented:
JimBob - can you send an answer?
That works perfectly - A bodge, but a working bodge!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.