John
John

Reputation: 103

Canvas.TextOut Seems to allow transparent trailing white space

I am in the process of relearning Delphi as have not programmed much of anything in years and have forgotten more than I ever learned! I have started with a simple file search routine and placing the found files in a multi-column listbox. The component I found was called MultiColListBox.pas off of Delphi3000.com. I have added a couple events to the sort routine and fixed an empty listbox error when enabling Sort.

When has two columns defined using this code and each is set for a length of 20, and in the first column your text (item) is say 100 characters long and the first item in the second column is say 20 characters long, you will see underneath the trailing whitespace text from the foirst column's text.

In the component, (Link to Code below), where the columns are drawn;

procedure TMultiColListBox.ListBoxDrawItem(Control : TWinControl;
                                       Index : Integer;
                                       Rect : TRect;
                                       State : TOwnerDrawState);

I have tried setting the brush to solid, and everything else I could think of. I finally realized that it is drawing the coordinates of the text with nothing trailing. Therefore we are getting a transparent effect which is not desired.

Usually I am overlooking something simple, so far, (can't see the forest for the trees). What might fix this issue? (This component has many items not working so lots of work but a great re-learning experience.

LINK To CODE: http://www.delphi3000.com/articles/article_3360.asp MultiColListBox

Thanks!

JOhn

PS. I could not figure out how to format a cut and then pasted long code set or even the entire function to this forum, (short ones easy as above) so I provided the link to the compoenent code on Delphi3000.com.

Upvotes: 1

Views: 577

Answers (1)

David Heffernan
David Heffernan

Reputation: 613441

Rather than fighting with this this 10 year old code you should simply switch to list view, TListView and set ViewStyle to vsReport. This gives you a multi-column list using the native, modern-day Windows list control.

This doesn't directly answer your question, but I believe it solves your problem far better than the code you are trying to use.

Upvotes: 5

Related Questions