X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/b2d5a7ee008faae08694abd039f7da235da8bce5..763f55468e441e94e65a72b127c8fc2a48c91e91:/src/msw/window.cpp diff --git a/src/msw/window.cpp b/src/msw/window.cpp index b05e19decc..7e0faddaea 100644 --- a/src/msw/window.cpp +++ b/src/msw/window.cpp @@ -297,6 +297,7 @@ void wxWindowMSW::Init() m_oldWndProc = 0; m_useCtl3D = FALSE; m_mouseInWindow = FALSE; + m_lastKeydownProcessed = FALSE; // wxWnd m_hMenu = 0; @@ -391,8 +392,9 @@ bool wxWindowMSW::Create(wxWindow *parent, DWORD msflags = WS_VISIBLE | MSWGetCreateWindowFlags(&exstyle); #ifdef __WXUNIVERSAL__ - // no 3d effects, we draw them ourselves - exStyle = 0; + // no borders, we draw them ourselves + exstyle = 0; + msflags &= ~WS_BORDER; #endif // wxUniversal if ( style & wxPOPUP_WINDOW ) @@ -998,15 +1000,20 @@ bool wxCheckWindowWndProc(WXHWND hWnd, WXFARPROC wndProc) // FIXME: Doesn't handle wnd procs set by SetWindowLong, only these set // with RegisterClass!! - static wxChar buffer[512]; - WNDCLASS cls; + if ( wxUsingUnicowsDll() ) + { + static wxChar buffer[512]; + WNDCLASS cls; - ::GetClassName((HWND)hWnd, buffer, 512); - ::GetClassInfo(wxGetInstance(), buffer, &cls); - return wndProc == (WXFARPROC)cls.lpfnWndProc; -#else - return wndProc == (WXFARPROC)::GetWindowLong((HWND)hWnd, GWL_WNDPROC); + ::GetClassName((HWND)hWnd, buffer, 512); + ::GetClassInfo(wxGetInstance(), buffer, &cls); + return wndProc == (WXFARPROC)cls.lpfnWndProc; + } + else #endif + { + return wndProc == (WXFARPROC)::GetWindowLong((HWND)hWnd, GWL_WNDPROC); + } } // ---------------------------------------------------------------------------- @@ -1022,7 +1029,11 @@ void wxWindowMSW::SetWindowStyleFlag(long flags) // update the internal variable wxWindowBase::SetWindowStyleFlag(flags); - // now update the Windows style as well if needed + // now update the Windows style as well if needed - and if the window had + // been already created + if ( !GetHwnd() ) + return; + WXDWORD exstyle, exstyleOld; long style = MSWGetStyle(flags, &exstyle), styleOld = MSWGetStyle(flagsOld, &exstyleOld); @@ -1074,7 +1085,8 @@ WXDWORD wxWindowMSW::MSWGetStyle(long flags, WXDWORD *exstyle) const if ( flags & wxCLIP_SIBLINGS ) style |= WS_CLIPSIBLINGS; - if ( (flags & wxBORDER_MASK) != wxBORDER_NONE ) + wxBorder border = (wxBorder)(flags & wxBORDER_MASK); + if ( border != wxBORDER_NONE && border != wxBORDER_DEFAULT ) style |= WS_BORDER; // now deal with ext style if the caller wants it @@ -1093,6 +1105,7 @@ WXDWORD wxWindowMSW::MSWGetStyle(long flags, WXDWORD *exstyle) const case wxBORDER_NONE: case wxBORDER_SIMPLE: + case wxBORDER_DEFAULT: break; case wxBORDER_STATIC: @@ -1103,7 +1116,6 @@ WXDWORD wxWindowMSW::MSWGetStyle(long flags, WXDWORD *exstyle) const *exstyle |= WS_EX_WINDOWEDGE; break; - case wxBORDER_DEFAULT: case wxBORDER_SUNKEN: *exstyle |= WS_EX_CLIENTEDGE; break; @@ -1263,7 +1275,9 @@ void wxWindowMSW::OnIdle(wxIdleEvent& WXUNUSED(event)) // Check if we need to send a LEAVE event if ( m_mouseInWindow ) { - if ( !IsMouseInWindow() && !HasCapture()) + // note that we should generate the leave event whether the window has + // or doesn't have mouse capture + if ( !IsMouseInWindow() ) { // Generate a LEAVE event m_mouseInWindow = FALSE; @@ -1632,15 +1646,6 @@ void wxWindowMSW::DoSetClientSize(int width, int height) break; } - if ( i == 3 ) - { - // how did it happen? maybe OnSize() handler does something really - // strange in this class? - wxFAIL_MSG( _T("logic error in DoSetClientSize") ); - - break; - } - int widthClient = width, heightClient = height; @@ -2459,12 +2464,13 @@ long wxWindowMSW::MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam case WM_SYSKEYDOWN: case WM_KEYDOWN: + m_lastKeydownProcessed = FALSE; // If this has been processed by an event handler, // return 0 now (we've handled it). if ( HandleKeyDown((WORD) wParam, lParam) ) { processed = TRUE; - + m_lastKeydownProcessed = TRUE; break; } @@ -2472,7 +2478,6 @@ long wxWindowMSW::MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam if ( wParam == VK_SHIFT || wParam == VK_CONTROL ) { processed = TRUE; - break; } @@ -2699,21 +2704,6 @@ long wxWindowMSW::MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam } break; #endif // __WIN32__ - - // unfortunately this doesn't really work as then window which - // doesn't accept focus doesn't get any mouse events neither which - // means it can't get any input at all -#if 0 //def __WXUNIVERSAL__ - case WM_NCHITTEST: - // we shouldn't allow the windows which don't want to get focus to - // get it - if ( !AcceptsFocus() ) - { - rc.result = HTTRANSPARENT; - processed = TRUE; - } - break; -#endif // __WXUNIVERSAL__ } if ( !processed ) @@ -4046,6 +4036,14 @@ wxKeyEvent wxWindowMSW::CreateKeyEvent(wxEventType evType, // WM_KEYDOWN one bool wxWindowMSW::HandleChar(WXWPARAM wParam, WXLPARAM lParam, bool isASCII) { + if (m_lastKeydownProcessed) { + // The key was handled in the EVT_KEY_DOWN. Handling a key in an + // EVT_KEY_DOWN handler is meant, by design, to prevent EVT_CHARs + // from happening, so just bail out at this point. + m_lastKeydownProcessed = FALSE; + return TRUE; + } + bool ctrlDown = FALSE; int id; @@ -5160,6 +5158,7 @@ wxPoint wxGetMousePosition() { POINT pt; GetCursorPos( & pt ); + return wxPoint(pt.x, pt.y); }