Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

CRichEdit Font and Alignment

Posted on 2008-06-09
4
Medium Priority
?
426 Views
Last Modified: 2013-11-20
I've been encouraged by folks here to use CRichEdit rather than CScrollView to view reports so that the control has an out-of-the-box scrolling capability.  This seems like a great idea, and I'm making a lot of progress.  However, there are three things that I have left to figure out, and can't seem to find the answers.

I need a font for title lines, etc.  How do I take the default font, and increase its size?  I tried GetFont(), followed by GetLogFont and it doesn't seem to work.  If I'm going to do that, I can just write a document, and open it in wordpad or something like that.

I need to present columns of numbers, so I need to be able to right justify within columns.  I'd really prefer to stay away from courier.

I need to be able to make the document read only.  I'm creating the documents within an MDI Doc/View architecture

Thanks in advance, Rick.
0
Comment
Question by:rickatseasoft
[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
  • 2
  • 2
4 Comments
 
LVL 31

Expert Comment

by:Zoppo
ID: 21749879
Hi rickatseasoft,

to change the font size for new inserted text you can use CRichEditCtrl::GetDefaultCharFormat and CRichEditCtrl::SetDefaultCharFormat

to define a number of right-aligned tab-stops you can select the paragraph (or line) needed and use CRichEditCtrl::GetParaFormat and CRichEditCtrl::SetParaFormat

to set it to read only you can use CRichEditCtrl::SetReadOnly

to access the CRichEditControl which is used with a CRichEditView you can use CRichEditView::GetRichEditCtrl

Hope that helps,

ZOPPO
0
 

Author Comment

by:rickatseasoft
ID: 21768210
Zoppo:

In reviewing RichEdit.h, I find the PFM_TABSTOPS option for dwMask, and assume that I can set the array rgxTabs with the tab stops for a given line.  Two questions:

1.  How do I advance to the next tab stop?
2. How do I make the tab stop a right justify tab?

Thanks, Rick
0
 
LVL 31

Accepted Solution

by:
Zoppo earned 2000 total points
ID: 21769854
Hi rickatseasoft,

1. I think you just have to add a tab-stop character ( "\t" ) in the string you set to the control
2. In MSDN there's mentioned that right aligned tab-stops only work with RichEdit 3.0 or higher - if you have this you can specify the alignment for the tab within the bits 24-27 of each entry in rgxTabs, i.e. somehow like this:

DWORD dwValue = 0x2 << 24;

DWORD dwTab = 200; // just a sample value

rgxTabs[0] = dwTab | dwValue;

(I did not test it, but IMO it should work)

Hope that helps,

ZOPPO
0
 

Author Closing Comment

by:rickatseasoft
ID: 31465589
Thanks for the help, rick
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

This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
Ready to get certified? Check out some courses that help you prepare for third-party exams.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…

609 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