Board index » cppbuilder » Invalidate problem with OwnerDraw TListBox

Invalidate problem with OwnerDraw TListBox


2005-12-10 06:25:53 AM
cppbuilder40
Hi,
I have a TListBox whose Style property is set to lbOwnerDrawFixed. I have
added an OnDrawItem event handler to draw the content of my listbox
according to my owerdraw rules. Up to this point, everything seems to work
fine.
However, if the owerdraw rules change, I want the listbox to get updated.
So, if a change occurs to the rules, I call Invalidate() on the listbox so
that it can update itself. Unfortunately, Invalidate() isn't causing the
OnDrawItem event handler to get fired for the items in my listbox, and so
the changes are not visible unless I do something silly, like move a window
around in front of my listbox.
I know I've done this before, and I've looked at the code from a previous
project that works just fine. I cannot, for the life of me, see what could
possibly be different between the two projects that would allow the old one
to work, and this one not to.
Even calling Repaint and/or Update don't do anything. What's going on?
Shouldn't Invalidate() cause my entire control to get invalidated and
re-drawn? Why isn't it?
- Dennis
 
 

Re:Invalidate problem with OwnerDraw TListBox

"Dennis Jones" < XXXX@XXXXX.COM >wrote in message
Quote
However, if the owerdraw rules change, I want the listbox to get updated.
So, if a change occurs to the rules, I call Invalidate() on the listbox so
that it can update itself. Unfortunately, Invalidate() isn't causing the
OnDrawItem event handler to get fired for the items in my listbox, and so
the changes are not visible unless I do something silly, like move a
window
around in front of my listbox.
Nevermind....I was calling Invalidate on the wrong listbox!!! Silly me.
That'll do it everytime!
- Dennis
 

Re:Invalidate problem with OwnerDraw TListBox

"Dennis Jones" < XXXX@XXXXX.COM >wrote in message
Quote
So, if a change occurs to the rules, I call Invalidate() on the listbox
so that it can update itself. Unfortunately, Invalidate() isn't causing
the OnDrawItem event handler to get fired for the items in my listbox,
and so the changes are not visible unless I do something silly, like
move a window around in front of my listbox.
Invalidate() is not an immediate update. The control is not updated until a
new WM_PAINT message arrives in the message queue. If you need an immediate
update, then call Update() after calling Invalidate().
Quote
Even calling Repaint and/or Update don't do anything. What's going on?
Please show your actual code.
Quote
Shouldn't Invalidate() cause my entire control to get invalidated and
re-drawn?
It will be invalidated, yes. It will be re-drawn whenever the WM_PAINT
message arrives from the OS.
Quote
Why isn't it?
I can't answer that without seeing what you are actually doing.
Gambit
 

{smallsort}