Solved

Setting rect on CRichEditCtrl.

Posted on 2003-11-29
7
879 Views
Last Modified: 2013-11-20
I have a rich edit view.  The text runs all the way to the edges and I can't figure out how to set it in - give the control margins on the screen.  I use this...

CRect rect;
GetRichEditCtrl().GetRect(&rect);
rect.DeflateRect(15, 0);
GetRichEditCtrl().SetRect(&rect);

...in OnCreate in my Rich Edit View class and it works fine in XP.  But it doesn't in Win98.  I sat here for two hours trying every combination of getrect, getclientrect, setrect, invalidate, GetRichEditCtrl.Invalidate -- everything I can think of and I can't get the text to budge off the sides of the control.  The left side doesn't look too bad, but on the right side the text goes right up against the edge.  

Can someone please help me set the margins on a rich edit view?  Thanks.
0
Comment
Question by:jjjkkklll
  • 3
  • 3
7 Comments
 
LVL 48

Accepted Solution

by:
AlexFM earned 500 total points
ID: 9844563
Instead of rich edit view use CFormView with rich edit control and set rich edit rectangle in WM_SIZE message handler.
0
 

Author Comment

by:jjjkkklll
ID: 9845285
Hi AlexFM,

That would probably work, but I'm very dug in on this one - it's too late to change it all at this point.  Is there no way to change the typing area on an existing rich edit view?
0
 

Expert Comment

by:Particleness
ID: 9847164
The rich edit works on XP but not Windows 98...I had a problem when that happened and just replaced the rich edit control dll file on win98 with the xp one. If you're selling your product, though, I don't know how you can legally distribute the dll file.
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

Expert Comment

by:Particleness
ID: 9847324
I just researched the redistribution of rich edit controls and it happens you're out of luck: http://www.codeguru.com/mfc/comments/12047.shtml Sorry.
0
 

Expert Comment

by:Particleness
ID: 9847335
From that link you an get to a workaround with a microsoft installer, but then you bog down the user in installing MSI with your software.
0
 

Author Comment

by:jjjkkklll
ID: 9852187
Thanks Particleness for your info.  I finally used AlexFM's suggestion out of frustration.  What I did was to change my RichEditView to a FormView.  I created a new program with FormView as the view's base class and then took it file by file to change the view over.  Then I solved a pile of compiler errors one at a time.  Then I added the rich edit control and everything seems to work fine.  It actually didn't take as long as I thought it would (about 2 hours).  I'm sure there's a lot of extra code bits in there that I don't need anymore, but it's working so I'm not touching it.  Thanks for your help.
0
 

Author Comment

by:jjjkkklll
ID: 9852201
Just to clarify (after reading my last post) I compared my existing program to the new FormView program and I changed my existing program to have a formview - I didn't start from scratch, I converted my existing RichEditView to a FormView.  Just wanted to make that clear.  Thanks again.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
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.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

746 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

14 Experts available now in Live!

Get 1:1 Help Now