Solved

Prob with richedit font

Posted on 2001-09-04
3
429 Views
Last Modified: 2013-12-03
I am trying to set a special font for only a range of chars in a richedit 3 . WM_SETFONT won't work even if there is no selection , it changes the whole font .

Any options ?
0
Comment
Question by:WxW
3 Comments
 
LVL 31

Expert Comment

by:Zoppo
ID: 6456593
Hi WxW,

you'll need to use EM_SETCHARFORMAT for range of chars or EM_SETPARAFORMAT for paragraphs.

hope that helps,

ZOPPO
0
 

Accepted Solution

by:
chandas earned 50 total points
ID: 6456622
You can't use WM_SETFONT. It is designed to specify the font for all the characters in the rich edit. Rather, use

CHARFORMAT or CHARFORMAT2, (since you're using Rich Edit 3 as you say)

You must remember to first zero out this structure before you use it, just to be safe. I typically use ZeroMemory(...) for this.

Set the cbSize member to the sizeof CHARFORMAT or CHARFORMAT2 as you require.

so you'll have something like

CHARFORMAT2 cf2
cf2.cbSize = sizeof CHARFORMAT2
ZeroMemory(blah, blah, blah) //I forget the exact usage
cf2.dwMask = CFM_CHARSET | CFM_FACE
cf2.bCharSet = //your charset here for example

and so on,

when you're done (assuming you have acurrent selection) call EM_SETCHARFORMAT() with the address of cf2 and use SCF_SELECTION as the wParam.

Sorry I don't have VC++ open in front of me and hence the pseudo-code, but basically that's the route to take.

Regards

Senkwe

0
 
LVL 6

Author Comment

by:WxW
ID: 6460483
good , the CFM_FACE worked
Enough strangely , WM_SETFONT works for richedit 1.0 but not for 2.0 or 3.0

Michael
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article, I will show how to use the Ribbon IDs Tool Window to assign the built-in Office icons to a ribbon button.  This tool will help us to find the OfficeImageId that corresponds to our desired built-in Office icon. The tool is part of…
For most people, the WrapPanel seems like a magic when they switch from WinForms to WPF. Most of us will think that the code that is used to write a control like that would be difficult. However, most of the work is done by the WPF engine, and the W…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now