Listing 1 MessageBox() used as a simple debugging aid
BOOL check_wndtext_len(HWND hwnd, LPCTSTR txt) { #ifdef _DEBUG if( hwnd != NULL && !IsWindow(hwnd)) { MessageBox( NULL, "The given window handle was invalid", "check_wndtext_len", MB_ICONEXCLAMATION); } #endif /* _DEBUG */ return hwnd != NULL && lstrlenA(txt) < GetWindowTextLength(hwnd); }