From b0a6bb75bcd4b5a4873d766a9208ac6376fe8625 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sat, 7 Oct 2000 20:19:10 +0000 Subject: [PATCH] 1. a couple of compilation warnings fixed (strconv/listctrl) 2. now reenable windows disabled by wxWindowDisabler slightly earlier: this solves the problem with "wrong" window being brought to top and eliminates the need for BringWindowToTop() and SetActiveWindow() in our code 3. style wxFRAME_FLOAT_ON_PARENT is now obsolete and unused, all frames have WS_EX_APPWINDOW style and appear on the taskbar git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@8487 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/defs.h | 4 +-- include/wx/msw/dialog.h | 12 ++++++-- include/wx/utils.h | 4 --- src/common/strconv.cpp | 4 +++ src/common/utilscmn.cpp | 34 --------------------- src/msw/dialog.cpp | 66 +++++++++++++++++++++-------------------- src/msw/frame.cpp | 14 ++++----- src/msw/listctrl.cpp | 1 - 8 files changed, 55 insertions(+), 84 deletions(-) diff --git a/include/wx/defs.h b/include/wx/defs.h index b850a396d0..c85c805dd1 100644 --- a/include/wx/defs.h +++ b/include/wx/defs.h @@ -919,8 +919,8 @@ enum wxStretch #define wxDIALOG_MODAL 0x0020 #define wxDIALOG_MODELESS 0x0000 -// Add for normal Windows frame behaviour -#define wxFRAME_FLOAT_ON_PARENT 0x0020 +// deprecated flag, don't use any more, defined for compatibility only +#define wxFRAME_FLOAT_ON_PARENT 0 // Context-sensitive help #define wxFRAME_EX_CONTEXTHELP 0x00000004 diff --git a/include/wx/msw/dialog.h b/include/wx/msw/dialog.h index ff51c4bdcf..f97ed29db0 100644 --- a/include/wx/msw/dialog.h +++ b/include/wx/msw/dialog.h @@ -23,10 +23,8 @@ WXDLLEXPORT_DATA(extern const wxChar*) wxDialogNameStr; // Dialog boxes class WXDLLEXPORT wxDialog : public wxDialogBase { - DECLARE_DYNAMIC_CLASS(wxDialog) - public: - wxDialog(); + wxDialog() { Init(); } // Constructor with a modal flag, but no window id - the old convention wxDialog(wxWindow *parent, @@ -116,9 +114,17 @@ protected: // show modal dialog and enter modal loop void DoShowModal(); + // common part of all ctors + void Init(); + private: wxWindow *m_oldFocus; + // while we are showing a modal dialog we disable the other windows using + // this object + class wxWindowDisabler *m_windowDisabler; + + DECLARE_DYNAMIC_CLASS(wxDialog) DECLARE_EVENT_TABLE() }; diff --git a/include/wx/utils.h b/include/wx/utils.h index c472247690..5329a493e6 100644 --- a/include/wx/utils.h +++ b/include/wx/utils.h @@ -305,10 +305,6 @@ public: private: wxWindowList *m_winDisabled; - -#ifdef __WXMSW__ - wxWindow *m_winTop; -#endif // MSW }; // ---------------------------------------------------------------------------- diff --git a/src/common/strconv.cpp b/src/common/strconv.cpp index baed36b001..d85340b877 100644 --- a/src/common/strconv.cpp +++ b/src/common/strconv.cpp @@ -87,6 +87,8 @@ WXDLLEXPORT_DATA(wxMBConv *) wxConvCurrent = &wxConvLibc; #if wxUSE_WCHAR_T +#ifdef WC_UTF16 + static size_t encode_utf16(wxUint32 input,wxUint16*output) { if (input<=0xffff) { @@ -119,6 +121,8 @@ static size_t decode_utf16(wxUint16*input,wxUint32&output) } } +#endif // WC_UTF16 + // ---------------------------------------------------------------------------- // wxMBConv // ---------------------------------------------------------------------------- diff --git a/src/common/utilscmn.cpp b/src/common/utilscmn.cpp index 796e131cf0..77de515356 100644 --- a/src/common/utilscmn.cpp +++ b/src/common/utilscmn.cpp @@ -1071,17 +1071,6 @@ void wxEnableTopLevelWindows(bool enable) wxWindowDisabler::wxWindowDisabler(wxWindow *winToSkip) { -#ifdef __WXMSW__ -#ifdef __WIN32__ - // and the top level window too - HWND hwndFG = ::GetForegroundWindow(); - m_winTop = hwndFG ? wxFindWinFromHandle((WXHWND)hwndFG) : (wxWindow *)NULL; -#else - HWND hwndFG = ::GetTopWindow(0); - m_winTop = hwndFG ? wxFindWinFromHandle((WXHWND)hwndFG) : (wxWindow *)NULL; -#endif -#endif // MSW - // remember the top level windows which were already disabled, so that we // don't reenable them later m_winDisabled = NULL; @@ -1123,29 +1112,6 @@ wxWindowDisabler::~wxWindowDisabler() } delete m_winDisabled; - -#ifdef __WXMSW__ -#ifdef __WIN32__ - if ( m_winTop ) - { - if ( !::SetForegroundWindow(GetHwndOf(m_winTop)) ) - { - wxLogLastError(wxT("SetForegroundWindow")); - } - } -#else - if ( m_winTop ) - { - // 16-bit SetForegroundWindow() replacement - RECT reWin; - GetWindowRect((HWND) m_winTop, &reWin); - SetWindowPos ((HWND) m_winTop, HWND_TOP, - reWin.left, reWin.top, - reWin.right - reWin.left, reWin.bottom, - SWP_SHOWWINDOW); - } -#endif -#endif // MSW } // Yield to other apps/messages and disable user input to all windows except diff --git a/src/msw/dialog.cpp b/src/msw/dialog.cpp index c7b8c547d1..9ae185092d 100644 --- a/src/msw/dialog.cpp +++ b/src/msw/dialog.cpp @@ -96,11 +96,14 @@ END_EVENT_TABLE() // wxDialog construction // ---------------------------------------------------------------------------- -wxDialog::wxDialog() +void wxDialog::Init() { m_oldFocus = (wxWindow *)NULL; + m_isShown = FALSE; + m_windowDisabler = (wxWindowDisabler *)NULL; + SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE)); } @@ -111,9 +114,10 @@ bool wxDialog::Create(wxWindow *parent, wxWindowID id, long style, const wxString& name) { + Init(); + m_oldFocus = FindFocus(); - SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE)); SetName(name); wxTopLevelWindows.Append(this); @@ -139,8 +143,6 @@ bool wxDialog::Create(wxWindow *parent, wxWindowID id, m_windowStyle = style; - m_isShown = FALSE; - if (width < 0) width = wxDIALOG_DEFAULT_WIDTH; if (height < 0) @@ -212,8 +214,7 @@ wxDialog::~wxDialog() wxTopLevelWindows.DeleteObject(this); - // this will call BringWindowToTop() if necessary to bring back our parent - // window to top + // this will also reenable all the other windows for a modal dialog Show(FALSE); if ( !IsModal() ) @@ -342,34 +343,34 @@ void wxDialog::DoShowModal() if (oldFocus) hwndOldFocus = (HWND) oldFocus->GetHWND(); - // inside this block, all app windows are disabled + // remember where the focus was + if ( !oldFocus ) { - wxWindowDisabler wd(this); + oldFocus = parent; + if ( parent ) + hwndOldFocus = GetHwndOf(parent); + } - // remember where the focus was - if ( !oldFocus ) - { - oldFocus = parent; - if (parent) - hwndOldFocus = (HWND) parent->GetHWND(); - } + // disable all other app windows + wxASSERT_MSG( !m_windowDisabler, _T("disabling windows twice?") ); - // enter the modal loop - while ( IsModalShowing() ) - { + m_windowDisabler = new wxWindowDisabler(this); + + // enter the modal loop + while ( IsModalShowing() ) + { #if wxUSE_THREADS - wxMutexGuiLeaveOrEnter(); + wxMutexGuiLeaveOrEnter(); #endif // wxUSE_THREADS - while ( !wxTheApp->Pending() && wxTheApp->ProcessIdle() ) - ; + while ( !wxTheApp->Pending() && wxTheApp->ProcessIdle() ) + ; - // a message came or no more idle processing to do - wxTheApp->DoMessage(); - } + // a message came or no more idle processing to do + wxTheApp->DoMessage(); } -#ifdef __WIN32__ +#if 0 //def __WIN32__ if ( parent ) ::SetActiveWindow(GetHwndOf(parent)); #endif // __WIN32__ @@ -388,16 +389,15 @@ void wxDialog::DoShowModal() bool wxDialog::Show(bool show) { - // The following is required when the parent has been disabled, (modal - // dialogs, or modeless dialogs with disabling such as wxProgressDialog). - // Otherwise the parent disappears behind other windows when the dialog is - // hidden. if ( !show ) { - wxWindow *parent = GetParent(); - if ( parent ) + // if we had disabled other app windows, reenable them back now because + // if they stay disabled Windows will activate another window (one + // which is enabled, anyhow) and we will lose activation + if ( m_windowDisabler ) { - ::BringWindowToTop(GetHwndOf(parent)); + delete m_windowDisabler; + m_windowDisabler = NULL; } } @@ -552,6 +552,7 @@ long wxDialog::MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam) switch ( message ) { +#if 0 // now that we got owner window right it doesn't seem to be needed case WM_ACTIVATE: switch ( LOWORD(wParam) ) { @@ -578,6 +579,7 @@ long wxDialog::MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam) // fall through to process it normally as well } break; +#endif // 0 case WM_CLOSE: // if we can't close, tell the system that we processed the diff --git a/src/msw/frame.cpp b/src/msw/frame.cpp index a76e556e13..be0e9d10e2 100644 --- a/src/msw/frame.cpp +++ b/src/msw/frame.cpp @@ -147,13 +147,6 @@ bool wxFrame::Create(wxWindow *parent, m_iconized = FALSE; - // we pass NULL as parent to MSWCreate because frames with parents behave - // very strangely under Win95 shell - // Alteration by JACS: keep normal Windows behaviour (float on top of parent) - // with this style. - if ((m_windowStyle & wxFRAME_FLOAT_ON_PARENT) == 0) - parent = NULL; - wxTopLevelWindows.Append(this); MSWCreate(m_windowId, parent, wxFrameClassName, this, title, @@ -672,9 +665,14 @@ bool wxFrame::MSWCreate(int id, wxWindow *parent, const wxChar *wclass, wxWindow WXDWORD extendedStyle = MakeExtendedStyle(style); + // make all frames appear in the win9x shell taskbar unless + // wxFRAME_TOOL_WINDOW is explicitly given - without giving them + // WS_EX_APPWINDOW style, the child (i.e. owned) frames wouldn't appear in it #if !defined(__WIN16__) && !defined(__SC__) if (style & wxFRAME_TOOL_WINDOW) - extendedStyle |= WS_EX_TOOLWINDOW; + extendedStyle |= WS_EX_TOOLWINDOW; + else + extendedStyle |= WS_EX_APPWINDOW; #endif if (style & wxSTAY_ON_TOP) diff --git a/src/msw/listctrl.cpp b/src/msw/listctrl.cpp index b4bd7519b7..539992500b 100644 --- a/src/msw/listctrl.cpp +++ b/src/msw/listctrl.cpp @@ -1737,7 +1737,6 @@ void wxListCtrl::OnPaint(wxPaintEvent& event) wxRect itemRect; int cy=0; - int lastH = 0; int itemCount = GetItemCount(); int i; for (i = 0; i < itemCount; i++) -- 2.45.2