Solved

Prob with richedit font

Posted on 2001-09-04
3
428 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 30

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

This article shows a few slightly more advanced techniques for Windows 7 gadget programming, including how to save and restore user settings for your gadget and how to populate the "details" panel that is displayed in the Windows 7 gadget gallery.  …
With most software applications trying to cater to multiple user needs nowadays, the focus is to make them as configurable as possible. For e.g., when creating Silverlight applications which will connect to WCF services, the service end point usuall…
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…

760 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