don't crash in wxGetWindowXXX() if HWND is 0
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@12895 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
be050baf48
commit
5acc0d5f32
@ -1381,59 +1381,47 @@ void wxClientDisplayRect(int *x, int *y, int *width, int *height)
|
|||||||
wxString WXDLLEXPORT wxGetWindowText(WXHWND hWnd)
|
wxString WXDLLEXPORT wxGetWindowText(WXHWND hWnd)
|
||||||
{
|
{
|
||||||
wxString str;
|
wxString str;
|
||||||
int len = GetWindowTextLength((HWND)hWnd) + 1;
|
|
||||||
GetWindowText((HWND)hWnd, str.GetWriteBuf(len), len);
|
if ( hWnd )
|
||||||
str.UngetWriteBuf();
|
{
|
||||||
|
int len = GetWindowTextLength((HWND)hWnd) + 1;
|
||||||
|
::GetWindowText((HWND)hWnd, str.GetWriteBuf(len), len);
|
||||||
|
str.UngetWriteBuf();
|
||||||
|
}
|
||||||
|
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxString WXDLLEXPORT wxGetWindowClass(WXHWND hWnd)
|
wxString WXDLLEXPORT wxGetWindowClass(WXHWND hWnd)
|
||||||
{
|
{
|
||||||
#ifdef __WXMICROWIN__
|
|
||||||
// MICROWIN_TODO
|
|
||||||
return wxEmptyString;
|
|
||||||
#else
|
|
||||||
wxString str;
|
wxString str;
|
||||||
|
|
||||||
int len = 256; // some starting value
|
// MICROWIN_TODO
|
||||||
|
#ifndef __WXMICROWIN__
|
||||||
for ( ;; )
|
if ( hWnd )
|
||||||
{
|
{
|
||||||
// as we've #undefined GetClassName we must now manually choose the
|
int len = 256; // some starting value
|
||||||
// right function to call
|
|
||||||
int count =
|
|
||||||
|
|
||||||
#ifndef __WIN32__
|
for ( ;; )
|
||||||
GetClassName
|
{
|
||||||
#else // Win32
|
int count = ::GetClassName((HWND)hWnd, str.GetWriteBuf(len), len);
|
||||||
#ifdef UNICODE
|
|
||||||
GetClassNameW
|
|
||||||
#else // !Unicode
|
|
||||||
#ifdef __TWIN32__
|
|
||||||
GetClassName
|
|
||||||
#else // !Twin32
|
|
||||||
GetClassNameA
|
|
||||||
#endif // Twin32/!Twin32
|
|
||||||
#endif // Unicode/ANSI
|
|
||||||
#endif // Win16/32
|
|
||||||
((HWND)hWnd, str.GetWriteBuf(len), len);
|
|
||||||
|
|
||||||
str.UngetWriteBuf();
|
str.UngetWriteBuf();
|
||||||
if ( count == len )
|
if ( count == len )
|
||||||
{
|
{
|
||||||
// the class name might have been truncated, retry with larger
|
// the class name might have been truncated, retry with larger
|
||||||
// buffer
|
// buffer
|
||||||
len *= 2;
|
len *= 2;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif // !__WXMICROWIN__
|
||||||
|
|
||||||
return str;
|
return str;
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
WXWORD WXDLLEXPORT wxGetWindowId(WXHWND hWnd)
|
WXWORD WXDLLEXPORT wxGetWindowId(WXHWND hWnd)
|
||||||
|
Loading…
Reference in New Issue
Block a user