Solved

Prob with richedit font

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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Gotham fonts and Office 2013 6 119
Slow process to read Excel 15 139
Should CArray be used for a list of pointers in C++? 19 120
Is IHttpActionResult a promise pattern? 2 68
What my article will show is if you ever had to do processing to a listbox without being able to just select all the items in it. My software Visual Studio 2008 crystal report v11 My issue was I wanted to add crystal report to a form and show…
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…
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…

830 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