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. vc++

vc++

Scheduled Pinned Locked Moved C / C++ / MFC
c++tutorial
4 Posts 4 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.
  • U Offline
    U Offline
    User 1452703
    wrote on last edited by
    #1

    How to use Different font sizes in a VC++ Dialog Box

    K V 2 Replies Last reply
    0
    • U User 1452703

      How to use Different font sizes in a VC++ Dialog Box

      K Offline
      K Offline
      kriaz
      wrote on last edited by
      #2

      Right click on dialog select properties; from the general tab select the font size you want.:)

      1 Reply Last reply
      0
      • U User 1452703

        How to use Different font sizes in a VC++ Dialog Box

        V Offline
        V Offline
        vcplusplus
        wrote on last edited by
        #3

        If you want to do it at run time, override the virtual function DoModal(); #include <afxpriv.h> // Required for CDialogTemplate int CMyDlg::DoModal() { CDialogTemplate dlt; // Load dialog Template if (!dlt.Load(MAKEINTRESOURCE(CMyDlg::IDD))) { return -1; } // Set Font Size; // Default Value WORD nFontSize = 10; TCHAR chFaceName[100] = "Courier New"; // Open an ini file or read from the registry to get the new font size and face name if (GetNewFontSize(....)) { nFontSize = newsize; } if (GetNewFaceName(....)) { lstrcpy(chFaceName, newfacename); } dlt.SetFont(chFaceName, (WORD)nFontSize); // Get pointer to the modified dialog template LPSTR pData = (LPSTR)GlobalLock(dlt.m_hTemplate); if (pData == NULL) { return -1; } // Let MFC know that you are using your own template m_lpszTemplateName = NULL; InitModalIndirect(pData); // Display Dialog Box INT nResult = CDialog::DoModal(); // Unlock memory object GlobalUnlock(dlt.m_hTemplate); return nResult; }

        J 1 Reply Last reply
        0
        • V vcplusplus

          If you want to do it at run time, override the virtual function DoModal(); #include <afxpriv.h> // Required for CDialogTemplate int CMyDlg::DoModal() { CDialogTemplate dlt; // Load dialog Template if (!dlt.Load(MAKEINTRESOURCE(CMyDlg::IDD))) { return -1; } // Set Font Size; // Default Value WORD nFontSize = 10; TCHAR chFaceName[100] = "Courier New"; // Open an ini file or read from the registry to get the new font size and face name if (GetNewFontSize(....)) { nFontSize = newsize; } if (GetNewFaceName(....)) { lstrcpy(chFaceName, newfacename); } dlt.SetFont(chFaceName, (WORD)nFontSize); // Get pointer to the modified dialog template LPSTR pData = (LPSTR)GlobalLock(dlt.m_hTemplate); if (pData == NULL) { return -1; } // Let MFC know that you are using your own template m_lpszTemplateName = NULL; InitModalIndirect(pData); // Display Dialog Box INT nResult = CDialog::DoModal(); // Unlock memory object GlobalUnlock(dlt.m_hTemplate); return nResult; }

          J Offline
          J Offline
          John M Drescher
          wrote on last edited by
          #4

          I use a method similar to this with a highres app and it works great. On a highres monitor (2048 x 2560) I use 15pt font and on the second (1024x768) I use 10pt... John

          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