]>
git.saurik.com Git - wxWidgets.git/blob - src/msw/popupwin.cpp
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: msw/popupwin.cpp
3 // Purpose: implements wxPopupWindow for MSW
4 // Author: Vadim Zeitlin
8 // Copyright: (c) 2002 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
9 // License: wxWindows licence
10 ///////////////////////////////////////////////////////////////////////////////
12 // ============================================================================
14 // ============================================================================
16 // ----------------------------------------------------------------------------
18 // ----------------------------------------------------------------------------
21 #pragma implementation "popup.h"
24 // For compilers that support precompilation, includes "wx.h".
25 #include "wx/wxprec.h"
36 #include "wx/popupwin.h"
38 #include "wx/msw/private.h" // for GetDesktopWindow()
40 IMPLEMENT_DYNAMIC_CLASS(wxPopupWindow
, wxWindow
)
42 // ============================================================================
44 // ============================================================================
46 bool wxPopupWindow::Create(wxWindow
*parent
, int flags
)
48 return wxPopupWindowBase::Create(parent
) &&
49 wxWindow::Create(parent
, -1,
50 wxDefaultPosition
, wxDefaultSize
,
51 flags
| wxPOPUP_WINDOW
);
54 void wxPopupWindow::DoGetPosition(int *x
, int *y
) const
56 // the position of a "top level" window such as this should be in
57 // screen coordinates, not in the client ones which MSW gives us
58 // (because we are a child window)
59 wxPopupWindowBase::DoGetPosition(x
, y
);
61 GetParent()->ClientToScreen(x
, y
);
64 WXDWORD
wxPopupWindow::MSWGetStyle(long flags
, WXDWORD
*exstyle
) const
66 // we only honour the border flags, the others don't make sense for us
67 WXDWORD style
= wxWindow::MSWGetStyle(flags
& wxBORDER_MASK
, exstyle
);
71 // a popup window floats on top of everything
72 *exstyle
|= WS_EX_TOPMOST
| WS_EX_TOOLWINDOW
;
78 WXHWND
wxPopupWindow::MSWGetParent() const
80 // we must be a child of the desktop to be able to extend beyond the parent
81 // window client area (like the comboboxes drop downs do)
83 // NB: alternative implementation would be to use WS_POPUP instead of
84 // WS_CHILD but then showing a popup would deactivate the parent which
85 // is ugly and working around this, although possible, is even more
87 return (WXHWND
)::GetDesktopWindow();
90 bool wxPopupWindow::Show(bool show
)
92 if ( !wxWindowMSW::Show(show
) )
97 // raise to top of z order
98 if (!::SetWindowPos(GetHwnd(), HWND_TOP
, 0, 0, 0, 0, SWP_NOMOVE
| SWP_NOSIZE
))
100 wxLogLastError(_T("SetWindowPos"));
107 #endif // #if wxUSE_POPUPWIN