BUG: GetTextExtentPoint Fails in App Based on Windows/Win32sLast reviewed: March 2, 1996Article ID: Q147647 |
The information in this article applies to:
SYMPTOMSGetTextExtentPoint fails when all of the following conditions are present:
GetTextExtentPoint - Invalid string CAUSEAs stated earlier, this problem occurs only when the allocated size of the string is an exact multiple of 32 bytes. This is a bug in Microsoft Windows 3.1 that causes ramifications in a 16-bit application running under Windows 3.1. A 16-bit application running under Windows NT 3.51 will have the same problem, but it will run without any problems under Windows 95. This bug is not specific to Win32s. However, because Win32s runs under the Windows environment, a 32-bit application running under Windows 3.1 by way of Win32s will also exhibit this problem. However, a 32-bit application running under Windows NT or Windows 95 will not exhibit this problem.
STATUSMicrosoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article. We are researching this problem and will post new information here in the Microsoft Knowledge Base as it becomes available.
MORE INFORMATIONNote that GetTextExtentPoint() will succeed if you pass a string constant that has a size that is a multiple of 32. For example, the following will work:
GetTextExtentPoint(hDC, "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", 32, &size); Sample Code to Reproduce ProblemNote that error checking is not implemented in the following code.
HGLOBAL hMem; HDC hDC; SIZE size; int blksize, i; char szMsg[256]; LPSTR lpBuf; blksize=32; #ifdef WIN32 SetLastError(0); #endif hDC = GetDC(hWnd); hMem = GlobalAlloc(GHND, blksize); lpBuf = (LPSTR) GlobalLock(hMem); for (i=0; i<blksize; i++) lpBuf[i] = 't'; if (!GetTextExtentPoint(hDC, lpBuf, blksize, &size)) { #ifdef WIN32 wsprintf(szMsg, "GetTextExtentPoint Error %d\r\n", GetLastError()); #else wsprintf(szMsg, "GetTextExtentPoint Error\r\n); #endif MessageBox(NULL, szMsg, "Test", MB_OK); } GlobalUnlock(hMem); #ifdef WIN32 SetLastError(0); #endif hMem = GlobalReAlloc(hMem, 2*blksize, GMEM_ZEROINIT); lpBuf = (LPSTR) GlobalLock(hMem); for (i=0; i<blksize; i++) lpBuf[blksize+i] = 'T'; if (!GetTextExtentPoint(hDC, lpBuf, 2*blksize, &size)) { #ifdef WIN32 wsprintf(szMsg, "GetTextExtentPoint Error %d\r\n", GetLastError()); #else wsprintf(szMsg, "GetTextExtentPoint Error \r\n"); #endif MessageBox(NULL, szMsg, "Test", MB_OK); } GlobalUnlock(hMem); if (hMem) GlobalFree(hMem); |
Additional reference words: win32s gdi 1.30c 4.00 3.10 3.51
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |