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
Solved

CRichEdit Font and Alignment

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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Suggested Solutions

Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
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.
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

807 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