X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/9923c37dccb4e5dbe6387ceb3ab0a8202fadc231..068b764a5a7cc2929b1fd8ea5643f43b5cbc8762:/src/os2/utilsgui.cpp diff --git a/src/os2/utilsgui.cpp b/src/os2/utilsgui.cpp index fd710bbc20..a48d2a0936 100644 --- a/src/os2/utilsgui.cpp +++ b/src/os2/utilsgui.cpp @@ -515,10 +515,12 @@ wxString WXDLLEXPORT wxGetWindowText( ) { wxString vStr; - long lLen = ::WinQueryWindowTextLength((HWND)hWnd) + 1; - ::WinQueryWindowText((HWND)hWnd, lLen, vStr.GetWriteBuf((int)lLen)); - vStr.UngetWriteBuf(); + if ( hWnd ) + { + long lLen = ::WinQueryWindowTextLength((HWND)hWnd) + 1; + ::WinQueryWindowText((HWND)hWnd, lLen, wxStringBuffer(vStr, lLen)); + } return vStr; } @@ -528,22 +530,24 @@ wxString WXDLLEXPORT wxGetWindowClass( ) { wxString vStr; - int nLen = 256; // some starting value - - for ( ;; ) + if ( hWnd ) { - int nCount = ::WinQueryClassName((HWND)hWnd, nLen, vStr.GetWriteBuf(nLen)); - - vStr.UngetWriteBuf(); - if (nCount == nLen ) - { - // the class name might have been truncated, retry with larger - // buffer - nLen *= 2; - } - else - { - break; + int nLen = 256; // some starting value + + for ( ;; ) + { + int nCount = ::WinQueryClassName((HWND)hWnd, nLen, wxStringBuffer(vStr, nLen)); + + if (nCount == nLen ) + { + // the class name might have been truncated, retry with larger + // buffer + nLen *= 2; + } + else + { + break; + } } } return vStr;