-
December 13th, 2012, 09:26 AM
#1
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
Here is my code:
Code:
DrawRTF(TextToDraw,100 * 1.0);
static void BSDrawRTF(const char * t, const char* limit)
{
gs_LastRTFWidth = 0;
gs_LastRTFHeight = 0;
if (strlen(t) == 0)
return;
long Limit = max(0,atol(limit));
CTORTFFormater::GetEdit()->SetWindowText(t);
CDC dcTarget;
dcTarget.CreateDC("DISPLAY", NULL, NULL, NULL);
dcTarget.SaveDC();
CRect OutRect;
OutRect.left = 0;
OutRect.top = 0;
OutRect.right = Limit ?
::MulDiv(Limit, 1440, dcTarget.GetDeviceCaps(LOGPIXELSX)) :
MM_TO_TWIPS(CTORTFFormater::GetEdit()->GetControlWidth());
OutRect.bottom = 500000;
CTORTFFormater::GetEdit()->SetTargetDevice(dcTarget, OutRect.right);
FORMATRANGE FRange;
FRange.hdc = dcTarget.m_hDC;
FRange.hdcTarget = dcTarget.m_hDC;
FRange.rc = OutRect;
FRange.rcPage = OutRect;
FRange.chrg.cpMin = 0;
FRange.chrg.cpMax = CTORTFFormater::GetEdit()->GetTextLength();
long lIndex = CTORTFFormater::GetEdit()->FormatRange(&FRange, FALSE);
gs_LastRTFWidth = ::MulDiv(dcTarget.GetDeviceCaps(LOGPIXELSX), FRange.rc.right, 1440);
gs_LastRTFHeight = ::MulDiv(dcTarget.GetDeviceCaps(LOGPIXELSX), FRange.rc.bottom, 1440);
CTORTFFormater::GetEdit()->FormatRange(NULL, FALSE); // release the cached DC information stored in SetTargetDevice
CTORTFFormater::GetEdit()->SetControlWidth(0); // restore the original
dcTarget.RestoreDC(-1);
dcTarget.DeleteDC();
CString s;
s.Format("RTFTEXT:%d,%d,%d,%ld", gs_CurrentPainter->AddRTFText(t), gs_LastRTFWidth, gs_LastRTFHeight, Limit);
gs_PaintData += s + "\r\n";
}
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|