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