The docs for DesktopListbox include this, for the PaintCellText handler:
Returning True means the user has handled the text paint and no other processing is to be done with the text. In this case, the user is responsible for text highlighting. Text highlighting is currently only done for the hierarchical listbox style. Returning False means the user wants the default text drawing. In this case, the text will be highlighted as appropriate (according to platform) for you automatically.
This implies that if I want to do my own thing in regard to row and text highlighting, then I’d better Return True in the event handler. Well, I do want to do my own thing. I have two separate row highlight colours, and I don’t want to text colour changed to white if a row is highlighted.
Here is a simplified version of my PaintCellText handler, showing what gets put into the various columns:
PaintCellText (g as Graphics, row as integer, column as integer, x as integer, y as integer) As Boolean
Var reg As RowSet, offset As Double, statPict As Picture
if (column=0) then
select case me.CellTagAt(row, 0)
case app.STAT_UNREAD
statPict = msunread
// More cases to set statPict
end select
// Code to set offset
g.DrawPicture (statPict, 5, offset)
Return False
end if
if (column=1) then
// Code to set statPict
g.DrawPicture (statPict, 5, 2)
end if
// Code here to obtain some database info based on an id in the rowtag.
// Use part of the database info to set g.DrawingColor, and ...
g.FontName = "Arial"
me.CellTextAt(row,2) = reg.Column("col2data").StringValue
me.CellTextAt(row,3) = reg.Column("col3data").StringValue
me.CellTextAt(row,4) = reg.Column("col4data").StringValue
me.CellTextAt(row,6) = reg.Column("col6data").StringValue
Return False
End Sub
This code works as desired, with my various row highlighting colours and text colours as I decide, with no automatic row or text highlighting. But I’m returning False
and not True
, so is that a documentation error? If I return True
instead, then the text colour goes white when the row is highlighted and the font is wrong for the whole row (System instead of Arial).
The other issue is that the code for setting CellTextAt for columns 2-6 is executed several times per row (when column=2,3,4,5,6) to no purpose. I want to avoid that as when column=1, all the relevant cells are filled. But if I put something like:
if (column>1) then Return False
at the head of the event handler, I’m back to having the event handler messing with font and text colour again.
I feel I’m mising something fundamental about the Listbox.
12 posts - 5 participants