FIX: ExtTextOut Causes Assertion in DCPREV.CPP or DCMETA.CPPLast reviewed: September 18, 1997Article ID: Q132288 |
1.50 1.51 1.52 | 2.00 2.10
WINDOWS | WINDOWS NTkbprg kbfixlist The information in this article applies to:
SYMPTOMSCalling ExtTextOut in a CView's OnDraw or OnPaint routine causes an assertion failure when Print Preview is used. The assertion failure occurs only when the lpszString parameter points to read-only memory. The assertion failure will occur on one of the following lines:
CAUSEThe cause is in an incorrect ASSERT statement in the CPreviewDC::ExtTextOut function as follows:
... ASSERT(AfxIsValidAddress(lpszString, nCount)); ...The documentation states (correctly) that AfxIsValidAddress takes an optional third parameter that specifies whether the memory is to be used for both reading and writing. It defaults to TRUE. Because this particular ASSERT does not provide the optional third parameter, the call to AfxIsValidAddress checks whether the memory pointed to by lpszString can be written to. If it cannot, the assertion fails. Note that there is no need for the ExtTextOut function to write to the memory pointed to by lpszString.
RESOLUTIONModify the call to ExtTextOut so that it passes non-read-only memory to the function. This can be done by storing your string data in a different location or by making a copy of the string data before calling the ExtTextOut function.
STATUSMicrosoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article. This problem was fixed in Microsoft Visual C++, 32-bit Edition, version 4.0.
|
Additional reference words: 1.50 1.51 1.52 2.50 2.51 2.52 2.00 2.10 3.00
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |