Fun with List Controls
-
I have a derived CListCtrl in which I do a bit of custom drawing. The custom drawing had to be done because the first line of each "query" is more or less a header line. For example, if I have the programming staff's hours worked this week in a database, the first line (and subsequently, the first column) in the list control (report view of course) is the person's name. However, the real data on the next line is a date. So what's happening is that since the column is sized to handle a date, a person with a normal name has their name clipped. I'm looking for a way when I get this "status line" that I can handle the painting and not have the name clipped but have it paint the line of text over multiple columns. I've seen the examples for painting the list control when there's no items, but this isn't going to work in my situation because they're painting the entire list control which I don't want. Any help is appreciated. Bill http://www.ratebeer.com
-
I have a derived CListCtrl in which I do a bit of custom drawing. The custom drawing had to be done because the first line of each "query" is more or less a header line. For example, if I have the programming staff's hours worked this week in a database, the first line (and subsequently, the first column) in the list control (report view of course) is the person's name. However, the real data on the next line is a date. So what's happening is that since the column is sized to handle a date, a person with a normal name has their name clipped. I'm looking for a way when I get this "status line" that I can handle the painting and not have the name clipped but have it paint the line of text over multiple columns. I've seen the examples for painting the list control when there's no items, but this isn't going to work in my situation because they're painting the entire list control which I don't want. Any help is appreciated. Bill http://www.ratebeer.com
Basically, you have two choices. Owner-draw list control delegates all drawing to your code. You're responsible for everything and have full control. OTOH, the custom-draw is usable when you just want to alter some aspects of drawing, like text color or font. I'm not sure if you'll be able to draw unbounded by columns. There should be some articles on custom-draw list control on CP. Maybe you should just use a grid - there's one right here on CodeProject. It supports multiple fonts, colors, etc. Tomasz Sowinski -- http://www.shooltz.com
-
Basically, you have two choices. Owner-draw list control delegates all drawing to your code. You're responsible for everything and have full control. OTOH, the custom-draw is usable when you just want to alter some aspects of drawing, like text color or font. I'm not sure if you'll be able to draw unbounded by columns. There should be some articles on custom-draw list control on CP. Maybe you should just use a grid - there's one right here on CodeProject. It supports multiple fonts, colors, etc. Tomasz Sowinski -- http://www.shooltz.com
I'm currently using custom draw to highlight particular rows. I couldn't figure out how to intercept the text drawing. I also noticed that when I looked at the rect struct that's passed into the custom draw function that top was set, but bottom, right and left were out in left field (uninitialized I'm guessing). I really don't require any additional functionality other than this, so I'm not sure if the supergrid is something I want to add at this point, but who knows, maybe I'll end up going down that route. Thanks for the feedback. Bill http://www.ratebeer.com