ID: Q132288
1.50 1.51 1.52 | 2.00 2.10
WINDOWS | WINDOWS NT
kbprg kbfixlist
The information in this article applies to:
- Microsoft Visual C++ for Windows, versions 1.5, 1.51, 1.52
- Microsoft Visual C++, 32-bit Edition, versions 2.0, 2.1
Calling 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:
DCPREV.CPP - Line 588
DCPREV.CPP - Line 592
DCPREV.CPP - Line 594
The 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.
Modify 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.
Microsoft 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 3.10 KBCategory: kbprg kbfixlist kbbuglist KBSubcategory: MfcDocView
Keywords : kbDocView kbMFC kbVC kbbuglist kbfixlist
Version : 1.50 1.51 1.52 | 2.00 2.10
Platform : NT WINDOWS
Solution Type : kbfix
Last Reviewed: September 20, 1997