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. Changing RichEdit font

Changing RichEdit font

Scheduled Pinned Locked Moved C / C++ / MFC
question
3 Posts 2 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.
  • J Offline
    J Offline
    jsumm
    wrote on last edited by
    #1

    Hi all, how can I change the font in a RichEdit2 Control to Terminal? I tried this, but the displayed font is not Terminal. CHARFORMAT cf; cf.cbSize = sizeof(cf); cf.dwMask = CFM_FACE | CFM_SIZE; // makes szFaceName and yHeight valid cf.yHeight = 9 * 20; // in TWIPS, 20 twips per point //cf.bPitchAndFamily = FIXED_PITCH; cf.bCharSet = OEM_CHARSET; ::lstrcpy (cf.szFaceName, "Terminal"); m_pRichEdit->SetSelectionCharFormat(cf); Thanks

    J S 2 Replies Last reply
    0
    • J jsumm

      Hi all, how can I change the font in a RichEdit2 Control to Terminal? I tried this, but the displayed font is not Terminal. CHARFORMAT cf; cf.cbSize = sizeof(cf); cf.dwMask = CFM_FACE | CFM_SIZE; // makes szFaceName and yHeight valid cf.yHeight = 9 * 20; // in TWIPS, 20 twips per point //cf.bPitchAndFamily = FIXED_PITCH; cf.bCharSet = OEM_CHARSET; ::lstrcpy (cf.szFaceName, "Terminal"); m_pRichEdit->SetSelectionCharFormat(cf); Thanks

      J Offline
      J Offline
      jsumm
      wrote on last edited by
      #2

      Has no one any ideas or is it to easy ? I'm trying to solve this problem since hours. It must be possible. In Borland Delphi it's no problem, but I have to do this in VC++.

      1 Reply Last reply
      0
      • J jsumm

        Hi all, how can I change the font in a RichEdit2 Control to Terminal? I tried this, but the displayed font is not Terminal. CHARFORMAT cf; cf.cbSize = sizeof(cf); cf.dwMask = CFM_FACE | CFM_SIZE; // makes szFaceName and yHeight valid cf.yHeight = 9 * 20; // in TWIPS, 20 twips per point //cf.bPitchAndFamily = FIXED_PITCH; cf.bCharSet = OEM_CHARSET; ::lstrcpy (cf.szFaceName, "Terminal"); m_pRichEdit->SetSelectionCharFormat(cf); Thanks

        S Offline
        S Offline
        Scott Holt
        wrote on last edited by
        #3

        My understanding of how to use the rich edit is that you have to first select the text for which you wish to change the font. I found the following code in a program that I wrote some time ago: CHARRANGE CharRange ; CHARFORMAT2 CharFormat ; // To format the text just written, we must select it. ::SendMessage( m_hwndThis, EM_SETSEL, 0, CharRange.cpMax) ; //'cpMax' set to LAST character position. // Set up the character formatting structure. CharFormat.cbSize = sizeof(CharFormat) ; CharFormat.dwMask = CFM_BOLD | CFM_COLOR | CFM_ITALIC ; CharFormat.dwEffects = (bBold) ? CFE_BOLD : 0 | (bItalic) ? CFE_ITALIC : 0 ; CharFormat.yHeight = 0 ; CharFormat.yOffset = 0 ; CharFormat.crTextColor = clrFG ; //Previously set CharFormat.bCharSet = DEFAULT_CHARSET ; CharFormat.bPitchAndFamily = DEFAULT_PITCH | FF_DONTCARE ; memset(CharFormat.szFaceName, 0, 1) ; _tcscpy((_TCHAR*)&CharFormat.szFaceName, _T("Arial")) ; // Format the text just written. ::SendMessage( m_hwndThis, EM_SETCHARFORMAT, SCF_SELECTION, (LPARAM)&CharFormat) ; Don't know if this will help, but maybe it will give you some ideas where to continue. Scott

        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