X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/d4cd85a064e4ccce92cf909ba7eac90614909b32..db60c20db8321d7fb0604e33fe7288ddb38c496e:/src/msw/window.cpp diff --git a/src/msw/window.cpp b/src/msw/window.cpp index 65d0cfbe77..4dcdf623f0 100644 --- a/src/msw/window.cpp +++ b/src/msw/window.cpp @@ -46,6 +46,7 @@ #include "wx/sizer.h" #include "wx/intl.h" #include "wx/log.h" + #include "wx/textctrl.h" #endif #if wxUSE_OWNER_DRAWN && !defined(__WXUNIVERSAL__) @@ -89,7 +90,6 @@ #include "wx/spinctrl.h" #endif // wxUSE_SPINCTRL -#include "wx/textctrl.h" #include "wx/notebook.h" #include "wx/listctrl.h" @@ -1147,6 +1147,25 @@ void wxWindowMSW::SetWindowStyleFlag(long flags) // update the internal variable wxWindowBase::SetWindowStyleFlag(flags); + // and the real window flags + MSWUpdateStyle(flagsOld, GetExtraStyle()); +} + +void wxWindowMSW::SetExtraStyle(long exflags) +{ + long exflagsOld = GetExtraStyle(); + if ( exflags == exflagsOld ) + return; + + // update the internal variable + wxWindowBase::SetExtraStyle(exflags); + + // and the real window flags + MSWUpdateStyle(GetWindowStyleFlag(), exflagsOld); +} + +void wxWindowMSW::MSWUpdateStyle(long flagsOld, long exflagsOld) +{ // now update the Windows style as well if needed - and if the window had // been already created if ( !GetHwnd() ) @@ -1155,9 +1174,21 @@ void wxWindowMSW::SetWindowStyleFlag(long flags) // we may need to call SetWindowPos() when we change some styles bool callSWP = false; - WXDWORD exstyle, exstyleOld; - long style = MSWGetStyle(flags, &exstyle), - styleOld = MSWGetStyle(flagsOld, &exstyleOld); + WXDWORD exstyle; + long style = MSWGetStyle(GetWindowStyleFlag(), &exstyle); + + // this is quite a horrible hack but we need it because MSWGetStyle() + // doesn't take exflags as parameter but uses GetExtraStyle() internally + // and so we have to modify the window exflags temporarily to get the + // correct exstyleOld + long exflagsNew = GetExtraStyle(); + wxWindowBase::SetExtraStyle(exflagsOld); + + WXDWORD exstyleOld; + long styleOld = MSWGetStyle(flagsOld, &exstyleOld); + + wxWindowBase::SetExtraStyle(exflagsNew); + if ( style != styleOld ) { @@ -1171,14 +1202,8 @@ void wxWindowMSW::SetWindowStyleFlag(long flags) ::SetWindowLong(GetHwnd(), GWL_STYLE, styleReal); - // If any of the style changes changed any of the frame styles: - // MSDN: SetWindowLong: - // Certain window data is cached, so changes you make using - // SetWindowLong will not take effect until you call the - // SetWindowPos function. Specifically, if you change any of - // the frame styles, you must call SetWindowPos with the - // SWP_FRAMECHANGED flag for the cache to be updated properly. - + // we need to call SetWindowPos() if any of the styles affecting the + // frame appearance have changed callSWP = ((styleOld ^ style ) & (WS_BORDER | WS_THICKFRAME | WS_CAPTION | @@ -3000,50 +3025,48 @@ WXLRESULT wxWindowMSW::MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM l #if defined(WM_HELP) case WM_HELP: { - // HELPINFO doesn't seem to be supported on WinCE. + // by default, WM_HELP is propagated by DefWindowProc() upwards + // to the window parent but as we do it ourselves already + // (wxHelpEvent is derived from wxCommandEvent), we don't want + // to get the other events if we process this message at all + processed = true; + + // WM_HELP doesn't use lParam under CE #ifndef __WXWINCE__ HELPINFO* info = (HELPINFO*) lParam; - // Don't yet process menu help events, just windows - if (info->iContextType == HELPINFO_WINDOW) + if ( info->iContextType == HELPINFO_WINDOW ) { -#endif - wxWindowMSW* subjectOfHelp = this; - bool eventProcessed = false; - while (subjectOfHelp && !eventProcessed) - { - wxHelpEvent helpEvent(wxEVT_HELP, - subjectOfHelp->GetId(), +#endif // !__WXWINCE__ + wxHelpEvent helpEvent + ( + wxEVT_HELP, + GetId(), #ifdef __WXWINCE__ - wxPoint(0,0) + wxGetMousePosition() // what else? #else - wxPoint(info->MousePos.x, info->MousePos.y) + wxPoint(info->MousePos.x, info->MousePos.y) #endif - ); + ); - helpEvent.SetEventObject(this); - eventProcessed = - GetEventHandler()->ProcessEvent(helpEvent); - - // Go up the window hierarchy until the event is - // handled (or not) - subjectOfHelp = subjectOfHelp->GetParent(); - } - - processed = eventProcessed; + helpEvent.SetEventObject(this); + GetEventHandler()->ProcessEvent(helpEvent); #ifndef __WXWINCE__ } - else if (info->iContextType == HELPINFO_MENUITEM) + else if ( info->iContextType == HELPINFO_MENUITEM ) { wxHelpEvent helpEvent(wxEVT_HELP, info->iCtrlId); helpEvent.SetEventObject(this); - processed = GetEventHandler()->ProcessEvent(helpEvent); + GetEventHandler()->ProcessEvent(helpEvent); } - //else: processed is already false -#endif + else // unknown help event? + { + processed = false; + } +#endif // !__WXWINCE__ } break; -#endif +#endif // WM_HELP #if !defined(__WXWINCE__) case WM_CONTEXTMENU: @@ -3393,7 +3416,7 @@ bool wxWindowMSW::HandleTooltipNotify(WXUINT code, // Truncate tooltip length if needed as otherwise we might not have // enough space for it in the buffer and MultiByteToWideChar() would // return an error - size_t tipLength = wxMin(ttip.Len(), WXSIZEOF(buf) - 1); + size_t tipLength = wxMin(ttip.length(), WXSIZEOF(buf) - 1); // Convert to WideChar without adding the NULL character. The NULL // character is added afterwards (this is more efficient). @@ -6220,18 +6243,10 @@ wxWindow* wxFindWindowAtPoint(const wxPoint& pt) POINT pt2; pt2.x = pt.x; pt2.y = pt.y; - HWND hWndHit = ::WindowFromPoint(pt2); - wxWindow* win = wxFindWinFromHandle((WXHWND) hWndHit) ; - HWND hWnd = hWndHit; + HWND hWnd = ::WindowFromPoint(pt2); - // Try to find a window with a wxWindow associated with it - while (!win && (hWnd != 0)) - { - hWnd = ::GetParent(hWnd); - win = wxFindWinFromHandle((WXHWND) hWnd) ; - } - return win; + return wxGetWindowFromHWND((WXHWND)hWnd); } // Get the current mouse position.