Timo Kreuzer wrote:
Ok, I need to defend Magnus here, I guess (thanks
KJK::Hyperion for
noticing)
here's how I tested the behavior of GetTextFaceW:
#define WIN32_LEAN_AND_MEAN
#define STRICT
#define NOMINMAX
#include <windows.h>
#include <stdio.h>
#include <tchar.h>
int main()
{
HDC hdc = CreateCompatibleDC(NULL);
TCHAR buf[1];
int c = ARRAYSIZE(buf);
LPTSTR lpName = buf;
SetLastError(1); _tprintf(_T("GetTextFace(hdc, %d, %p) -> %d,
GetLastError() -> %lu\n"), 0, NULL, GetTextFace(hdc, 0, NULL),
GetLastError());
SetLastError(1); _tprintf(_T("GetTextFace(hdc, %d, %p) -> %d,
GetLastError() -> %lu\n"), 0, lpName, GetTextFace(hdc, 0, lpName),
GetLastError());
SetLastError(1); _tprintf(_T("GetTextFace(hdc, %d, %p) -> %d,
GetLastError() -> %lu\n"), c, lpName, GetTextFace(hdc, c, lpName),
GetLastError());
SetLastError(1); _tprintf(_T("GetTextFace(hdc, %d, %p) -> %d,
GetLastError() -> %lu\n"), c, NULL, GetTextFace(hdc, c, NULL),
GetLastError());
}
// EOF
And this is the output:
GetTextFace(hdc, 0, 00000000) -> 7, GetLastError() -> 1
GetTextFace(hdc, 0, 0021FD70) -> 0, GetLastError() -> 1
GetTextFace(hdc, 1, 0021FD70) -> 1, GetLastError() -> 1
GetTextFace(hdc, 1, 00000000) -> 7, GetLastError() -> 1
(7 is sizeof("System"))
When lpName is NULL, the API always return the required size, ignoring
c. If a buffer is specified, it must be at least 1 character long (0
characters won't even fit an empty string), otherwise failure. Hence,
the success conditional is !(lpName && !c), i.e. (!lpName || c), which
is what it had been all along