title: MFC: Dynamically change control font size?
body: <p>I have a CListCtrl class that I'd like to be able to easily change the font size of.  I subclassed the CListCtrl as MyListControl.  I can successfully set the font using this code in the PreSubclassWindow event handler:</p>
  
  <pre><code>void MyListControl::PreSubclassWindow()
  {
      CListCtrl::PreSubclassWindow();
  
      // from http://support.microsoft.com/kb/85518
      LOGFONT lf;                        // Used to create the CFont.
  
      memset(&amp;lf, 0, sizeof(LOGFONT));   // Clear out structure.
      lf.lfHeight = 20;                  // Request a 20-pixel-high font
      strcpy(lf.lfFaceName, "Arial");    //    with face name "Arial".
      font_.CreateFontIndirect(&amp;lf);    // Create the font.
      // Use the font to paint a control.
      SetFont(&amp;font_);
  }
  </code></pre>
  
  <p>This works.  However, what I'd like to do is create a method called SetFontSize(int size) which will simply change the existing font size (leaving the face and other characteristics as is).  So I believe this method would need to get the existing font and then change the font size but my attempts to do this have failed (this kills my program):</p>
  
  <pre><code>void MyListControl::SetFontSize(int pixelHeight)
  {
      LOGFONT lf;                        // Used to create the CFont.
  
      CFont *currentFont = GetFont();
      currentFont-&gt;GetLogFont(&amp;lf);
      LOGFONT lfNew = lf;
      lfNew.lfHeight = pixelHeight;                  // Request a 20-pixel-high font
      font_.CreateFontIndirect(&amp;lf);    // Create the font.
  
      // Use the font to paint a control.
      SetFont(&amp;font_);
  
  }
  </code></pre>
  
  <p>How can I create this method?</p>