VirtualTreeView node height based on icon font size

785 Views Asked by At

I am trying to set node height based on system icon font size.

My code so far:

LOGFONT lf;
ZeroMemory(&lf, sizeof(lf));
if (SystemParametersInfo(SPI_GETICONTITLELOGFONT, sizeof(lf), &lf, 0))
   {
   // This is a hack because font height itself doesn't give me correct node height - everything is too tight
   int Height = VST->DefaultNodeHeight - abs(VST->Font->Height)+1;

   VST->DefaultNodeHeight = abs(lf.lfHeight)+Height;
   VST->Font->Name        = lf.lfFaceName;
   VST->Font->Height      = lf.lfHeight;
   }

The above works but I cannot get the DefaultNodeHeight right - it is not the same size as default used when font is fixed. Font height is good.

How can I retrieve the correct value from the system, or auto-size VirtualTreeView to use correct node height which would be the same as default but based on above code?

Default font height is -14, font size is 8 and node height is 18.

So in other words I need:

a) icon font size

b) appropriate DefaultNodeHeight, based on font size (in case if I use different font size, then DefaultNodeHeight is recalculated based on that particular size)

0

There are 0 best solutions below