Solved

CRichEdit Font and Alignment

Posted on 2008-06-09
4
408 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 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 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
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.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

929 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

10 Experts available now in Live!

Get 1:1 Help Now