]>
git.saurik.com Git - wxWidgets.git/blob - src/msw/popupwin.cpp
a59d329bd2aa56bf3fbe61eec262b730022e59e7
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: src/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 // Licence: wxWindows licence
10 ///////////////////////////////////////////////////////////////////////////////
12 // ============================================================================
14 // ============================================================================
16 // ----------------------------------------------------------------------------
18 // ----------------------------------------------------------------------------
20 // For compilers that support precompilation, includes "wx.h".
21 #include "wx/wxprec.h"
32 #include "wx/popupwin.h"
34 #include "wx/msw/private.h" // for GetDesktopWindow()
36 // ============================================================================
38 // ============================================================================
40 bool wxPopupWindow::Create(wxWindow
*parent
, int flags
)
42 // popup windows are created hidden by default
45 return wxPopupWindowBase::Create(parent
) &&
46 wxWindow::Create(parent
, wxID_ANY
,
47 wxDefaultPosition
, wxDefaultSize
,
48 flags
| wxPOPUP_WINDOW
);
51 void wxPopupWindow::DoGetPosition(int *x
, int *y
) const
53 // the position of a "top level" window such as this should be in
54 // screen coordinates, not in the client ones which MSW gives us
55 // (because we are a child window)
56 wxPopupWindowBase::DoGetPosition(x
, y
);
58 GetParent()->ClientToScreen(x
, y
);
61 WXDWORD
wxPopupWindow::MSWGetStyle(long flags
, WXDWORD
*exstyle
) const
63 // we only honour the border flags, the others don't make sense for us
64 WXDWORD style
= wxWindow::MSWGetStyle(flags
& wxBORDER_MASK
, exstyle
);
68 // a popup window floats on top of everything
69 *exstyle
|= WS_EX_TOPMOST
| WS_EX_TOOLWINDOW
;
75 WXHWND
wxPopupWindow::MSWGetParent() const
77 // we must be a child of the desktop to be able to extend beyond the parent
78 // window client area (like the comboboxes drop downs do)
80 // NB: alternative implementation would be to use WS_POPUP instead of
81 // WS_CHILD but then showing a popup would deactivate the parent which
82 // is ugly and working around this, although possible, is even more
84 // GetDesktopWindow() is not always supported on WinCE, and if
85 // it is, it often returns NULL.
89 return (WXHWND
)::GetDesktopWindow();
93 bool wxPopupWindow::Show(bool show
)
95 if ( !wxWindowMSW::Show(show
) )
100 // raise to top of z order
101 if (!::SetWindowPos(GetHwnd(), HWND_TOP
, 0, 0, 0, 0, SWP_NOMOVE
| SWP_NOSIZE
))
103 wxLogLastError(wxT("SetWindowPos"));
106 // and set it as the foreground window so the mouse can be captured
107 ::SetForegroundWindow(GetHwnd());
113 #endif // #if wxUSE_POPUPWIN