ebmDevMag.com home
ebm Developer's Magazine
links

developer's mag
main page

article
part 1
part 2
part 3
part 4
part 5


3 - Straightforward Drawing

The code example shows its use: the constructor passes the window shape to CList, as well as the total entries. Our child class keeps track of the data pointer for use in DrawRow(). At that time, the list box calls GetRowHeight() to figure out how to space entries, then DrawRow() to display the data. In this class, we calculate the row height from the current font, which requires the current window, hence the need for the variables m_rowHeight and m_window. We could find them each time we are in the function, but the documentation on CList points out that it is a routine that is called frequently, so we should save the values for speed.

Finally DrawRow() outputs via DrawText(). Note that the row is cleared before this call is made, so you don't have to worry about clearing it yourself.

If you compare this to a comparable Windows list box, you see more code, but benefits in other areas - because you pass only a pointer, data is never copied, saving time and memory. And although this class doesn't appear to handle dynamic lists (the constructor is passed the item total), it actually does, through the inherited function SetNumRows(), which you call to adjust the size.

Previous Section
Next Section

Copyright © 2001-2006 ebmDevMag.com - Legal Notice