]> git.saurik.com Git - wxWidgets.git/blame - src/msw/popupwin.cpp
Added missing include
[wxWidgets.git] / src / msw / popupwin.cpp
CommitLineData
e49d97e6
VZ
1///////////////////////////////////////////////////////////////////////////////
2// Name: msw/popupwin.cpp
3// Purpose: implements wxPopupWindow for MSW
4// Author: Vadim Zeitlin
5// Modified by:
6// Created: 08.05.02
7// RCS-ID: $Id$
8// Copyright: (c) 2002 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
65571936 9// License: wxWindows licence
e49d97e6
VZ
10///////////////////////////////////////////////////////////////////////////////
11
12// ============================================================================
13// declarations
14// ============================================================================
15
16// ----------------------------------------------------------------------------
17// headers
18// ----------------------------------------------------------------------------
19
e49d97e6
VZ
20// For compilers that support precompilation, includes "wx.h".
21#include "wx/wxprec.h"
22
23#ifdef __BORLANDC__
24 #pragma hdrstop
25#endif
26
27#ifndef WX_PRECOMP
37d729ed 28#include "wx/defs.h"
e49d97e6
VZ
29#endif //WX_PRECOMP
30
3080bf59
VZ
31#if wxUSE_POPUPWIN
32
e49d97e6
VZ
33#include "wx/popupwin.h"
34
24b3cc2c 35#include "wx/msw/private.h" // for GetDesktopWindow()
220c6d43 36
e49d97e6
VZ
37// ============================================================================
38// implementation
39// ============================================================================
40
41bool wxPopupWindow::Create(wxWindow *parent, int flags)
42{
eefe6d4b
VZ
43 // popup windows are created hidden by default
44 Hide();
45
e49d97e6 46 return wxPopupWindowBase::Create(parent) &&
078cf5cb 47 wxWindow::Create(parent, wxID_ANY,
e49d97e6
VZ
48 wxDefaultPosition, wxDefaultSize,
49 flags | wxPOPUP_WINDOW);
50}
51
52void wxPopupWindow::DoGetPosition(int *x, int *y) const
53{
54 // the position of a "top level" window such as this should be in
55 // screen coordinates, not in the client ones which MSW gives us
56 // (because we are a child window)
57 wxPopupWindowBase::DoGetPosition(x, y);
58
59 GetParent()->ClientToScreen(x, y);
60}
61
62WXDWORD wxPopupWindow::MSWGetStyle(long flags, WXDWORD *exstyle) const
63{
24b3cc2c 64 // we only honour the border flags, the others don't make sense for us
e49d97e6
VZ
65 WXDWORD style = wxWindow::MSWGetStyle(flags & wxBORDER_MASK, exstyle);
66
e49d97e6
VZ
67 if ( exstyle )
68 {
69 // a popup window floats on top of everything
70 *exstyle |= WS_EX_TOPMOST | WS_EX_TOOLWINDOW;
71 }
72
73 return style;
74}
75
24b3cc2c 76WXHWND wxPopupWindow::MSWGetParent() const
7e25f59e 77{
24b3cc2c
VZ
78 // we must be a child of the desktop to be able to extend beyond the parent
79 // window client area (like the comboboxes drop downs do)
80 //
81 // NB: alternative implementation would be to use WS_POPUP instead of
82 // WS_CHILD but then showing a popup would deactivate the parent which
83 // is ugly and working around this, although possible, is even more
84 // ugly
4676948b
JS
85 // GetDesktopWindow() is not always supported on WinCE, and if
86 // it is, it often returns NULL.
87#ifdef __WXWINCE__
88 return 0;
89#else
24b3cc2c 90 return (WXHWND)::GetDesktopWindow();
4676948b 91#endif
7e25f59e
VZ
92}
93
25b1b442
JS
94bool wxPopupWindow::Show(bool show)
95{
c649a6ab 96 if ( !wxWindowMSW::Show(show) )
078cf5cb 97 return false;
25b1b442 98
25b1b442
JS
99 if ( show )
100 {
101 // raise to top of z order
c649a6ab 102 if (!::SetWindowPos(GetHwnd(), HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE))
25b1b442
JS
103 {
104 wxLogLastError(_T("SetWindowPos"));
105 }
82ceade7
RD
106
107 // and set it as the foreground window so the mouse can be captured
108 ::SetForegroundWindow(GetHwnd());
25b1b442
JS
109 }
110
078cf5cb 111 return true;
25b1b442
JS
112}
113
3080bf59 114#endif // #if wxUSE_POPUPWIN
25b1b442 115