Re: Text box using rich edit control
I looked at some old code where I was doing zooms on edit controls, and I
noticed that I had to do some fudging on the zoom to get it to work
correctly.
m_RichEdit.SendMessage(EM_SETZOOM,(Zoom/100)*985,1000);
Don't ask me where I came up with 985, I think I did some trial an error.
I have some code for drawing the content of a richedit control on a DC using
scaling, that one uses the system metrics to come up with the fudge factor.
try this sample and let me know if this is what you wanted, and if not then
tell me what it does wrong:
http://www.learnstar.com/AliR/RichEditZoom.zip
Run the exe and put a number in the little edit box (50, 100, 200...) and
press zoom.
AliR.
"foobar" <somefoobar@gmail.com> wrote in message
news:1a51fbe8-de4d-4bc0-992f-c7b31ee2cd4f@r15g2000prh.googlegroups.com...
On Dec 18, 10:47 pm, "AliR \(VC++ MVP\)" <A...@online.nospam> wrote:
Ok I get it now.
Well as far as your window resizing code goes:
I don't know what GetZoom returns, but when you are calculating the
rectangle based on the zoom, you are working with ints instead of doubles,
so Width and Height would probably have a 0 value, assuming that nZoom has
a
value less than 100.
Anyway, this might work a little better
r = (int)(300 * nZoom / 100.0);
b = (int)(100 * nZoom / 100.0);
Just to focus on this zoom issue exclusively I am working on the
sample application.
For this sample it is guaranteed that GetZoom returns value greater
than equal to 50.
In fact I am changing zoom from 50 to 100 to 200 only and still I
could see that text is not remaining same
across zoom levels.
Do you simply want to display the content of the edit control on the view,
or do you have to have the actual edit control on there?
I need to display the content as well. When clicked on the box the
actual edit control should be shown.
But, again to exclusively focus on one issue currently I am always
showing actual edit control.
AliR.
"foobar" <somefoo...@gmail.com> wrote in message
news:d4646cee-11da-4633-afc1-417e78865eed@z27g2000prd.googlegroups.com...
Hi, Thanks for your comment. Please see my response below.
On Dec 18, 10:22 pm, "AliR \(VC++ MVP\)" <A...@online.nospam> wrote:
Is there a reason why you are not using CRichEditView?
Are you asking why CRichEditCtrl was picked over CRichEditView?
Yes that is what I was asking. I wanted to know the relationship between
the view and the edit control?
The edit control is a child window of view. The CView in my sample
displays many other elements such as images, lines, polygons, etc.
Rich text box is one such element. I am not sure if CRichEditView can
be used instead.
What is the relationship between the view's zoom and the edit's zoom?
All elements that are present on the view in my application should
respect the zoom value set for the view.
A common analogue is MS Word application and text box in the word
document.
The reason I'm asking these questions, is because I don't understand
what
you are asking for?
I hope that by giving MS Word analogue for zoom functionality, I am
clear now.
When you call EM_SETZOOM, the edit control will change the size of the
text.
If you want the text to be wrapped in the same exact place between the
zoom
levels then you will need to change the size of the edit control by the
zoom
factor.
Exactly. In the code excerpt that I sent in my previous post, I am
changing the size of the
rectangle before calling MoveWindow. I am not able to figure out where
I am doing the mistake.
Thanks again for any help.
AliR.