Solved

CRichEdit Font and Alignment

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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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
sum28 challenge 31 117
matchUp  challenge 6 78
Problem to event 3 114
Is there a simple front-end menu system. 9 124
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…
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
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.
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

730 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