1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: src/msw/toplevel.cpp
3 // Purpose: implements wxTopLevelWindow for MSW
4 // Author: Vadim Zeitlin
8 // Copyright: (c) 2001 SciTech Software, Inc. (www.scitechsoft.com)
9 // Licence: wxWindows licence
10 ///////////////////////////////////////////////////////////////////////////////
12 // ============================================================================
14 // ============================================================================
16 // ----------------------------------------------------------------------------
18 // ----------------------------------------------------------------------------
20 // For compilers that support precompilation, includes "wx.h".
21 #include "wx/wxprec.h"
27 #include "wx/toplevel.h"
31 #include "wx/dialog.h"
32 #include "wx/string.h"
37 #include "wx/containr.h" // wxSetFocusToChild()
38 #include "wx/module.h"
41 #include "wx/dynlib.h"
43 #include "wx/msw/private.h"
44 #if defined(__WXWINCE__) && !defined(__HANDHELDPC__)
47 // Standard SDK doesn't have aygshell.dll: see include/wx/msw/wince/libraries.h
48 #if _WIN32_WCE < 400 || !defined(__WINCE_STANDARDSDK__)
53 #include "wx/msw/winundef.h"
54 #include "wx/msw/missing.h"
56 #include "wx/display.h"
66 // FIXME-VC6: Only VC6 doesn't have this in its standard headers so this
67 // could be removed once support for it is dropped.
68 #ifndef WM_UNINITMENUPOPUP
69 #define WM_UNINITMENUPOPUP 0x0125
72 // ----------------------------------------------------------------------------
74 // ----------------------------------------------------------------------------
76 #if wxUSE_MENUS || wxUSE_MENUS_NATIVE
77 extern wxMenu
*wxCurrentPopupMenu
;
78 #endif // wxUSE_MENUS || wxUSE_MENUS_NATIVE
81 // ----------------------------------------------------------------------------
82 // stubs for missing functions under MicroWindows
83 // ----------------------------------------------------------------------------
87 // static inline bool IsIconic(HWND WXUNUSED(hwnd)) { return false; }
88 static inline bool IsZoomed(HWND
WXUNUSED(hwnd
)) { return false; }
90 #endif // __WXMICROWIN__
92 // NB: wxDlgProc must be defined here and not in dialog.cpp because the latter
93 // is not included by wxUniv build which does need wxDlgProc
95 wxDlgProc(HWND hDlg
, UINT message
, WPARAM wParam
, LPARAM lParam
);
97 // ----------------------------------------------------------------------------
98 // wxTLWHiddenParentModule: used to manage the hidden parent window (we need a
99 // module to ensure that the window is always deleted)
100 // ----------------------------------------------------------------------------
102 class wxTLWHiddenParentModule
: public wxModule
105 // module init/finalize
106 virtual bool OnInit();
107 virtual void OnExit();
109 // get the hidden window (creates on demand)
110 static HWND
GetHWND();
113 // the HWND of the hidden parent
116 // the class used to create it
117 static const wxChar
*ms_className
;
119 DECLARE_DYNAMIC_CLASS(wxTLWHiddenParentModule
)
122 IMPLEMENT_DYNAMIC_CLASS(wxTLWHiddenParentModule
, wxModule
)
124 // ============================================================================
125 // wxTopLevelWindowMSW implementation
126 // ============================================================================
128 BEGIN_EVENT_TABLE(wxTopLevelWindowMSW
, wxTopLevelWindowBase
)
129 EVT_ACTIVATE(wxTopLevelWindowMSW::OnActivate
)
132 // ----------------------------------------------------------------------------
133 // wxTopLevelWindowMSW creation
134 // ----------------------------------------------------------------------------
136 void wxTopLevelWindowMSW::Init()
139 m_maximizeOnShow
= false;
141 // Data to save/restore when calling ShowFullScreen
143 m_fsOldWindowStyle
= 0;
144 m_fsIsMaximized
= false;
145 m_fsIsShowing
= false;
147 m_winLastFocused
= NULL
;
149 #if defined(__SMARTPHONE__) && defined(__WXWINCE__)
153 #if defined(__SMARTPHONE__) || defined(__POCKETPC__)
154 SHACTIVATEINFO
* info
= new SHACTIVATEINFO
;
156 info
->cbSize
= sizeof(SHACTIVATEINFO
);
158 m_activateInfo
= (void*) info
;
165 WXDWORD
wxTopLevelWindowMSW::MSWGetStyle(long style
, WXDWORD
*exflags
) const
167 // let the base class deal with the common styles but fix the ones which
168 // don't make sense for us (we also deal with the borders ourselves)
169 WXDWORD msflags
= wxWindow::MSWGetStyle
171 (style
& ~wxBORDER_MASK
) | wxBORDER_NONE
, exflags
172 ) & ~WS_CHILD
& ~WS_VISIBLE
;
174 // For some reason, WS_VISIBLE needs to be defined on creation for
175 // SmartPhone 2003. The title can fail to be displayed otherwise.
176 #if defined(__SMARTPHONE__) || (defined(__WXWINCE__) && _WIN32_WCE < 400)
177 msflags
|= WS_VISIBLE
;
178 ((wxTopLevelWindowMSW
*)this)->wxWindowBase::Show(true);
181 // first select the kind of window being created
183 // note that if we don't set WS_POPUP, Windows assumes WS_OVERLAPPED and
184 // creates a window with both caption and border, hence we need to use
185 // WS_POPUP in a few cases just to avoid having caption/border which we
188 // border and caption styles
189 if ( ( style
& wxRESIZE_BORDER
) && !IsAlwaysMaximized())
190 msflags
|= WS_THICKFRAME
;
191 else if ( exflags
&& ((style
& wxBORDER_DOUBLE
) || (style
& wxBORDER_RAISED
)) )
192 *exflags
|= WS_EX_DLGMODALFRAME
;
193 else if ( !(style
& wxBORDER_NONE
) )
194 msflags
|= WS_BORDER
;
200 // normally we consider that all windows without a caption must be popups,
201 // but CE is an exception: there windows normally do not have the caption
202 // but shouldn't be made popups as popups can't have menus and don't look
203 // like normal windows anyhow
205 // TODO: Smartphone appears to like wxCAPTION, but we should check that
207 #if defined(__SMARTPHONE__) || !defined(__WXWINCE__)
208 if ( style
& wxCAPTION
)
209 msflags
|= WS_CAPTION
;
213 #endif // !__WXWINCE__
216 // next translate the individual flags
218 // WS_EX_CONTEXTHELP is incompatible with WS_MINIMIZEBOX and WS_MAXIMIZEBOX
219 // and is ignored if we specify both of them, but chances are that if we
220 // use wxWS_EX_CONTEXTHELP, we really do want to have the context help
221 // button while wxMINIMIZE/wxMAXIMIZE are included by default, so the help
223 if ( !(GetExtraStyle() & wxWS_EX_CONTEXTHELP
) )
225 if ( style
& wxMINIMIZE_BOX
)
226 msflags
|= WS_MINIMIZEBOX
;
227 if ( style
& wxMAXIMIZE_BOX
)
228 msflags
|= WS_MAXIMIZEBOX
;
232 // notice that if wxCLOSE_BOX is specified we need to use WS_SYSMENU too as
233 // otherwise the close box doesn't appear
234 if ( style
& (wxSYSTEM_MENU
| wxCLOSE_BOX
) )
235 msflags
|= WS_SYSMENU
;
236 #endif // !__WXWINCE__
238 // NB: under CE these 2 styles are not supported currently, we should
239 // call Minimize()/Maximize() "manually" if we want to support them
240 if ( style
& wxMINIMIZE
)
241 msflags
|= WS_MINIMIZE
;
243 if ( style
& wxMAXIMIZE
)
244 msflags
|= WS_MAXIMIZE
;
246 // Keep this here because it saves recoding this function in wxTinyFrame
247 if ( style
& wxTINY_CAPTION
)
248 msflags
|= WS_CAPTION
;
252 // there is no taskbar under CE, so omit all this
253 #if !defined(__WXWINCE__)
254 if ( !(GetExtraStyle() & wxTOPLEVEL_EX_DIALOG
) )
256 if ( style
& wxFRAME_TOOL_WINDOW
)
258 // create the palette-like window
259 *exflags
|= WS_EX_TOOLWINDOW
;
261 // tool windows shouldn't appear on the taskbar (as documented)
262 style
|= wxFRAME_NO_TASKBAR
;
265 // We have to solve 2 different problems here:
267 // 1. frames with wxFRAME_NO_TASKBAR flag shouldn't appear in the
268 // taskbar even if they don't have a parent
270 // 2. frames without this style should appear in the taskbar even
271 // if they're owned (Windows only puts non owned windows into
272 // the taskbar normally)
274 // The second one is solved here by using WS_EX_APPWINDOW flag, the
275 // first one is dealt with in our MSWGetParent() method
277 if ( !(style
& wxFRAME_NO_TASKBAR
) && GetParent() )
279 // need to force the frame to appear in the taskbar
280 *exflags
|= WS_EX_APPWINDOW
;
282 //else: nothing to do [here]
285 if ( GetExtraStyle() & wxWS_EX_CONTEXTHELP
)
286 *exflags
|= WS_EX_CONTEXTHELP
;
287 #endif // !__WXWINCE__
289 if ( style
& wxSTAY_ON_TOP
)
290 *exflags
|= WS_EX_TOPMOST
;
296 WXHWND
wxTopLevelWindowMSW::MSWGetParent() const
298 // for the frames without wxFRAME_FLOAT_ON_PARENT style we should use NULL
299 // parent HWND or it would be always on top of its parent which is not what
300 // we usually want (in fact, we only want it for frames with the
301 // wxFRAME_FLOAT_ON_PARENT flag)
302 HWND hwndParent
= NULL
;
303 if ( HasFlag(wxFRAME_FLOAT_ON_PARENT
) )
305 const wxWindow
*parent
= GetParent();
309 // this flag doesn't make sense then and will be ignored
310 wxFAIL_MSG( wxT("wxFRAME_FLOAT_ON_PARENT but no parent?") );
314 hwndParent
= GetHwndOf(parent
);
317 //else: don't float on parent, must not be owned
319 // now deal with the 2nd taskbar-related problem (see comments above in
321 if ( HasFlag(wxFRAME_NO_TASKBAR
) && !hwndParent
)
324 hwndParent
= wxTLWHiddenParentModule::GetHWND();
327 return (WXHWND
)hwndParent
;
330 #if defined(__SMARTPHONE__) || defined(__POCKETPC__)
331 bool wxTopLevelWindowMSW::HandleSettingChange(WXWPARAM wParam
, WXLPARAM lParam
)
333 SHACTIVATEINFO
*info
= (SHACTIVATEINFO
*) m_activateInfo
;
336 SHHandleWMSettingChange(GetHwnd(), wParam
, lParam
, info
);
339 return wxWindowMSW::HandleSettingChange(wParam
, lParam
);
343 WXLRESULT
wxTopLevelWindowMSW::MSWWindowProc(WXUINT message
, WXWPARAM wParam
, WXLPARAM lParam
)
346 bool processed
= false;
350 #if defined(__SMARTPHONE__) || defined(__POCKETPC__)
353 SHACTIVATEINFO
* info
= (SHACTIVATEINFO
*) m_activateInfo
;
357 if (GetExtraStyle() & wxTOPLEVEL_EX_DIALOG
) flags
= SHA_INPUTDIALOG
;
358 SHHandleWMActivate(GetHwnd(), wParam
, lParam
, info
, flags
);
361 // This implicitly sends a wxEVT_ACTIVATE_APP event
363 wxTheApp
->SetActive(wParam
!= 0, FindFocus());
371 wxActivateEvent
event(wxEVT_HIBERNATE
, true, wxID_ANY
);
372 event
.SetEventObject(wxTheApp
);
373 processed
= wxTheApp
->ProcessEvent(event
);
377 #endif // __SMARTPHONE__ || __POCKETPC__
383 // ... the four low-order bits of the wParam parameter are
384 // used internally by the system. To obtain the correct
385 // result when testing the value of wParam, an application
386 // must combine the value 0xFFF0 with the wParam value by
387 // using the bitwise AND operator.
388 unsigned id
= wParam
& 0xfff0;
390 // Preserve the focus when minimizing/restoring the window: we
391 // need to do it manually as DefWindowProc() doesn't appear to
392 // do this for us for some reason (perhaps because we don't use
393 // WM_NEXTDLGCTL for setting focus?). Moreover, our code in
394 // OnActivate() doesn't work in this case as we receive the
395 // deactivation event too late when the window is being
396 // minimized and the focus is already NULL by then. Similarly,
397 // we receive the activation event too early and restoring
398 // focus in it fails because the window is still minimized. So
399 // we need to do it here.
400 if ( id
== SC_MINIMIZE
)
402 // For minimization, it's simple enough: just save the
403 // focus as usual. The important thing is that we're not
404 // minimized yet, so this works correctly.
407 else if ( id
== SC_RESTORE
)
409 // For restoring, it's trickier as DefWindowProc() sets
410 // focus to the window itself. So run it first and restore
411 // our saved focus only afterwards.
413 rc
= wxTopLevelWindowBase::MSWWindowProc(message
,
416 DoRestoreLastFocus();
419 #ifndef __WXUNIVERSAL__
420 // We need to generate events for the custom items added to the
421 // system menu if it had been created (and presumably modified).
422 // As SC_SIZE is the first of the system-defined commands, we
423 // only do this for the custom commands before it and leave
424 // SC_SIZE and everything after it to DefWindowProc().
425 if ( m_menuSystem
&& id
< SC_SIZE
)
427 if ( m_menuSystem
->MSWCommand(0 /* unused anyhow */, id
) )
430 #endif // #ifndef __WXUNIVERSAL__
434 #if !defined(__WXMICROWIN__) && !defined(__WXWINCE__)
436 case WM_INITMENUPOPUP
:
437 processed
= HandleMenuPopup(wxEVT_MENU_OPEN
, (WXHMENU
)wParam
);
444 UnpackMenuSelect(wParam
, lParam
, &item
, &flags
, &hmenu
);
446 processed
= HandleMenuSelect(item
, flags
, hmenu
);
450 case WM_EXITMENULOOP
:
451 // Under Windows 98 and 2000 and later we're going to get
452 // WM_UNINITMENUPOPUP which will be used to generate this event
453 // with more information (notably the menu that was closed) so we
454 // only need this one under old Windows systems where the newer
455 // event is never sent.
456 if ( wxGetWinVersion() < wxWinVersion_98
)
457 processed
= HandleExitMenuLoop(wParam
);
460 case WM_UNINITMENUPOPUP
:
461 processed
= HandleMenuPopup(wxEVT_MENU_CLOSE
, (WXHMENU
)wParam
);
463 #endif // wxUSE_MENUS
464 #endif // !__WXMICROWIN__
468 rc
= wxTopLevelWindowBase::MSWWindowProc(message
, wParam
, lParam
);
473 bool wxTopLevelWindowMSW::CreateDialog(const void *dlgTemplate
,
474 const wxString
& title
,
478 #ifdef __WXMICROWIN__
479 // no dialogs support under MicroWin yet
480 return CreateFrame(title
, pos
, size
);
481 #else // !__WXMICROWIN__
482 // static cast is valid as we're only ever called for dialogs
484 parent
= static_cast<wxDialog
*>(this)->GetParentForModalDialog();
486 m_hWnd
= (WXHWND
)::CreateDialogIndirect
489 (DLGTEMPLATE
*)dlgTemplate
,
490 parent
? GetHwndOf(parent
) : NULL
,
496 wxFAIL_MSG(wxT("Failed to create dialog. Incorrect DLGTEMPLATE?"));
498 wxLogSysError(wxT("Can't create dialog using memory template"));
503 #if !defined(__WXWINCE__)
504 // For some reason, the system menu is activated when we use the
505 // WS_EX_CONTEXTHELP style, so let's set a reasonable icon
506 if ( HasExtraStyle(wxWS_EX_CONTEXTHELP
) )
508 wxFrame
*winTop
= wxDynamicCast(wxTheApp
->GetTopWindow(), wxFrame
);
511 wxIcon icon
= winTop
->GetIcon();
514 ::SendMessage(GetHwnd(), WM_SETICON
,
516 (LPARAM
)GetHiconOf(icon
));
520 #endif // !__WXWINCE__
522 if ( !title
.empty() )
524 ::SetWindowText(GetHwnd(), title
.t_str());
529 #if !defined(__WXWINCE__) || defined(__WINCE_STANDARDSDK__)
530 // move the dialog to its initial position without forcing repainting
532 (void)MSWGetCreateWindowCoords(pos
, size
, x
, y
, w
, h
);
534 if ( x
== (int)CW_USEDEFAULT
)
536 // Let the system position the window, just set its size.
537 ::SetWindowPos(GetHwnd(), 0,
539 SWP_NOMOVE
| SWP_NOZORDER
| SWP_NOACTIVATE
);
541 else // Move the window to the desired location and set its size too.
543 if ( !::MoveWindow(GetHwnd(), x
, y
, w
, h
, FALSE
) )
545 wxLogLastError(wxT("MoveWindow"));
548 #endif // !__WXWINCE__
550 #ifdef __SMARTPHONE__
551 // Work around title non-display glitch
556 #endif // __WXMICROWIN__/!__WXMICROWIN__
559 bool wxTopLevelWindowMSW::CreateFrame(const wxString
& title
,
564 WXDWORD flags
= MSWGetCreateWindowFlags(&exflags
);
566 const wxSize sz
= IsAlwaysMaximized() ? wxDefaultSize
: size
;
569 if ( wxTheApp
->GetLayoutDirection() == wxLayout_RightToLeft
)
570 exflags
|= WS_EX_LAYOUTRTL
;
573 return MSWCreate(MSWGetRegisteredClassName(),
574 title
.t_str(), pos
, sz
, flags
, exflags
);
577 bool wxTopLevelWindowMSW::Create(wxWindow
*parent
,
579 const wxString
& title
,
583 const wxString
& name
)
585 wxSize sizeReal
= size
;
586 if ( !sizeReal
.IsFullySpecified() )
588 sizeReal
.SetDefaults(GetDefaultSize());
591 // notice that we should append this window to wxTopLevelWindows list
592 // before calling CreateBase() as it behaves differently for TLW and
594 wxTopLevelWindows
.Append(this);
596 bool ret
= CreateBase(parent
, id
, pos
, sizeReal
, style
, name
);
601 parent
->AddChild(this);
603 if ( GetExtraStyle() & wxTOPLEVEL_EX_DIALOG
)
605 // we have different dialog templates to allows creation of dialogs
606 // with & without captions under MSWindows, resizable or not (but a
607 // resizable dialog always has caption - otherwise it would look too
610 // we need 3 additional WORDs for dialog menu, class and title (as we
611 // don't use DS_SETFONT we don't need the fourth WORD for the font)
612 static const int dlgsize
= sizeof(DLGTEMPLATE
) + (sizeof(WORD
) * 3);
613 DLGTEMPLATE
*dlgTemplate
= (DLGTEMPLATE
*)malloc(dlgsize
);
614 memset(dlgTemplate
, 0, dlgsize
);
616 // these values are arbitrary, they won't be used normally anyhow
619 dlgTemplate
->cx
= 144;
620 dlgTemplate
->cy
= 75;
622 // reuse the code in MSWGetStyle() but correct the results slightly for
625 // NB: we need a temporary variable as we can't pass pointer to
626 // dwExtendedStyle directly, it's not aligned correctly for 64 bit
628 WXDWORD dwExtendedStyle
;
629 dlgTemplate
->style
= MSWGetStyle(style
, &dwExtendedStyle
);
630 dlgTemplate
->dwExtendedStyle
= dwExtendedStyle
;
632 // all dialogs are popups
633 dlgTemplate
->style
|= WS_POPUP
;
636 if ( wxTheApp
->GetLayoutDirection() == wxLayout_RightToLeft
)
638 dlgTemplate
->dwExtendedStyle
|= WS_EX_LAYOUTRTL
;
641 // force 3D-look if necessary, it looks impossibly ugly otherwise
642 if ( style
& (wxRESIZE_BORDER
| wxCAPTION
) )
643 dlgTemplate
->style
|= DS_MODALFRAME
;
646 ret
= CreateDialog(dlgTemplate
, title
, pos
, sizeReal
);
651 ret
= CreateFrame(title
, pos
, sizeReal
);
655 if ( ret
&& !(GetWindowStyleFlag() & wxCLOSE_BOX
) )
657 EnableCloseButton(false);
661 // for standard dialogs the dialog manager generates WM_CHANGEUISTATE
662 // itself but for custom windows we have to do it ourselves in order to
663 // make the keyboard indicators (such as underlines for accelerators and
664 // focus rectangles) work under Win2k+
667 MSWUpdateUIState(UIS_INITIALIZE
);
670 // Note: if we include PocketPC in this test, dialogs can fail to show up,
671 // for example the text entry dialog in the dialogs sample. Problem with Maximise()?
672 #if defined(__WXWINCE__) && (defined(__SMARTPHONE__) || defined(__WINCE_STANDARDSDK__))
673 if ( ( style
& wxMAXIMIZE
) || IsAlwaysMaximized() )
679 #if defined(__SMARTPHONE__) && defined(__WXWINCE__)
680 SetRightMenu(); // to nothing for initialization
686 wxTopLevelWindowMSW::~wxTopLevelWindowMSW()
692 #if defined(__SMARTPHONE__) || defined(__POCKETPC__)
693 SHACTIVATEINFO
* info
= (SHACTIVATEINFO
*) m_activateInfo
;
695 m_activateInfo
= NULL
;
698 // after destroying an owned window, Windows activates the next top level
699 // window in Z order but it may be different from our owner (to reproduce
700 // this simply Alt-TAB to another application and back before closing the
701 // owned frame) whereas we always want to yield activation to our parent
702 if ( HasFlag(wxFRAME_FLOAT_ON_PARENT
) )
704 wxWindow
*parent
= GetParent();
707 ::BringWindowToTop(GetHwndOf(parent
));
712 // ----------------------------------------------------------------------------
713 // wxTopLevelWindowMSW showing
714 // ----------------------------------------------------------------------------
716 void wxTopLevelWindowMSW::DoShowWindow(int nShowCmd
)
718 ::ShowWindow(GetHwnd(), nShowCmd
);
720 // Hiding the window doesn't change its iconized state.
721 if ( nShowCmd
!= SW_HIDE
)
723 // Otherwise restoring, maximizing or showing the window normally also
724 // makes it not iconized and only minimizing it does make it iconized.
725 m_iconized
= nShowCmd
== SW_MINIMIZE
;
729 void wxTopLevelWindowMSW::ShowWithoutActivating()
731 if ( !wxWindowBase::Show(true) )
734 DoShowWindow(SW_SHOWNA
);
737 bool wxTopLevelWindowMSW::Show(bool show
)
739 // don't use wxWindow version as we want to call DoShowWindow() ourselves
740 if ( !wxWindowBase::Show(show
) )
746 if ( m_maximizeOnShow
)
749 nShowCmd
= SW_MAXIMIZE
;
751 // This is necessary, or no window appears
752 #if defined( __WINCE_STANDARDSDK__) || defined(__SMARTPHONE__)
753 DoShowWindow(SW_SHOW
);
756 m_maximizeOnShow
= false;
758 else if ( m_iconized
)
760 // We were iconized while we were hidden, so now we need to show
761 // the window in iconized state.
762 nShowCmd
= SW_MINIMIZE
;
764 else if ( ::IsIconic(GetHwnd()) )
766 // We were restored while we were hidden, so now we need to show
767 // the window in its normal state.
769 // As below, don't activate some kinds of windows.
770 if ( HasFlag(wxFRAME_TOOL_WINDOW
) || !IsEnabled() )
771 nShowCmd
= SW_SHOWNOACTIVATE
;
773 nShowCmd
= SW_RESTORE
;
777 // we shouldn't use SW_SHOW which also activates the window for
778 // tool frames (as they shouldn't steal focus from the main window)
779 // nor for the currently disabled windows as they would be enabled
781 if ( HasFlag(wxFRAME_TOOL_WINDOW
) || !IsEnabled() )
782 nShowCmd
= SW_SHOWNA
;
792 #if wxUSE_DEFERRED_SIZING
793 // we only set pending size if we're maximized before being shown, now that
794 // we're shown we don't need it any more (it is reset in size event handler
795 // for child windows but we have to do it ourselves for this parent window)
797 // make sure to reset it before actually showing the window as this will
798 // generate WM_SIZE events and we want to use the correct client size from
799 // them, not the size returned by WM_NCCALCSIZE in DoGetClientSize() which
800 // turns out to be wrong for maximized windows (see #11762)
801 m_pendingSize
= wxDefaultSize
;
802 #endif // wxUSE_DEFERRED_SIZING
804 DoShowWindow(nShowCmd
);
806 #if defined(__WXWINCE__) && (_WIN32_WCE >= 400 && !defined(__POCKETPC__) && !defined(__SMARTPHONE__))
807 // Addornments have to be added when the frame is the correct size
808 wxFrame
* frame
= wxDynamicCast(this, wxFrame
);
809 if (frame
&& frame
->GetMenuBar())
810 frame
->GetMenuBar()->AddAdornments(GetWindowStyleFlag());
816 void wxTopLevelWindowMSW::Raise()
818 ::SetForegroundWindow(GetHwnd());
821 // ----------------------------------------------------------------------------
822 // wxTopLevelWindowMSW maximize/minimize
823 // ----------------------------------------------------------------------------
825 void wxTopLevelWindowMSW::Maximize(bool maximize
)
829 // just maximize it directly
830 DoShowWindow(maximize
? SW_MAXIMIZE
: SW_RESTORE
);
834 // we can't maximize the hidden frame because it shows it as well,
835 // so just remember that we should do it later in this case
836 m_maximizeOnShow
= maximize
;
838 #if wxUSE_DEFERRED_SIZING
839 // after calling Maximize() the client code expects to get the frame
840 // "real" size and doesn't want to know that, because of implementation
841 // details, the frame isn't really maximized yet but will be only once
842 // it's shown, so return our size as it will be then in this case
845 // we must only change pending size here, and not call SetSize()
846 // because otherwise Windows would think that this (full screen)
847 // size is the natural size for the frame and so would use it when
848 // the user clicks on "restore" title bar button instead of the
849 // correct initial frame size
851 // NB: unfortunately we don't know which display we're on yet so we
852 // have to use the default one
853 m_pendingSize
= wxGetClientDisplayRect().GetSize();
855 //else: can't do anything in this case, we don't have the old size
856 #endif // wxUSE_DEFERRED_SIZING
860 bool wxTopLevelWindowMSW::IsMaximized() const
862 return IsAlwaysMaximized() ||
863 #if !defined(__SMARTPHONE__) && !defined(__POCKETPC__) && !defined(__WINCE_STANDARDSDK__)
865 (::IsZoomed(GetHwnd()) != 0) ||
870 void wxTopLevelWindowMSW::Iconize(bool iconize
)
872 if ( iconize
== m_iconized
)
874 // Do nothing, in particular don't restore non-iconized windows when
875 // Iconize(false) is called as this would wrongly un-maximize them.
881 // change the window state immediately
882 DoShowWindow(iconize
? SW_MINIMIZE
: SW_RESTORE
);
886 // iconizing the window shouldn't show it so just update the internal
887 // state (otherwise it's done by DoShowWindow() itself)
888 m_iconized
= iconize
;
892 bool wxTopLevelWindowMSW::IsIconized() const
900 // don't use m_iconized, it may be briefly out of sync with the real state
901 // as it's only modified when we receive a WM_SIZE and we could be called
902 // from an event handler from one of the messages we receive before it,
904 return ::IsIconic(GetHwnd()) != 0;
908 void wxTopLevelWindowMSW::Restore()
910 DoShowWindow(SW_RESTORE
);
913 void wxTopLevelWindowMSW::SetLayoutDirection(wxLayoutDirection dir
)
915 if ( dir
== wxLayout_Default
)
916 dir
= wxTheApp
->GetLayoutDirection();
918 if ( dir
!= wxLayout_Default
)
919 wxTopLevelWindowBase::SetLayoutDirection(dir
);
922 // ----------------------------------------------------------------------------
923 // wxTopLevelWindowMSW geometry
924 // ----------------------------------------------------------------------------
928 void wxTopLevelWindowMSW::DoGetPosition(int *x
, int *y
) const
933 wp
.length
= sizeof(WINDOWPLACEMENT
);
934 if ( ::GetWindowPlacement(GetHwnd(), &wp
) )
936 RECT
& rc
= wp
.rcNormalPosition
;
938 // the position returned by GetWindowPlacement() is in workspace
939 // coordinates except for windows with WS_EX_TOOLWINDOW style
940 if ( !HasFlag(wxFRAME_TOOL_WINDOW
) )
942 // we must use the correct display for the translation as the
943 // task bar might be shown on one display but not the other one
944 int n
= wxDisplay::GetFromWindow(this);
945 wxDisplay
dpy(n
== wxNOT_FOUND
? 0 : n
);
946 const wxPoint ptOfs
= dpy
.GetClientArea().GetPosition() -
947 dpy
.GetGeometry().GetPosition();
961 wxLogLastError(wxT("GetWindowPlacement"));
965 wxTopLevelWindowBase::DoGetPosition(x
, y
);
968 void wxTopLevelWindowMSW::DoGetSize(int *width
, int *height
) const
973 wp
.length
= sizeof(WINDOWPLACEMENT
);
974 if ( ::GetWindowPlacement(GetHwnd(), &wp
) )
976 const RECT
& rc
= wp
.rcNormalPosition
;
979 *width
= rc
.right
- rc
.left
;
981 *height
= rc
.bottom
- rc
.top
;
986 wxLogLastError(wxT("GetWindowPlacement"));
990 wxTopLevelWindowBase::DoGetSize(width
, height
);
993 #endif // __WXWINCE__
996 wxTopLevelWindowMSW::MSWGetCreateWindowCoords(const wxPoint
& pos
,
999 int& w
, int& h
) const
1001 // let the system position the window if no explicit position was specified
1002 if ( pos
.x
== wxDefaultCoord
)
1004 // if x is set to CW_USEDEFAULT, y parameter is ignored anyhow so we
1005 // can just as well set it to CW_USEDEFAULT as well
1011 // OTOH, if x is not set to CW_USEDEFAULT, y shouldn't be set to it
1012 // neither because it is not handled as a special value by Windows then
1013 // and so we have to choose some default value for it, even if a
1014 // completely arbitrary one
1015 static const int DEFAULT_Y
= 200;
1018 y
= pos
.y
== wxDefaultCoord
? DEFAULT_Y
: pos
.y
;
1021 if ( size
.x
== wxDefaultCoord
|| size
.y
== wxDefaultCoord
)
1023 // We don't use CW_USEDEFAULT here for several reasons:
1025 // 1. It results in huge frames on modern screens (1000*800 is not
1026 // uncommon on my 1280*1024 screen) which is way too big for a half
1027 // empty frame of most of wxWidgets samples for example)
1029 // 2. It is buggy for frames with wxFRAME_TOOL_WINDOW style for which
1030 // the default is for whatever reason 8*8 which breaks client <->
1031 // window size calculations (it would be nice if it didn't, but it
1032 // does and the simplest way to fix it seemed to change the broken
1033 // default size anyhow)
1035 // 3. There is just no advantage in doing it: with x and y it is
1036 // possible that [future versions of] Windows position the new top
1037 // level window in some smart way which we can't do, but we can
1038 // guess a reasonably good size for a new window just as well
1041 // The only exception is for the Windows CE platform where the system
1042 // does know better than we how should the windows be sized
1046 #else // !_WIN32_WCE
1047 wxSize sizeReal
= size
;
1048 sizeReal
.SetDefaults(GetDefaultSize());
1052 #endif // _WIN32_WCE/!_WIN32_WCE
1061 // ----------------------------------------------------------------------------
1062 // wxTopLevelWindowMSW fullscreen
1063 // ----------------------------------------------------------------------------
1065 bool wxTopLevelWindowMSW::ShowFullScreen(bool show
, long style
)
1067 if ( show
== IsFullScreen() )
1073 m_fsIsShowing
= show
;
1079 // zap the frame borders
1081 // save the 'normal' window style
1082 m_fsOldWindowStyle
= GetWindowLong(GetHwnd(), GWL_STYLE
);
1084 // save the old position, width & height, maximize state
1085 m_fsOldSize
= GetRect();
1086 m_fsIsMaximized
= IsMaximized();
1088 // decide which window style flags to turn off
1089 LONG newStyle
= m_fsOldWindowStyle
;
1092 if (style
& wxFULLSCREEN_NOBORDER
)
1094 offFlags
|= WS_BORDER
;
1096 offFlags
|= WS_THICKFRAME
;
1099 if (style
& wxFULLSCREEN_NOCAPTION
)
1100 offFlags
|= WS_CAPTION
| WS_SYSMENU
;
1102 newStyle
&= ~offFlags
;
1104 // change our window style to be compatible with full-screen mode
1105 ::SetWindowLong(GetHwnd(), GWL_STYLE
, newStyle
);
1109 // resize to the size of the display containing us
1110 int dpy
= wxDisplay::GetFromWindow(this);
1111 if ( dpy
!= wxNOT_FOUND
)
1113 rect
= wxDisplay(dpy
).GetGeometry();
1115 else // fall back to the main desktop
1116 #endif // wxUSE_DISPLAY
1118 // resize to the size of the desktop
1119 wxCopyRECTToRect(wxGetWindowRect(::GetDesktopWindow()), rect
);
1121 // FIXME: size of the bottom menu (toolbar)
1122 // should be taken in account
1123 rect
.height
+= rect
.y
;
1130 // now flush the window style cache and actually go full-screen
1131 long flags
= SWP_FRAMECHANGED
;
1133 // showing the frame full screen should also show it if it's still
1137 // don't call wxWindow version to avoid flicker from calling
1138 // ::ShowWindow() -- we're going to show the window at the correct
1139 // location directly below -- but do call the wxWindowBase version
1140 // to sync the internal m_isShown flag
1141 wxWindowBase::Show();
1143 flags
|= SWP_SHOWWINDOW
;
1146 SetWindowPos(GetHwnd(), HWND_TOP
,
1147 rect
.x
, rect
.y
, rect
.width
, rect
.height
,
1150 #if !defined(__HANDHELDPC__) && (defined(__WXWINCE__) && (_WIN32_WCE < 400))
1151 ::SHFullScreen(GetHwnd(), SHFS_HIDETASKBAR
| SHFS_HIDESIPBUTTON
);
1154 // finally send an event allowing the window to relayout itself &c
1155 wxSizeEvent
event(rect
.GetSize(), GetId());
1156 event
.SetEventObject(this);
1157 HandleWindowEvent(event
);
1159 else // stop showing full screen
1161 #if !defined(__HANDHELDPC__) && (defined(__WXWINCE__) && (_WIN32_WCE < 400))
1162 ::SHFullScreen(GetHwnd(), SHFS_SHOWTASKBAR
| SHFS_SHOWSIPBUTTON
);
1164 Maximize(m_fsIsMaximized
);
1165 SetWindowLong(GetHwnd(),GWL_STYLE
, m_fsOldWindowStyle
);
1166 SetWindowPos(GetHwnd(),HWND_TOP
,m_fsOldSize
.x
, m_fsOldSize
.y
,
1167 m_fsOldSize
.width
, m_fsOldSize
.height
, SWP_FRAMECHANGED
);
1173 // ----------------------------------------------------------------------------
1174 // wxTopLevelWindowMSW misc
1175 // ----------------------------------------------------------------------------
1177 void wxTopLevelWindowMSW::SetTitle( const wxString
& title
)
1182 wxString
wxTopLevelWindowMSW::GetTitle() const
1187 bool wxTopLevelWindowMSW::DoSelectAndSetIcon(const wxIconBundle
& icons
,
1192 const wxSize
size(::GetSystemMetrics(smX
), ::GetSystemMetrics(smY
));
1194 wxIcon icon
= icons
.GetIcon(size
, wxIconBundle::FALLBACK_NEAREST_LARGER
);
1199 ::SendMessage(GetHwnd(), WM_SETICON
, i
, (LPARAM
)GetHiconOf(icon
));
1203 void wxTopLevelWindowMSW::SetIcons(const wxIconBundle
& icons
)
1205 wxTopLevelWindowBase::SetIcons(icons
);
1207 if ( icons
.IsEmpty() )
1209 // FIXME: SetIcons(wxNullIconBundle) should unset existing icons,
1210 // but we currently don't do that
1211 wxASSERT_MSG( m_icons
.IsEmpty(), "unsetting icons doesn't work" );
1215 DoSelectAndSetIcon(icons
, SM_CXSMICON
, SM_CYSMICON
, ICON_SMALL
);
1216 DoSelectAndSetIcon(icons
, SM_CXICON
, SM_CYICON
, ICON_BIG
);
1219 bool wxTopLevelWindowMSW::EnableCloseButton(bool enable
)
1221 #if !defined(__WXMICROWIN__)
1222 // get system (a.k.a. window) menu
1223 HMENU hmenu
= GetSystemMenu(GetHwnd(), FALSE
/* get it */);
1226 // no system menu at all -- ok if we want to remove the close button
1227 // anyhow, but bad if we want to show it
1231 // enabling/disabling the close item from it also automatically
1232 // disables/enables the close title bar button
1233 if ( ::EnableMenuItem(hmenu
, SC_CLOSE
,
1235 (enable
? MF_ENABLED
: MF_GRAYED
)) == -1 )
1237 wxLogLastError(wxT("EnableMenuItem(SC_CLOSE)"));
1242 // update appearance immediately
1243 if ( !::DrawMenuBar(GetHwnd()) )
1245 wxLogLastError(wxT("DrawMenuBar"));
1248 #endif // !__WXMICROWIN__
1253 void wxTopLevelWindowMSW::RequestUserAttention(int flags
)
1255 // check if we can use FlashWindowEx(): unfortunately a simple test for
1256 // FLASHW_STOP doesn't work because MSVC6 headers do #define it but don't
1257 // provide FlashWindowEx() declaration, so try to detect whether we have
1258 // real headers for WINVER 0x0500 by checking for existence of a symbol not
1259 // declated in MSVC6 header
1260 #if defined(FLASHW_STOP) && defined(VK_XBUTTON1) && wxUSE_DYNLIB_CLASS
1261 // available in the headers, check if it is supported by the system
1262 typedef BOOL (WINAPI
*FlashWindowEx_t
)(FLASHWINFO
*pfwi
);
1263 static FlashWindowEx_t s_pfnFlashWindowEx
= NULL
;
1264 if ( !s_pfnFlashWindowEx
)
1266 wxDynamicLibrary
dllUser32(wxT("user32.dll"));
1267 s_pfnFlashWindowEx
= (FlashWindowEx_t
)
1268 dllUser32
.GetSymbol(wxT("FlashWindowEx"));
1270 // we can safely unload user32.dll here, it's going to remain loaded as
1271 // long as the program is running anyhow
1274 if ( s_pfnFlashWindowEx
)
1276 WinStruct
<FLASHWINFO
> fwi
;
1277 fwi
.hwnd
= GetHwnd();
1278 fwi
.dwFlags
= FLASHW_ALL
;
1279 if ( flags
& wxUSER_ATTENTION_INFO
)
1281 // just flash a few times
1284 else // wxUSER_ATTENTION_ERROR
1286 // flash until the user notices it
1287 fwi
.dwFlags
|= FLASHW_TIMERNOFG
;
1290 s_pfnFlashWindowEx(&fwi
);
1292 else // FlashWindowEx() not available
1293 #endif // FlashWindowEx() defined
1297 ::FlashWindow(GetHwnd(), TRUE
);
1298 #endif // __WXWINCE__
1302 wxMenu
*wxTopLevelWindowMSW::MSWGetSystemMenu() const
1304 #ifndef __WXUNIVERSAL__
1305 if ( !m_menuSystem
)
1307 HMENU hmenu
= ::GetSystemMenu(GetHwnd(), FALSE
);
1310 wxLogLastError(wxT("GetSystemMenu()"));
1314 wxTopLevelWindowMSW
* const
1315 self
= const_cast<wxTopLevelWindowMSW
*>(this);
1317 self
->m_menuSystem
= wxMenu::MSWNewFromHMENU(hmenu
);
1319 // We need to somehow associate this menu with this window to ensure
1320 // that we get events from it. A natural idea would be to pretend that
1321 // it's attached to our menu bar but this wouldn't work if we don't
1322 // have any menu bar which is a common case for applications using
1323 // custom items in the system menu (they mostly do it exactly because
1324 // they don't have any other menus).
1326 // So reuse the invoking window pointer instead, this is not exactly
1327 // correct but doesn't seem to have any serious drawbacks.
1328 m_menuSystem
->SetInvokingWindow(self
);
1330 #endif // #ifndef __WXUNIVERSAL__
1332 return m_menuSystem
;
1335 // ----------------------------------------------------------------------------
1336 // Transparency support
1337 // ---------------------------------------------------------------------------
1339 bool wxTopLevelWindowMSW::SetTransparent(wxByte alpha
)
1341 #if wxUSE_DYNLIB_CLASS
1342 typedef DWORD (WINAPI
*PSETLAYEREDWINDOWATTR
)(HWND
, DWORD
, BYTE
, DWORD
);
1343 static PSETLAYEREDWINDOWATTR
1344 pSetLayeredWindowAttributes
= (PSETLAYEREDWINDOWATTR
)-1;
1346 if ( pSetLayeredWindowAttributes
== (PSETLAYEREDWINDOWATTR
)-1 )
1348 wxDynamicLibrary
dllUser32(wxT("user32.dll"));
1350 // use RawGetSymbol() and not GetSymbol() to avoid error messages under
1351 // Windows 95: there is nothing the user can do about this anyhow
1352 pSetLayeredWindowAttributes
= (PSETLAYEREDWINDOWATTR
)
1353 dllUser32
.RawGetSymbol(wxT("SetLayeredWindowAttributes"));
1355 // it's ok to destroy dllUser32 here, we link statically to user32.dll
1356 // anyhow so it won't be unloaded
1359 if ( !pSetLayeredWindowAttributes
)
1361 #endif // wxUSE_DYNLIB_CLASS
1363 LONG exstyle
= GetWindowLong(GetHwnd(), GWL_EXSTYLE
);
1365 // if setting alpha to fully opaque then turn off the layered style
1368 SetWindowLong(GetHwnd(), GWL_EXSTYLE
, exstyle
& ~WS_EX_LAYERED
);
1373 #if wxUSE_DYNLIB_CLASS
1374 // Otherwise, set the layered style if needed and set the alpha value
1375 if ((exstyle
& WS_EX_LAYERED
) == 0 )
1376 SetWindowLong(GetHwnd(), GWL_EXSTYLE
, exstyle
| WS_EX_LAYERED
);
1378 if ( pSetLayeredWindowAttributes(GetHwnd(), 0, (BYTE
)alpha
, LWA_ALPHA
) )
1380 #endif // wxUSE_DYNLIB_CLASS
1385 bool wxTopLevelWindowMSW::CanSetTransparent()
1387 // The API is available on win2k and above
1389 static int os_type
= -1;
1390 static int ver_major
= -1;
1393 os_type
= ::wxGetOsVersion(&ver_major
);
1395 return (os_type
== wxOS_WINDOWS_NT
&& ver_major
>= 5);
1398 void wxTopLevelWindowMSW::DoFreeze()
1400 // do nothing: freezing toplevel window causes paint and mouse events
1401 // to go through it any TLWs under it, so the best we can do is to freeze
1402 // all children -- and wxWindowBase::Freeze() does that
1405 void wxTopLevelWindowMSW::DoThaw()
1407 // intentionally empty -- see DoFreeze()
1411 // ----------------------------------------------------------------------------
1412 // wxTopLevelWindow event handling
1413 // ----------------------------------------------------------------------------
1415 void wxTopLevelWindowMSW::DoSaveLastFocus()
1420 // remember the last focused child if it is our child
1421 m_winLastFocused
= FindFocus();
1423 if ( m_winLastFocused
)
1425 // and don't remember it if it's a child from some other frame
1426 if ( wxGetTopLevelParent(m_winLastFocused
) != this )
1428 m_winLastFocused
= NULL
;
1433 void wxTopLevelWindowMSW::DoRestoreLastFocus()
1435 wxWindow
*parent
= m_winLastFocused
? m_winLastFocused
->GetParent()
1442 wxSetFocusToChild(parent
, &m_winLastFocused
);
1445 void wxTopLevelWindowMSW::OnActivate(wxActivateEvent
& event
)
1447 if ( event
.GetActive() )
1449 // We get WM_ACTIVATE before being restored from iconized state, so we
1450 // can be still iconized here. In this case, avoid restoring the focus
1451 // as it doesn't work anyhow and we will do when we're really restored.
1458 // restore focus to the child which was last focused unless we already
1460 wxLogTrace(wxT("focus"), wxT("wxTLW %p activated."), m_hWnd
);
1462 wxWindow
*winFocus
= FindFocus();
1463 if ( !winFocus
|| wxGetTopLevelParent(winFocus
) != this )
1464 DoRestoreLastFocus();
1466 else // deactivating
1470 wxLogTrace(wxT("focus"),
1471 wxT("wxTLW %p deactivated, last focused: %p."),
1473 m_winLastFocused
? GetHwndOf(m_winLastFocused
) : NULL
);
1482 wxTopLevelWindowMSW::HandleMenuSelect(WXWORD nItem
, WXWORD flags
, WXHMENU hMenu
)
1484 // Ignore the special messages generated when the menu is closed (this is
1485 // the only case when the flags are set to -1), in particular don't clear
1486 // the help string in the status bar when this happens as it had just been
1487 // restored by the base class code.
1488 if ( !hMenu
&& flags
== 0xffff )
1491 // Unfortunately we also need to ignore another message which is sent after
1492 // closing the currently active submenu of the menu bar by pressing Escape:
1493 // in this case we get WM_UNINITMENUPOPUP, from which we generate
1494 // wxEVT_MENU_CLOSE, and _then_ we get WM_MENUSELECT for the top level menu
1495 // from which we overwrite the help string just restored by OnMenuClose()
1496 // handler in wxFrameBase. To prevent this from happening we discard these
1497 // messages but only in the case it's really the top level menu as we still
1498 // need to clear the help string when a submenu is selected in a menu.
1499 if ( flags
== (MF_POPUP
| MF_HILITE
) && !m_menuDepth
)
1502 // sign extend to int from unsigned short we get from Windows
1503 int item
= (signed short)nItem
;
1505 // WM_MENUSELECT is generated for both normal items and menus, including
1506 // the top level menus of the menu bar, which can't be represented using
1507 // any valid identifier in wxMenuEvent so use an otherwise unused value for
1509 if ( flags
& (MF_POPUP
| MF_SEPARATOR
) )
1512 wxMenuEvent
event(wxEVT_MENU_HIGHLIGHT
, item
);
1513 event
.SetEventObject(this);
1515 if ( HandleWindowEvent(event
) )
1518 // by default, i.e. if the event wasn't handled above, clear the status bar
1519 // text when an item which can't have any associated help string in wx API
1521 if ( item
== wxID_NONE
)
1522 DoGiveHelp(wxEmptyString
, true);
1528 wxTopLevelWindowMSW::DoSendMenuOpenCloseEvent(wxEventType evtType
, wxMenu
* menu
, bool popup
)
1530 // Update the menu depth when dealing with the top level menus.
1533 if ( evtType
== wxEVT_MENU_OPEN
)
1537 else if ( evtType
== wxEVT_MENU_CLOSE
)
1539 wxASSERT_MSG( m_menuDepth
> 0, wxS("No open menus?") );
1545 wxFAIL_MSG( wxS("Unexpected menu event type") );
1549 wxMenuEvent
event(evtType
, popup
? wxID_ANY
: 0, menu
);
1550 event
.SetEventObject(menu
);
1552 return HandleWindowEvent(event
);
1555 bool wxTopLevelWindowMSW::HandleExitMenuLoop(WXWORD isPopup
)
1557 return DoSendMenuOpenCloseEvent(wxEVT_MENU_CLOSE
,
1558 isPopup
? wxCurrentPopupMenu
: NULL
,
1562 bool wxTopLevelWindowMSW::HandleMenuPopup(wxEventType evtType
, WXHMENU hMenu
)
1564 bool isPopup
= false;
1565 wxMenu
* menu
= NULL
;
1566 if ( wxCurrentPopupMenu
&& wxCurrentPopupMenu
->GetHMenu() == hMenu
)
1568 menu
= wxCurrentPopupMenu
;
1573 menu
= MSWFindMenuFromHMENU(hMenu
);
1577 return DoSendMenuOpenCloseEvent(evtType
, menu
, isPopup
);
1580 wxMenu
* wxTopLevelWindowMSW::MSWFindMenuFromHMENU(WXHMENU
WXUNUSED(hMenu
))
1582 // We don't have any menus at this level.
1586 #endif // wxUSE_MENUS
1590 // the DialogProc for all wxWidgets dialogs
1591 LONG APIENTRY _EXPORT
1592 wxDlgProc(HWND hDlg
,
1594 WPARAM
WXUNUSED(wParam
),
1595 LPARAM
WXUNUSED(lParam
))
1601 // under CE, add a "Ok" button in the dialog title bar and make it full
1604 // TODO: find the window for this HWND, and take into account
1605 // wxMAXIMIZE and wxCLOSE_BOX. For now, assume both are present.
1607 // Standard SDK doesn't have aygshell.dll: see
1608 // include/wx/msw/wince/libraries.h
1609 #if defined(__WXWINCE__) && !defined(__WINCE_STANDARDSDK__) && !defined(__HANDHELDPC__)
1610 SHINITDLGINFO shidi
;
1611 shidi
.dwMask
= SHIDIM_FLAGS
;
1612 shidi
.dwFlags
= SHIDIF_SIZEDLG
// take account of the SIP or menubar
1613 #ifndef __SMARTPHONE__
1618 SHInitDialog( &shidi
);
1619 #else // no SHInitDialog()
1622 // for WM_INITDIALOG, returning TRUE tells system to set focus to
1623 // the first control in the dialog box, but as we set the focus
1624 // ourselves, we return FALSE for it as well
1629 // for almost all messages, returning FALSE means that we didn't process
1634 // ============================================================================
1635 // wxTLWHiddenParentModule implementation
1636 // ============================================================================
1638 HWND
wxTLWHiddenParentModule::ms_hwnd
= NULL
;
1640 const wxChar
*wxTLWHiddenParentModule::ms_className
= NULL
;
1642 bool wxTLWHiddenParentModule::OnInit()
1645 ms_className
= NULL
;
1650 void wxTLWHiddenParentModule::OnExit()
1654 if ( !::DestroyWindow(ms_hwnd
) )
1656 wxLogLastError(wxT("DestroyWindow(hidden TLW parent)"));
1664 if ( !::UnregisterClass(ms_className
, wxGetInstance()) )
1666 wxLogLastError(wxT("UnregisterClass(\"wxTLWHiddenParent\")"));
1669 ms_className
= NULL
;
1674 HWND
wxTLWHiddenParentModule::GetHWND()
1678 if ( !ms_className
)
1680 static const wxChar
*HIDDEN_PARENT_CLASS
= wxT("wxTLWHiddenParent");
1683 wxZeroMemory(wndclass
);
1685 wndclass
.lpfnWndProc
= DefWindowProc
;
1686 wndclass
.hInstance
= wxGetInstance();
1687 wndclass
.lpszClassName
= HIDDEN_PARENT_CLASS
;
1689 if ( !::RegisterClass(&wndclass
) )
1691 wxLogLastError(wxT("RegisterClass(\"wxTLWHiddenParent\")"));
1695 ms_className
= HIDDEN_PARENT_CLASS
;
1699 ms_hwnd
= ::CreateWindow(ms_className
, wxEmptyString
, 0, 0, 0, 0, 0, NULL
,
1700 (HMENU
)NULL
, wxGetInstance(), NULL
);
1703 wxLogLastError(wxT("CreateWindow(hidden TLW parent)"));