Solved

CRichEdit Font and Alignment

Posted on 2008-06-09
4
404 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
  • 2
  • 2
4 Comments
 
LVL 30

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 30

Accepted Solution

by:
Zoppo earned 500 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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Suggested Solutions

Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
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.
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

747 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

12 Experts available now in Live!

Get 1:1 Help Now