Solved

Prob with richedit font

Posted on 2001-09-04
3
433 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Is COM supported from Apache 1 79
GET error with Font Awesome 3 50
Starting to use Git with Visual  Studio Online 1 69
MDT Create a bootable media for BIOS 2 23
This article surveys and compares options for encoding and decoding base64 data.  It includes source code in C++ as well as examples of how to use standard Windows API functions for these tasks. We'll look at the algorithms — how encoding and decodi…
As more and more people are shifting to the latest .Net frameworks, the windows presentation framework is gaining importance by the day. Many people are now turning to WPF controls to provide a rich user experience. I have been using WPF controls fo…
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…

732 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