X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/220c6d434e3f4cf030a04c091b6fdd7436a92efd..2b4f3c9f768c91d1927c263f5db644cc16fca0b9:/src/msw/popupwin.cpp diff --git a/src/msw/popupwin.cpp b/src/msw/popupwin.cpp index ab65556566..87d82460ca 100644 --- a/src/msw/popupwin.cpp +++ b/src/msw/popupwin.cpp @@ -35,6 +35,8 @@ #include "wx/msw/private.h" // for WS_CHILD and WS_POPUP +wxWindowList wxPopupWindow::ms_shownPopups; + // ============================================================================ // implementation // ============================================================================ @@ -76,3 +78,43 @@ WXDWORD wxPopupWindow::MSWGetStyle(long flags, WXDWORD *exstyle) const return style; } +bool wxPopupWindow::Show(bool show) +{ + // skip wxWindow::Show() which calls wxBringWindowToTop(): this results in + // activating the popup window and stealing the atcivation from our parent + // which means that the parent frame becomes deactivated when opening a + // combobox, for example -- definitely not what we want + if ( !wxWindowBase::Show(show) ) + return FALSE; + + if ( show ) + { + ms_shownPopups.Append(this); + } + else // remove from the shown list + { + ms_shownPopups.DeleteObject(this); + } + + ::ShowWindow(GetHwnd(), show ? SW_SHOWNOACTIVATE : SW_HIDE); + + return TRUE; +} + +/* static */ +wxPopupWindow *wxPopupWindow::FindPopupFor(wxWindow *winParent) +{ + // find a popup with the given parent in the linked list of all shown + // popups + for ( wxWindowList::Node *node = ms_shownPopups.GetFirst(); + node; + node = node->GetNext() ) + { + wxWindow *win = node->GetData(); + if ( win->GetParent() == winParent ) + return (wxPopupWindow *)win; + } + + return NULL; +} +