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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Custom Bold Draw for ListView

Status
Not open for further replies.

AClaussen

Programmer
Jan 16, 2002
2
BR
Hi!
I wonder if you can help me ot with this weird problem.
I have this ListView and I'm using the OnAdvancedCustomDrawItem event
to make some items bold. Pretty simple isn't it?
The problem is that some items on the ListView, when I set them to
bold, the text wraps and gets a "..." at the end,
like it couldn't fit the width of the ListView but there's plenty of
room on the right.

My ListView setup is:
Columns = <>
OwnerDraw = True
ShowColumnHeaders = False
SmallImages = ImageList1
ViewStyle = vsList
OnAdvancedCustomDrawItem = MakeBold

MakeBold coding is:
begin
if Stage <> cdPrePaint then Exit;
ListView1.Canvas.Font.Style := [fsBold];
Repaint;
end;

When the ListItem is not bold it fits perfectly, but when it gets bold
the dots appear... Hope you can figure it out...

Thank you very much

Alice Claussen
 
Bolding a word actually makes that word wider. Each pixel in the letters of the word are being offset to the right and duplicated, making the entire word look bold. Windows has predefined margins set in all its windows so that if anything crosses the right margins the text will ether word wrap, a horizontal scroll bar will appear on the bottom or the '...' will be added to a shortened entry. It may look like there is enough room to fit the bold word in ListItem but to this preset margin you do not.
I haven't been able to adjust these margins to different setting, but the way I solved this was to widen the the boxes I was using slightly. Using your largest entry set to bold and keep widening the box until the '...' goes away.

If anybody has a better solution, I would like to know as well.
 
I couldn't find a real solution to this problem... but I found a way to skip it.
I created a really wide ListItem and on AdvancedCustomDrawItem event I set it's font color to the same font color as the ListView, so t gets invisible.
Since this invisible item is really large, the other, even if they get bold, they fit the ListView and the dots do not appear...
It's not a real solution but it's a way to skip the problem till a real solution comes...

Alice Claussen
 
Why do you consider that a problem? I always leave it like
that! It has never bothered me or my users!

But good luck anyway,

BobbaFet Everyone has a right to my opinion.
E-mail me at caswegkamp@hotmail.com

Heineken is like making love in a cano... it's f*cking close to water !!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top