0

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)

Coder12345
  • 3,431
  • 3
  • 33
  • 73
  • I still think you are doing this all wrong. – David Heffernan Jan 05 '14 at 19:12
  • Why do you think so? `SPI_GETICONTITLELOGFONT` is the only value to retrieve for icon font size. – Coder12345 Jan 05 '14 at 19:13
  • 1
    Because the `lfHeight` member of the `LOGFONT` structure is not a [`size in pixels`](http://stackoverflow.com/a/2944426/960757). – TLama Jan 05 '14 at 19:18
  • For the same reasons as we discussed in your previous question – David Heffernan Jan 05 '14 at 19:20
  • @DavidHeffernan if you think that is worth a public warning, then I guess an explicit link to that referenced question/discussion would be nice for any future reader – Arioch 'The Jan 05 '14 at 20:29
  • 1
    http://stackoverflow.com/questions/20825325/ – Free Consulting Jan 05 '14 at 21:39
  • @David Heffernan I did try your solution of course but unfortunately it was not giving the appropriate item height as the solution which I marked as correct. The items using your solution are still clipped so it must be based on font height. But I do not see how measuring font height in main menu is related to measuring note height based on system icon font size. Do you have a proposed solution for this particular problem? – Coder12345 Jan 06 '14 at 19:07

0 Answers0