|
-
June 23rd, 1999, 03:44 AM
#1
Changing Fonts in RichEdit Control
Hi,
I want to change the default font of the Rich Edit control at run time.
I tried making use of CRichEditCtrl::SetDefaultCharFormat() function
and changing the szFaceName member of CHARFORMAT structure. It did not work.
The function help says "Only the attributes specified by the dwMask member of cf are
changed by this function." I did not see any attribute that can be used to change the
font.
I tried this before putting any text in the control.
Can anyone one tell me how to change font of Rich Edit control at run time?
Cheers,
Sanjeet
-
June 23rd, 1999, 09:17 AM
#2
Re: Changing Fonts in RichEdit Control
Hi,
Maybe try the "SetFont()" function (CWnd method). This should change the font for the entire text (I don't know if it's what you want).
Greetz
Jean-Marie
-
June 23rd, 1999, 10:01 AM
#3
Re: Changing Fonts in RichEdit Control
To Sanjeet
Try this.
int CMyView::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CRichEditView::OnCreate(lpCreateStruct) == -1)
return -1;
CHARFORMAT cfDefault;
cfDefault.cbSize = sizeof(cfDefault);
cfDefault.dwEffects = CFE_PROTECTED;
cfDefault.dwMask = CFM_BOLD | CFM_FACE | CFM_SIZE | CFM_CHARSET | CFM_PROTECTED | CFM_COLOR;
cfDefault.yHeight = 12 * 20;
cfDefault.crTextColor = RGB(255,255,0);
cfDefault.bCharSet = 0;
strcpy( cfDefault.szFaceName, _T("Courier New") );// or "Times New Roman" etc etc
GetRichEditCtrl().SetDefaultCharFormat(cfDefault);
GetRichEditCtrl().SetEventMask(ENM_CHANGE | ENM_SELCHANGE | ENM_PROTECTED);
GetRichEditCtrl().SetBackgroundColor( FALSE, RGB(0,0,0) );
return 0;
}
-
June 23rd, 1999, 10:05 PM
#4
Re: Changing Fonts in RichEdit Control
Thanks Matthew,
I did not use the code sent by you. But got where I was going wrong.
Actually it was a stupid mistake on my side.
I never noticed the dwMask value "CFM_FACE". After reading I set this value and
it worked.
Thanks again. 
Sanjeet.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|