FIX: Print Preview Problems for Chars with ASCII Values > 127Last reviewed: September 18, 1997Article ID: Q116299 |
1.00 1.50 | 1.00
WINDOWS | WINDOWS NTkbprg kbfixlist kbbuglist The information in this article applies to:
SYMPTOMSMicrosoft Foundation Classes (MFC) library applications may have problems performing a print preview of text that contains characters with ASCII values greater than 127. The problems can range from uneven spacing of the characters to a general protection fault (GPF) when you try to activate a Print Preview.
CAUSEThe routine "CPreviewDC::ComputeDeltas()", located in the file DCPREV.CPP, passes signed char values as the second and third parameters to the function "::GetCharWidth()". However, ::GetCharWidth() takes unsigned integer values for its second and third parameters. In the process of converting from a signed char to an unsigned int, the wrong value is passed to ::GetCharWidth(), and the function either returns incorrect values or causes a GPF.
RESOLUTIONTo avoid the problem, you can modify the file DCPREV.CPP and declare the two variables "lpszCurChar" and "lpszStartRun" as being long pointers to unsigned const characters. See the "MORE INFORMATION" section, below, to see exactly what changes need to be made.
STATUSMicrosoft has confirmed this to be a bug in the products listed at the beginning of this article. This problem was corrected in MFC version 3.0, included with Visual C++ version 2.0.
MORE INFORMATIONThe function CPreviewDC::ComputeDeltas(,) located in the source file DCPREV.CPP, declares and uses two variables called lpszCurChar and lpszStartRun. These two variables are declared as being of type LPCSTR (in other words, 32-bit pointers to a const signed char). To avoid the problem of the pointers referring the ::GetCharWidth() function to passing characters, declare the variables lpszCurChar and lpszStartRun as being 32-bit pointers to const unsigned chars. With versions 2.0 and 2.5 of the MFC library supplied with Visual C++ for Windows, versions 1.0 and 1.5, this can be done when you define a new type called "LPCTSTR" with the following typedef:
typedef const unsigned char FAR * LPCTSTR;Place the definition of the LPCSTR type in the file DCPREV.CPP at global scope before the definition of the function "CPreviewDC::ComputeDeltas()". The LPCTSTR type is already defined in the 32-bit version of the MFC library (supplied with Visual C++ for Windows NT, version 1.0) and does not need to be defined in DCPREV.CPP with that version of the MFC library. The variables lpszCurChar and lpszStartRun should be declared as being of type LPCTSTR. To do this, make the changes listed below:
|
Additional reference words: international foreign extended umlaut 1.00 1.50
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |