CRichEditCtrl::FormatRange result differ in VC++ 6.0 and 2010
Hello,
Ich have ported my application from VC++ 6.0 to VC++ 2010.
Now code that was working in VC++ 6.0 is not working anymore in VC++ 2010.
In my case I am writing text to a CRTFEditCtrl and then want to calculate the height of the complete text.
For calculating the height the FORMATRANGE.rc.bottom value, that has been returned from the CRichEditCtrl::FormatRange() fct., is used.
In VC++ 6.0 the rc.bottom value is '=2160' whereas in VC++ 2010 the value is '=499920'.
Also the return value of FormatRange() differs, in VC++ 6.0 it is '=104' and in VC++ 2010 it is '=103'
Does anybody what the Problem could be?
In the code below the value I get for 'gs_LastRTFHeight' is '=144' in VC++ 6.0 and '=33328' in VC++ 2010
Last edited by Vanaj; December 13th, 2012 at 12:52 PM.
Jim
ATP BE400 CE500 (C550B-SPW) CE560XL MU300 CFI CFII
"The speed of non working code is irrelevant"... Of course that is just my opinion, I could be wrong.
"Nothing in the world can take the place of persistence. Talent will not; nothing is more common than unsuccessful men with talent. Genius will not; unrewarded genius is almost a proverb. Education will not; the world is full of educated derelicts. Persistence and determination are omnipotent. The slogan 'press on' has solved and always will solve the problems of the human race."...Calvin Coolidge 30th President of the USA.
Re: CRichEditCtrl::FormatRange result differ in VC++ 6.0 and 2010
Hello Vanja,
Thank you very much for your answer. Your are right its better to calculate the heigth using LOGPIXELSY rather then LOGPIXELSX, but the calculation is not the problem here.
The problem is that the FORMATRANGE.rc.bottom value is way to big after calling the FormatRange() fct.
In VC++ 6.0 the FORMATRANGE.rc.bottom value is =2160 and in VC++ 2010 it is =499920.
Re: CRichEditCtrl::FormatRange result differ in VC++ 6.0 and 2010
Originally Posted by rgwerder1
The problem is that the FORMATRANGE.rc.bottom value is way to big after calling the FormatRange() fct.
In VC++ 6.0 the FORMATRANGE.rc.bottom value is =2160 and in VC++ 2010 it is =499920.
Well, why not debug both the VC 6.0 and VC 2010 and see where the results start to diverge? Be your own problem solver.
You should have the full MFC source code, so unless it is a change in the MFC source code, the issue may be your own code and not the differences in the compiler. It would also help if you made just one function call per line, instead of assuming what a function will return and use that return value.
Code:
CTORTFFormater::GetEdit()->
You keep doing that over and over again in that piece of code. First, never assume that you get back a valid CWnd or the CWnd that you're expecting to get back. Second, assign the return value to a CWnd* variable and just use that variable. This saves from you making the function call repeatedly.
What is "GetEdit()"? I don't think it's an MFC function, unless I'm mistaken.
Do you know what these are, or are you assuming what these values are? Again, store these in variables, inspect to make sure they are exactly the same and valid, and then just use those variable.
Once you've established that the GetEdit() returns a valid CWnd pointer, and those values are exactly the same between versions of VC++, then debug into the FormatRange() function to see what's going on.
Regards,
Paul McKenzie
Last edited by Paul McKenzie; December 14th, 2012 at 10:24 AM.
Re: CRichEditCtrl::FormatRange result differ in VC++ 6.0 and 2010
Chech which version of RichEdit control is used in your aplication. Different versions of MFC may load different RichEdit versions, that may behave different in some particular cases.
As an example, CRichEditView loads and uses RichEdit control version 1.0 in VS6.0. In VS2010, version 2.1 is loaded and used.
Bookmarks