choose implicit parent for the dialog boxes better, fixes weird focus jumps when using wxLog
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@16927 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -253,6 +253,7 @@ wxMSW:
|
|||||||
- fixed redraw problems in dynamically resized wxStaticText
|
- fixed redraw problems in dynamically resized wxStaticText
|
||||||
- improvements to wxWindows applications behaviour when the system colours
|
- improvements to wxWindows applications behaviour when the system colours
|
||||||
are changed
|
are changed
|
||||||
|
- choose implicit parent for the dialog boxes better
|
||||||
- fixed wxProgressDialog for ranges > 65535
|
- fixed wxProgressDialog for ranges > 65535
|
||||||
- wxSpinButton and wxSpinCtrl now support full 32 bit range (if the version
|
- wxSpinButton and wxSpinCtrl now support full 32 bit range (if the version
|
||||||
of comctl32.dll installed on the system supports it)
|
of comctl32.dll installed on the system supports it)
|
||||||
|
@@ -98,6 +98,12 @@ public:
|
|||||||
#endif // wxUSE_CTL3D
|
#endif // wxUSE_CTL3D
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
// find the window to use as parent for this dialog if none has been
|
||||||
|
// specified explicitly by the user
|
||||||
|
//
|
||||||
|
// may return NULL
|
||||||
|
wxWindow *FindSuitableParent() const;
|
||||||
|
|
||||||
// show modal dialog and enter modal loop
|
// show modal dialog and enter modal loop
|
||||||
void DoShowModal();
|
void DoShowModal();
|
||||||
|
|
||||||
|
@@ -194,6 +194,28 @@ bool wxDialog::IsModalShowing() const
|
|||||||
return wxModalDialogs.Find((wxDialog *)this) != NULL; // const_cast
|
return wxModalDialogs.Find((wxDialog *)this) != NULL; // const_cast
|
||||||
}
|
}
|
||||||
|
|
||||||
|
wxWindow *wxDialog::FindSuitableParent() const
|
||||||
|
{
|
||||||
|
// first try to use the currently active window
|
||||||
|
HWND hwndFg = ::GetForegroundWindow();
|
||||||
|
wxWindow *parent = hwndFg ? wxFindWinFromHandle((WXHWND)hwndFg)
|
||||||
|
: NULL;
|
||||||
|
if ( !parent )
|
||||||
|
{
|
||||||
|
// next try the main app window
|
||||||
|
parent = wxTheApp->GetTopWindow();
|
||||||
|
}
|
||||||
|
|
||||||
|
// finally, check if the parent we found is really suitable
|
||||||
|
if ( !parent || parent == (wxWindow *)this || !parent->IsShown() )
|
||||||
|
{
|
||||||
|
// don't use this one
|
||||||
|
parent = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return parent;
|
||||||
|
}
|
||||||
|
|
||||||
void wxDialog::DoShowModal()
|
void wxDialog::DoShowModal()
|
||||||
{
|
{
|
||||||
wxCHECK_RET( !IsModalShowing(), _T("DoShowModal() called twice") );
|
wxCHECK_RET( !IsModalShowing(), _T("DoShowModal() called twice") );
|
||||||
@@ -285,12 +307,7 @@ bool wxDialog::Show(bool show)
|
|||||||
// modal dialog needs a parent window, so try to find one
|
// modal dialog needs a parent window, so try to find one
|
||||||
if ( !GetParent() )
|
if ( !GetParent() )
|
||||||
{
|
{
|
||||||
wxWindow *parent = wxTheApp->GetTopWindow();
|
m_parent = FindSuitableParent();
|
||||||
if ( parent && parent != this && parent->IsShown() )
|
|
||||||
{
|
|
||||||
// use it
|
|
||||||
m_parent = parent;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DoShowModal();
|
DoShowModal();
|
||||||
|
@@ -46,8 +46,7 @@ wxMessageDialog::wxMessageDialog(wxWindow *parent,
|
|||||||
|
|
||||||
int wxMessageDialog::ShowModal()
|
int wxMessageDialog::ShowModal()
|
||||||
{
|
{
|
||||||
wxWindow *winTop = wxTheApp->GetTopWindow();
|
if ( !wxTheApp->GetTopWindow() )
|
||||||
if ( !winTop )
|
|
||||||
{
|
{
|
||||||
// when the message box is shown from wxApp::OnInit() (i.e. before the
|
// when the message box is shown from wxApp::OnInit() (i.e. before the
|
||||||
// message loop is entered), this must be done or the next message box
|
// message loop is entered), this must be done or the next message box
|
||||||
@@ -58,11 +57,9 @@ int wxMessageDialog::ShowModal()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// use the top level window as parent if none specified
|
// use the top level window as parent if none specified
|
||||||
HWND hWnd = 0;
|
if ( !m_parent )
|
||||||
if ( m_parent )
|
m_parent = FindSuitableParent();
|
||||||
hWnd = GetHwndOf(m_parent);
|
HWND hWnd = m_parent ? GetHwndOf(m_parent) : NULL;
|
||||||
else if ( winTop )
|
|
||||||
hWnd = GetHwndOf(winTop);
|
|
||||||
|
|
||||||
// translate wx style in MSW
|
// translate wx style in MSW
|
||||||
unsigned int msStyle = MB_OK;
|
unsigned int msStyle = MB_OK;
|
||||||
|
Reference in New Issue
Block a user