Board index » cppbuilder » Spontaneous font change in custom draw list view

Spontaneous font change in custom draw list view

We are trying to add a 'coloured blob' as the first column of a
TListView.  We so this using OnCustomDrawSubItem, setting DefaultDraw =
true unless column == 1.  Col 0 is a checkbox, provided by the control
itself.

Everything seemed fine when we used the Canvas->Recatangle call to do
this, but we found some mysterious resource leaks on a few (but not all)
of our PCs.  We haven't been able to locate drivers to fix this, and the
machines deplete resources real fast so we're looking for a code around.

Current solution is to draw empty text, using the WinAPIs SetBkColor and
ExtTextOut with an empty string, specifying our cell as the clip rect.

This draws the 'blob' perfectly well, but the rest of that row will draw
in the system default font, which is larger and bold.  Rows where we do
not draw the blob (it's a bit like a multi-select) work as normal.
However, the resource leak does go away.  We have tried Save/RestoreDC;
and save / copy back the Canvas font without success.

Does anyone know how to restore the correct font in this second case, or
a better way to avoid our resource leak (almost certainly a video driver
problem)?

Thanks for any advice

AlisdairM

 

Re:Spontaneous font change in custom draw list view


Quote
AlisdairM wrote:
> This draws the 'blob' perfectly well, but the rest of that row will draw
> in the system default font, which is larger and bold.  

OK, having tried a few more things, the problems start as soon as we
refer to the Canvas->Handle property.  Even if we do nothing with it,
the font changes.  And selecting into the DC the canvas font, or even a
copy of the ListView font (copied to be safe, not sure what VCL is doing
with all those handles!) has no apparent effect.

Still stumped :? (

AlisdairM

Other Threads