X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/eb5e4d9ac1527441fe107460c7fee93092175a3e..cf31a1d7b60feddf23cc30259c6d909d4736ca56:/src/msw/window.cpp diff --git a/src/msw/window.cpp b/src/msw/window.cpp index 4cfa88b3c9..5f4c38e7fe 100644 --- a/src/msw/window.cpp +++ b/src/msw/window.cpp @@ -377,7 +377,7 @@ bool wxWindowMSW::Create(wxWindow *parent, // // the correct solution is to create the controls as siblings of the // static box - wxASSERT_MSG( !wxDynamicCastThis(wxStaticBox), + wxASSERT_MSG( !wxDynamicCast(parent, wxStaticBox), _T("wxStaticBox can't be used as a window parent!") ); #endif // wxUSE_STATBOX @@ -450,23 +450,18 @@ void wxWindowMSW::SetFocus() if ( !::SetFocus(hWnd) ) { +#if defined(__WXDEBUG__) && !defined(__WXMICROWIN__) // was there really an error? -#ifndef __WXMICROWIN__ DWORD dwRes = ::GetLastError(); -#else - - DWORD dwRes = 0; -#endif if ( dwRes ) { - wxLogApiError(_T("SetFocus"), dwRes); + HWND hwndFocus = ::GetFocus(); + if ( hwndFocus != hWnd ) + { + wxLogApiError(_T("SetFocus"), dwRes); + } } - - // VZ: just why does this happen sometimes?? any idea? -#if 0 - HWND hwndFocus = ::GetFocus(); - wxASSERT_MSG( hwndFocus == hWnd, _T("SetFocus() didn't work?") ); -#endif // 0 +#endif // Debug } } @@ -1446,6 +1441,12 @@ void wxWindowMSW::DoClientToScreen(int *x, int *y) const void wxWindowMSW::DoMoveWindow(int x, int y, int width, int height) { + // TODO: is this consistent with other platforms? + // Still, negative width or height shouldn't be allowed + if (width < 0) + width = 0; + if (height < 0) + height = 0; if ( !::MoveWindow(GetHwnd(), x, y, width, height, TRUE) ) { wxLogLastError(wxT("MoveWindow")); @@ -1527,11 +1528,13 @@ void wxWindowMSW::DoSetClientSize(int width, int height) // will not be correct as the difference between the total and client size // changes - so we keep changing it until we get it right // - // normally this loop shouldn't take more than 2 iterations (usually 1 but - // if scrollbars [dis]appear as the result of the first call, then 2) but - // just to be on the safe side we check for it instead of making it an + // normally this loop shouldn't take more than 3 iterations (usually 1 but + // if scrollbars [dis]appear as the result of the first call, then 2 and it + // may become 3 if the window had 0 size originally and so we didn't + // calculate the scrollbar correction correctly during the first iteration) + // but just to be on the safe side we check for it instead of making it an // "infinite" loop (i.e. leaving break inside as the only way to get out) - for ( int i = 0; i < 3; i++ ) + for ( int i = 0; i < 4; i++ ) { RECT rectClient; ::GetClientRect(GetHwnd(), &rectClient); @@ -1542,7 +1545,7 @@ void wxWindowMSW::DoSetClientSize(int width, int height) break; } - if ( i == 2 ) + if ( i == 3 ) { // how did it happen? maybe OnSize() handler does something really // strange in this class?