]>
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 // ----------------------------------------------------------------------------
20 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
21 #pragma implementation "popup.h"
24 // For compilers that support precompilation, includes "wx.h".
25 #include "wx/wxprec.h"
37 #include "wx/popupwin.h"
39 #include "wx/msw/private.h" // for GetDesktopWindow()
41 // ============================================================================
43 // ============================================================================
45 bool wxPopupWindow::Create(wxWindow
*parent
, int flags
)
47 // popup windows are created hidden by default
50 return wxPopupWindowBase::Create(parent
) &&
51 wxWindow::Create(parent
, wxID_ANY
,
52 wxDefaultPosition
, wxDefaultSize
,
53 flags
| wxPOPUP_WINDOW
);
56 void wxPopupWindow::DoGetPosition(int *x
, int *y
) const
58 // the position of a "top level" window such as this should be in
59 // screen coordinates, not in the client ones which MSW gives us
60 // (because we are a child window)
61 wxPopupWindowBase::DoGetPosition(x
, y
);
63 GetParent()->ClientToScreen(x
, y
);
66 WXDWORD
wxPopupWindow::MSWGetStyle(long flags
, WXDWORD
*exstyle
) const
68 // we only honour the border flags, the others don't make sense for us
69 WXDWORD style
= wxWindow::MSWGetStyle(flags
& wxBORDER_MASK
, exstyle
);
73 // a popup window floats on top of everything
74 *exstyle
|= WS_EX_TOPMOST
| WS_EX_TOOLWINDOW
;
80 WXHWND
wxPopupWindow::MSWGetParent() const
82 // we must be a child of the desktop to be able to extend beyond the parent
83 // window client area (like the comboboxes drop downs do)
85 // NB: alternative implementation would be to use WS_POPUP instead of
86 // WS_CHILD but then showing a popup would deactivate the parent which
87 // is ugly and working around this, although possible, is even more
89 // GetDesktopWindow() is not always supported on WinCE, and if
90 // it is, it often returns NULL.
94 return (WXHWND
)::GetDesktopWindow();
98 bool wxPopupWindow::Show(bool show
)
100 if ( !wxWindowMSW::Show(show
) )
105 // raise to top of z order
106 if (!::SetWindowPos(GetHwnd(), HWND_TOP
, 0, 0, 0, 0, SWP_NOMOVE
| SWP_NOSIZE
))
108 wxLogLastError(_T("SetWindowPos"));
115 #endif // #if wxUSE_POPUPWIN