Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. CFontDialog incorrect default size

CFontDialog incorrect default size

Scheduled Pinned Locked Moved C / C++ / MFC
question
6 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    Lonnie Johnson
    wrote on last edited by
    #1

    In the OnBeginPrinting function of my view class I am displaying a CFontDialog dialog box. I want the default font to be Arial and the default size to be 10. When the dialog box displays, it a shows default size of 62. Here is the code. These are the first lines in the OnBeginPrinting function.

    ASSERT(pDC->GetMapMode() == MM_TEXT);
    LOGFONT lf;
    ::ZeroMemory(&lf, sizeof(LOGFONT));
    lf.lfHeight = -MulDiv(10, pDC->GetDeviceCaps(LOGPIXELSY), 72);
    lstrcpy(lf.lfFaceName, _T("Arial"));
    CFontDialog dlg&lf, CF_PRINTERFONTS, pDC);
    if (dlg.DoModal() == IDOK)
    {
    m_strFont = dlg.GetFaceName();
    m_nPointSize = dlg.GetSize() / 10;
    }

    Why is the dialog displaying the wrong size value?

    D P 2 Replies Last reply
    0
    • L Lonnie Johnson

      In the OnBeginPrinting function of my view class I am displaying a CFontDialog dialog box. I want the default font to be Arial and the default size to be 10. When the dialog box displays, it a shows default size of 62. Here is the code. These are the first lines in the OnBeginPrinting function.

      ASSERT(pDC->GetMapMode() == MM_TEXT);
      LOGFONT lf;
      ::ZeroMemory(&lf, sizeof(LOGFONT));
      lf.lfHeight = -MulDiv(10, pDC->GetDeviceCaps(LOGPIXELSY), 72);
      lstrcpy(lf.lfFaceName, _T("Arial"));
      CFontDialog dlg&lf, CF_PRINTERFONTS, pDC);
      if (dlg.DoModal() == IDOK)
      {
      m_strFont = dlg.GetFaceName();
      m_nPointSize = dlg.GetSize() / 10;
      }

      Why is the dialog displaying the wrong size value?

      D Offline
      D Offline
      David Crow
      wrote on last edited by
      #2

      Lonnie Johnson wrote:

      Why is the dialog displaying the wrong size value?

      I don't know, but have you tried using values other than 10 to see if a pattern exists?

      "Love people and use things, not love things and use people." - Unknown

      "The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch

      L 1 Reply Last reply
      0
      • D David Crow

        Lonnie Johnson wrote:

        Why is the dialog displaying the wrong size value?

        I don't know, but have you tried using values other than 10 to see if a pattern exists?

        "Love people and use things, not love things and use people." - Unknown

        "The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch

        L Offline
        L Offline
        Lonnie Johnson
        wrote on last edited by
        #3

        Here are the results from some other point sizes. input point size size that appears in the dialog box. 8 50 12 62 14 88 16 100 18 113 20 125

        1 Reply Last reply
        0
        • L Lonnie Johnson

          In the OnBeginPrinting function of my view class I am displaying a CFontDialog dialog box. I want the default font to be Arial and the default size to be 10. When the dialog box displays, it a shows default size of 62. Here is the code. These are the first lines in the OnBeginPrinting function.

          ASSERT(pDC->GetMapMode() == MM_TEXT);
          LOGFONT lf;
          ::ZeroMemory(&lf, sizeof(LOGFONT));
          lf.lfHeight = -MulDiv(10, pDC->GetDeviceCaps(LOGPIXELSY), 72);
          lstrcpy(lf.lfFaceName, _T("Arial"));
          CFontDialog dlg&lf, CF_PRINTERFONTS, pDC);
          if (dlg.DoModal() == IDOK)
          {
          m_strFont = dlg.GetFaceName();
          m_nPointSize = dlg.GetSize() / 10;
          }

          Why is the dialog displaying the wrong size value?

          P Offline
          P Offline
          PJ Arends
          wrote on last edited by
          #4

          What is the value returned from GetDeviceCaps()? printers have way more pixels per inch than screens do. What is the value of lfHeight?

          L 1 Reply Last reply
          0
          • P PJ Arends

            What is the value returned from GetDeviceCaps()? printers have way more pixels per inch than screens do. What is the value of lfHeight?

            L Offline
            L Offline
            Lonnie Johnson
            wrote on last edited by
            #5

            The value returned by pDC->GetDeviceCaps(LOGPIXELSY) is 600. The computed value for lf.lfHeight when 8 points is used is -67. The resulting size value in the Select Font dialog is 50.

            P 1 Reply Last reply
            0
            • L Lonnie Johnson

              The value returned by pDC->GetDeviceCaps(LOGPIXELSY) is 600. The computed value for lf.lfHeight when 8 points is used is -67. The resulting size value in the Select Font dialog is 50.

              P Offline
              P Offline
              PJ Arends
              wrote on last edited by
              #6

              Sounds about right.

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups