Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Prob with richedit font

Posted on 2001-09-04
3
Medium Priority
?
442 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 150 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

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

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

After several hours of googling I could not gather any information on this topic. There are several ways of controlling the USB port connected to any storage device. The best example of that is by changing the registry value of "HKEY_LOCAL_MACHINE\S…
For a while now I'v been searching for a circular progress control, much like the one you get when first starting your Silverlight application. I found a couple that were written in WPF and there were a few written in Silverlight, but all appeared o…
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…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

926 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