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
;
164 WXDWORD
wxTopLevelWindowMSW::MSWGetStyle(long style
, WXDWORD
*exflags
) const
166 // let the base class deal with the common styles but fix the ones which
167 // don't make sense for us (we also deal with the borders ourselves)
168 WXDWORD msflags
= wxWindow::MSWGetStyle
170 (style
& ~wxBORDER_MASK
) | wxBORDER_NONE
, exflags
171 ) & ~WS_CHILD
& ~WS_VISIBLE
;
173 // For some reason, WS_VISIBLE needs to be defined on creation for
174 // SmartPhone 2003. The title can fail to be displayed otherwise.
175 #if defined(__SMARTPHONE__) || (defined(__WXWINCE__) && _WIN32_WCE < 400)
176 msflags
|= WS_VISIBLE
;
177 ((wxTopLevelWindowMSW
*)this)->wxWindowBase::Show(true);
180 // first select the kind of window being created
182 // note that if we don't set WS_POPUP, Windows assumes WS_OVERLAPPED and
183 // creates a window with both caption and border, hence we need to use
184 // WS_POPUP in a few cases just to avoid having caption/border which we
187 // border and caption styles
188 if ( ( style
& wxRESIZE_BORDER
) && !IsAlwaysMaximized())
189 msflags
|= WS_THICKFRAME
;
190 else if ( exflags
&& ((style
& wxBORDER_DOUBLE
) || (style
& wxBORDER_RAISED
)) )
191 *exflags
|= WS_EX_DLGMODALFRAME
;
192 else if ( !(style
& wxBORDER_NONE
) )
193 msflags
|= WS_BORDER
;
199 // normally we consider that all windows without a caption must be popups,
200 // but CE is an exception: there windows normally do not have the caption
201 // but shouldn't be made popups as popups can't have menus and don't look
202 // like normal windows anyhow
204 // TODO: Smartphone appears to like wxCAPTION, but we should check that
206 #if defined(__SMARTPHONE__) || !defined(__WXWINCE__)
207 if ( style
& wxCAPTION
)
208 msflags
|= WS_CAPTION
;
212 #endif // !__WXWINCE__
215 // next translate the individual flags
217 // WS_EX_CONTEXTHELP is incompatible with WS_MINIMIZEBOX and WS_MAXIMIZEBOX
218 // and is ignored if we specify both of them, but chances are that if we
219 // use wxWS_EX_CONTEXTHELP, we really do want to have the context help
220 // button while wxMINIMIZE/wxMAXIMIZE are included by default, so the help
222 if ( !(GetExtraStyle() & wxWS_EX_CONTEXTHELP
) )
224 if ( style
& wxMINIMIZE_BOX
)
225 msflags
|= WS_MINIMIZEBOX
;
226 if ( style
& wxMAXIMIZE_BOX
)
227 msflags
|= WS_MAXIMIZEBOX
;
231 // notice that if wxCLOSE_BOX is specified we need to use WS_SYSMENU too as
232 // otherwise the close box doesn't appear
233 if ( style
& (wxSYSTEM_MENU
| wxCLOSE_BOX
) )
234 msflags
|= WS_SYSMENU
;
235 #endif // !__WXWINCE__
237 // NB: under CE these 2 styles are not supported currently, we should
238 // call Minimize()/Maximize() "manually" if we want to support them
239 if ( style
& wxMINIMIZE
)
240 msflags
|= WS_MINIMIZE
;
242 if ( style
& wxMAXIMIZE
)
243 msflags
|= WS_MAXIMIZE
;
245 // Keep this here because it saves recoding this function in wxTinyFrame
246 if ( style
& wxTINY_CAPTION
)
247 msflags
|= WS_CAPTION
;
251 // there is no taskbar under CE, so omit all this
252 #if !defined(__WXWINCE__)
253 if ( !(GetExtraStyle() & wxTOPLEVEL_EX_DIALOG
) )
255 if ( style
& wxFRAME_TOOL_WINDOW
)
257 // create the palette-like window
258 *exflags
|= WS_EX_TOOLWINDOW
;
260 // tool windows shouldn't appear on the taskbar (as documented)
261 style
|= wxFRAME_NO_TASKBAR
;
264 // We have to solve 2 different problems here:
266 // 1. frames with wxFRAME_NO_TASKBAR flag shouldn't appear in the
267 // taskbar even if they don't have a parent
269 // 2. frames without this style should appear in the taskbar even
270 // if they're owned (Windows only puts non owned windows into
271 // the taskbar normally)
273 // The second one is solved here by using WS_EX_APPWINDOW flag, the
274 // first one is dealt with in our MSWGetParent() method
276 if ( !(style
& wxFRAME_NO_TASKBAR
) && GetParent() )
278 // need to force the frame to appear in the taskbar
279 *exflags
|= WS_EX_APPWINDOW
;
281 //else: nothing to do [here]
284 if ( GetExtraStyle() & wxWS_EX_CONTEXTHELP
)
285 *exflags
|= WS_EX_CONTEXTHELP
;
286 #endif // !__WXWINCE__
288 if ( style
& wxSTAY_ON_TOP
)
289 *exflags
|= WS_EX_TOPMOST
;
295 WXHWND
wxTopLevelWindowMSW::MSWGetParent() const
297 // for the frames without wxFRAME_FLOAT_ON_PARENT style we should use NULL
298 // parent HWND or it would be always on top of its parent which is not what
299 // we usually want (in fact, we only want it for frames with the
300 // wxFRAME_FLOAT_ON_PARENT flag)
301 HWND hwndParent
= NULL
;
302 if ( HasFlag(wxFRAME_FLOAT_ON_PARENT
) )
304 const wxWindow
*parent
= GetParent();
308 // this flag doesn't make sense then and will be ignored
309 wxFAIL_MSG( wxT("wxFRAME_FLOAT_ON_PARENT but no parent?") );
313 hwndParent
= GetHwndOf(parent
);
316 //else: don't float on parent, must not be owned
318 // now deal with the 2nd taskbar-related problem (see comments above in
320 if ( HasFlag(wxFRAME_NO_TASKBAR
) && !hwndParent
)
323 hwndParent
= wxTLWHiddenParentModule::GetHWND();
326 return (WXHWND
)hwndParent
;
329 #if defined(__SMARTPHONE__) || defined(__POCKETPC__)
330 bool wxTopLevelWindowMSW::HandleSettingChange(WXWPARAM wParam
, WXLPARAM lParam
)
332 SHACTIVATEINFO
*info
= (SHACTIVATEINFO
*) m_activateInfo
;
335 SHHandleWMSettingChange(GetHwnd(), wParam
, lParam
, info
);
338 return wxWindowMSW::HandleSettingChange(wParam
, lParam
);
342 WXLRESULT
wxTopLevelWindowMSW::MSWWindowProc(WXUINT message
, WXWPARAM wParam
, WXLPARAM lParam
)
345 bool processed
= false;
349 #if defined(__SMARTPHONE__) || defined(__POCKETPC__)
352 SHACTIVATEINFO
* info
= (SHACTIVATEINFO
*) m_activateInfo
;
356 if (GetExtraStyle() & wxTOPLEVEL_EX_DIALOG
) flags
= SHA_INPUTDIALOG
;
357 SHHandleWMActivate(GetHwnd(), wParam
, lParam
, info
, flags
);
360 // This implicitly sends a wxEVT_ACTIVATE_APP event
362 wxTheApp
->SetActive(wParam
!= 0, FindFocus());
370 wxActivateEvent
event(wxEVT_HIBERNATE
, true, wxID_ANY
);
371 event
.SetEventObject(wxTheApp
);
372 processed
= wxTheApp
->ProcessEvent(event
);
376 #endif // __SMARTPHONE__ || __POCKETPC__
382 // ... the four low-order bits of the wParam parameter are
383 // used internally by the system. To obtain the correct
384 // result when testing the value of wParam, an application
385 // must combine the value 0xFFF0 with the wParam value by
386 // using the bitwise AND operator.
387 unsigned id
= wParam
& 0xfff0;
389 // Preserve the focus when minimizing/restoring the window: we
390 // need to do it manually as DefWindowProc() doesn't appear to
391 // do this for us for some reason (perhaps because we don't use
392 // WM_NEXTDLGCTL for setting focus?). Moreover, our code in
393 // OnActivate() doesn't work in this case as we receive the
394 // deactivation event too late when the window is being
395 // minimized and the focus is already NULL by then. Similarly,
396 // we receive the activation event too early and restoring
397 // focus in it fails because the window is still minimized. So
398 // we need to do it here.
399 if ( id
== SC_MINIMIZE
)
401 // For minimization, it's simple enough: just save the
402 // focus as usual. The important thing is that we're not
403 // minimized yet, so this works correctly.
406 else if ( id
== SC_RESTORE
)
408 // For restoring, it's trickier as DefWindowProc() sets
409 // focus to the window itself. So run it first and restore
410 // our saved focus only afterwards.
412 rc
= wxTopLevelWindowBase::MSWWindowProc(message
,
415 DoRestoreLastFocus();
418 #ifndef __WXUNIVERSAL__
419 // We need to generate events for the custom items added to the
420 // system menu if it had been created (and presumably modified).
421 // As SC_SIZE is the first of the system-defined commands, we
422 // only do this for the custom commands before it and leave
423 // SC_SIZE and everything after it to DefWindowProc().
424 if ( m_menuSystem
&& id
< SC_SIZE
)
426 if ( m_menuSystem
->MSWCommand(0 /* unused anyhow */, id
) )
429 #endif // #ifndef __WXUNIVERSAL__
433 #if !defined(__WXMICROWIN__) && !defined(__WXWINCE__)
435 case WM_INITMENUPOPUP
:
436 processed
= HandleMenuPopup(wxEVT_MENU_OPEN
, (WXHMENU
)wParam
);
443 UnpackMenuSelect(wParam
, lParam
, &item
, &flags
, &hmenu
);
445 processed
= HandleMenuSelect(item
, flags
, hmenu
);
449 case WM_EXITMENULOOP
:
450 // Under Windows 98 and 2000 and later we're going to get
451 // WM_UNINITMENUPOPUP which will be used to generate this event
452 // with more information (notably the menu that was closed) so we
453 // only need this one under old Windows systems where the newer
454 // event is never sent.
455 if ( wxGetWinVersion() < wxWinVersion_98
)
456 processed
= HandleExitMenuLoop(wParam
);
459 case WM_UNINITMENUPOPUP
:
460 processed
= HandleMenuPopup(wxEVT_MENU_CLOSE
, (WXHMENU
)wParam
);
462 #endif // wxUSE_MENUS
463 #endif // !__WXMICROWIN__
467 rc
= wxTopLevelWindowBase::MSWWindowProc(message
, wParam
, lParam
);
472 bool wxTopLevelWindowMSW::CreateDialog(const void *dlgTemplate
,
473 const wxString
& title
,
477 #ifdef __WXMICROWIN__
478 // no dialogs support under MicroWin yet
479 return CreateFrame(title
, pos
, size
);
480 #else // !__WXMICROWIN__
481 // static cast is valid as we're only ever called for dialogs
483 parent
= static_cast<wxDialog
*>(this)->GetParentForModalDialog();
485 m_hWnd
= (WXHWND
)::CreateDialogIndirect
488 (DLGTEMPLATE
*)dlgTemplate
,
489 parent
? GetHwndOf(parent
) : NULL
,
495 wxFAIL_MSG(wxT("Failed to create dialog. Incorrect DLGTEMPLATE?"));
497 wxLogSysError(wxT("Can't create dialog using memory template"));
502 #if !defined(__WXWINCE__)
503 // For some reason, the system menu is activated when we use the
504 // WS_EX_CONTEXTHELP style, so let's set a reasonable icon
505 if ( HasExtraStyle(wxWS_EX_CONTEXTHELP
) )
507 wxFrame
*winTop
= wxDynamicCast(wxTheApp
->GetTopWindow(), wxFrame
);
510 wxIcon icon
= winTop
->GetIcon();
513 ::SendMessage(GetHwnd(), WM_SETICON
,
515 (LPARAM
)GetHiconOf(icon
));
519 #endif // !__WXWINCE__
521 if ( !title
.empty() )
523 ::SetWindowText(GetHwnd(), title
.t_str());
528 #if !defined(__WXWINCE__) || defined(__WINCE_STANDARDSDK__)
529 // move the dialog to its initial position without forcing repainting
531 (void)MSWGetCreateWindowCoords(pos
, size
, x
, y
, w
, h
);
533 if ( x
== (int)CW_USEDEFAULT
)
535 // Let the system position the window, just set its size.
536 ::SetWindowPos(GetHwnd(), 0,
538 SWP_NOMOVE
| SWP_NOZORDER
| SWP_NOACTIVATE
);
540 else // Move the window to the desired location and set its size too.
542 if ( !::MoveWindow(GetHwnd(), x
, y
, w
, h
, FALSE
) )
544 wxLogLastError(wxT("MoveWindow"));
547 #endif // !__WXWINCE__
549 #ifdef __SMARTPHONE__
550 // Work around title non-display glitch
555 #endif // __WXMICROWIN__/!__WXMICROWIN__
558 bool wxTopLevelWindowMSW::CreateFrame(const wxString
& title
,
563 WXDWORD flags
= MSWGetCreateWindowFlags(&exflags
);
565 const wxSize sz
= IsAlwaysMaximized() ? wxDefaultSize
: size
;
568 if ( wxTheApp
->GetLayoutDirection() == wxLayout_RightToLeft
)
569 exflags
|= WS_EX_LAYOUTRTL
;
572 return MSWCreate(MSWGetRegisteredClassName(),
573 title
.t_str(), pos
, sz
, flags
, exflags
);
576 bool wxTopLevelWindowMSW::Create(wxWindow
*parent
,
578 const wxString
& title
,
582 const wxString
& name
)
584 wxSize sizeReal
= size
;
585 if ( !sizeReal
.IsFullySpecified() )
587 sizeReal
.SetDefaults(GetDefaultSize());
590 // notice that we should append this window to wxTopLevelWindows list
591 // before calling CreateBase() as it behaves differently for TLW and
593 wxTopLevelWindows
.Append(this);
595 bool ret
= CreateBase(parent
, id
, pos
, sizeReal
, style
, name
);
600 parent
->AddChild(this);
602 if ( GetExtraStyle() & wxTOPLEVEL_EX_DIALOG
)
604 // we have different dialog templates to allows creation of dialogs
605 // with & without captions under MSWindows, resizable or not (but a
606 // resizable dialog always has caption - otherwise it would look too
609 // we need 3 additional WORDs for dialog menu, class and title (as we
610 // don't use DS_SETFONT we don't need the fourth WORD for the font)
611 static const int dlgsize
= sizeof(DLGTEMPLATE
) + (sizeof(WORD
) * 3);
612 DLGTEMPLATE
*dlgTemplate
= (DLGTEMPLATE
*)malloc(dlgsize
);
613 memset(dlgTemplate
, 0, dlgsize
);
615 // these values are arbitrary, they won't be used normally anyhow
618 dlgTemplate
->cx
= 144;
619 dlgTemplate
->cy
= 75;
621 // reuse the code in MSWGetStyle() but correct the results slightly for
624 // NB: we need a temporary variable as we can't pass pointer to
625 // dwExtendedStyle directly, it's not aligned correctly for 64 bit
627 WXDWORD dwExtendedStyle
;
628 dlgTemplate
->style
= MSWGetStyle(style
, &dwExtendedStyle
);
629 dlgTemplate
->dwExtendedStyle
= dwExtendedStyle
;
631 // all dialogs are popups
632 dlgTemplate
->style
|= WS_POPUP
;
635 if ( wxTheApp
->GetLayoutDirection() == wxLayout_RightToLeft
)
637 dlgTemplate
->dwExtendedStyle
|= WS_EX_LAYOUTRTL
;
640 // force 3D-look if necessary, it looks impossibly ugly otherwise
641 if ( style
& (wxRESIZE_BORDER
| wxCAPTION
) )
642 dlgTemplate
->style
|= DS_MODALFRAME
;
645 ret
= CreateDialog(dlgTemplate
, title
, pos
, sizeReal
);
650 ret
= CreateFrame(title
, pos
, sizeReal
);
654 if ( ret
&& !(GetWindowStyleFlag() & wxCLOSE_BOX
) )
656 EnableCloseButton(false);
660 // for standard dialogs the dialog manager generates WM_CHANGEUISTATE
661 // itself but for custom windows we have to do it ourselves in order to
662 // make the keyboard indicators (such as underlines for accelerators and
663 // focus rectangles) work under Win2k+
666 MSWUpdateUIState(UIS_INITIALIZE
);
669 // Note: if we include PocketPC in this test, dialogs can fail to show up,
670 // for example the text entry dialog in the dialogs sample. Problem with Maximise()?
671 #if defined(__WXWINCE__) && (defined(__SMARTPHONE__) || defined(__WINCE_STANDARDSDK__))
672 if ( ( style
& wxMAXIMIZE
) || IsAlwaysMaximized() )
678 #if defined(__SMARTPHONE__) && defined(__WXWINCE__)
679 SetRightMenu(); // to nothing for initialization
685 wxTopLevelWindowMSW::~wxTopLevelWindowMSW()
691 #if defined(__SMARTPHONE__) || defined(__POCKETPC__)
692 SHACTIVATEINFO
* info
= (SHACTIVATEINFO
*) m_activateInfo
;
694 m_activateInfo
= NULL
;
697 // after destroying an owned window, Windows activates the next top level
698 // window in Z order but it may be different from our owner (to reproduce
699 // this simply Alt-TAB to another application and back before closing the
700 // owned frame) whereas we always want to yield activation to our parent
701 if ( HasFlag(wxFRAME_FLOAT_ON_PARENT
) )
703 wxWindow
*parent
= GetParent();
706 ::BringWindowToTop(GetHwndOf(parent
));
711 // ----------------------------------------------------------------------------
712 // wxTopLevelWindowMSW showing
713 // ----------------------------------------------------------------------------
715 void wxTopLevelWindowMSW::DoShowWindow(int nShowCmd
)
717 ::ShowWindow(GetHwnd(), nShowCmd
);
719 // Hiding the window doesn't change its iconized state.
720 if ( nShowCmd
!= SW_HIDE
)
722 // Otherwise restoring, maximizing or showing the window normally also
723 // makes it not iconized and only minimizing it does make it iconized.
724 m_iconized
= nShowCmd
== SW_MINIMIZE
;
728 void wxTopLevelWindowMSW::ShowWithoutActivating()
730 if ( !wxWindowBase::Show(true) )
733 DoShowWindow(SW_SHOWNA
);
736 bool wxTopLevelWindowMSW::Show(bool show
)
738 // don't use wxWindow version as we want to call DoShowWindow() ourselves
739 if ( !wxWindowBase::Show(show
) )
745 if ( m_maximizeOnShow
)
748 nShowCmd
= SW_MAXIMIZE
;
750 // This is necessary, or no window appears
751 #if defined( __WINCE_STANDARDSDK__) || defined(__SMARTPHONE__)
752 DoShowWindow(SW_SHOW
);
755 m_maximizeOnShow
= false;
757 else if ( m_iconized
)
759 // We were iconized while we were hidden, so now we need to show
760 // the window in iconized state.
761 nShowCmd
= SW_MINIMIZE
;
763 else if ( ::IsIconic(GetHwnd()) )
765 // We were restored while we were hidden, so now we need to show
766 // the window in its normal state.
768 // As below, don't activate some kinds of windows.
769 if ( HasFlag(wxFRAME_TOOL_WINDOW
) || !IsEnabled() )
770 nShowCmd
= SW_SHOWNOACTIVATE
;
772 nShowCmd
= SW_RESTORE
;
776 // we shouldn't use SW_SHOW which also activates the window for
777 // tool frames (as they shouldn't steal focus from the main window)
778 // nor for the currently disabled windows as they would be enabled
780 if ( HasFlag(wxFRAME_TOOL_WINDOW
) || !IsEnabled() )
781 nShowCmd
= SW_SHOWNA
;
791 #if wxUSE_DEFERRED_SIZING
792 // we only set pending size if we're maximized before being shown, now that
793 // we're shown we don't need it any more (it is reset in size event handler
794 // for child windows but we have to do it ourselves for this parent window)
796 // make sure to reset it before actually showing the window as this will
797 // generate WM_SIZE events and we want to use the correct client size from
798 // them, not the size returned by WM_NCCALCSIZE in DoGetClientSize() which
799 // turns out to be wrong for maximized windows (see #11762)
800 m_pendingSize
= wxDefaultSize
;
801 #endif // wxUSE_DEFERRED_SIZING
803 DoShowWindow(nShowCmd
);
805 #if defined(__WXWINCE__) && (_WIN32_WCE >= 400 && !defined(__POCKETPC__) && !defined(__SMARTPHONE__))
806 // Addornments have to be added when the frame is the correct size
807 wxFrame
* frame
= wxDynamicCast(this, wxFrame
);
808 if (frame
&& frame
->GetMenuBar())
809 frame
->GetMenuBar()->AddAdornments(GetWindowStyleFlag());
815 void wxTopLevelWindowMSW::Raise()
817 ::SetForegroundWindow(GetHwnd());
820 // ----------------------------------------------------------------------------
821 // wxTopLevelWindowMSW maximize/minimize
822 // ----------------------------------------------------------------------------
824 void wxTopLevelWindowMSW::Maximize(bool maximize
)
828 // just maximize it directly
829 DoShowWindow(maximize
? SW_MAXIMIZE
: SW_RESTORE
);
833 // we can't maximize the hidden frame because it shows it as well,
834 // so just remember that we should do it later in this case
835 m_maximizeOnShow
= maximize
;
837 #if wxUSE_DEFERRED_SIZING
838 // after calling Maximize() the client code expects to get the frame
839 // "real" size and doesn't want to know that, because of implementation
840 // details, the frame isn't really maximized yet but will be only once
841 // it's shown, so return our size as it will be then in this case
844 // we must only change pending size here, and not call SetSize()
845 // because otherwise Windows would think that this (full screen)
846 // size is the natural size for the frame and so would use it when
847 // the user clicks on "restore" title bar button instead of the
848 // correct initial frame size
850 // NB: unfortunately we don't know which display we're on yet so we
851 // have to use the default one
852 m_pendingSize
= wxGetClientDisplayRect().GetSize();
854 //else: can't do anything in this case, we don't have the old size
855 #endif // wxUSE_DEFERRED_SIZING
859 bool wxTopLevelWindowMSW::IsMaximized() const
861 return IsAlwaysMaximized() ||
862 #if !defined(__SMARTPHONE__) && !defined(__POCKETPC__) && !defined(__WINCE_STANDARDSDK__)
864 (::IsZoomed(GetHwnd()) != 0) ||
869 void wxTopLevelWindowMSW::Iconize(bool iconize
)
871 if ( iconize
== m_iconized
)
873 // Do nothing, in particular don't restore non-iconized windows when
874 // Iconize(false) is called as this would wrongly un-maximize them.
880 // change the window state immediately
881 DoShowWindow(iconize
? SW_MINIMIZE
: SW_RESTORE
);
885 // iconizing the window shouldn't show it so just update the internal
886 // state (otherwise it's done by DoShowWindow() itself)
887 m_iconized
= iconize
;
891 bool wxTopLevelWindowMSW::IsIconized() const
899 // don't use m_iconized, it may be briefly out of sync with the real state
900 // as it's only modified when we receive a WM_SIZE and we could be called
901 // from an event handler from one of the messages we receive before it,
903 return ::IsIconic(GetHwnd()) != 0;
907 void wxTopLevelWindowMSW::Restore()
909 DoShowWindow(SW_RESTORE
);
912 void wxTopLevelWindowMSW::SetLayoutDirection(wxLayoutDirection dir
)
914 if ( dir
== wxLayout_Default
)
915 dir
= wxTheApp
->GetLayoutDirection();
917 if ( dir
!= wxLayout_Default
)
918 wxTopLevelWindowBase::SetLayoutDirection(dir
);
921 // ----------------------------------------------------------------------------
922 // wxTopLevelWindowMSW geometry
923 // ----------------------------------------------------------------------------
927 void wxTopLevelWindowMSW::DoGetPosition(int *x
, int *y
) const
932 wp
.length
= sizeof(WINDOWPLACEMENT
);
933 if ( ::GetWindowPlacement(GetHwnd(), &wp
) )
935 RECT
& rc
= wp
.rcNormalPosition
;
937 // the position returned by GetWindowPlacement() is in workspace
938 // coordinates except for windows with WS_EX_TOOLWINDOW style
939 if ( !HasFlag(wxFRAME_TOOL_WINDOW
) )
941 // we must use the correct display for the translation as the
942 // task bar might be shown on one display but not the other one
943 int n
= wxDisplay::GetFromWindow(this);
944 wxDisplay
dpy(n
== wxNOT_FOUND
? 0 : n
);
945 const wxPoint ptOfs
= dpy
.GetClientArea().GetPosition() -
946 dpy
.GetGeometry().GetPosition();
960 wxLogLastError(wxT("GetWindowPlacement"));
964 wxTopLevelWindowBase::DoGetPosition(x
, y
);
967 void wxTopLevelWindowMSW::DoGetSize(int *width
, int *height
) const
972 wp
.length
= sizeof(WINDOWPLACEMENT
);
973 if ( ::GetWindowPlacement(GetHwnd(), &wp
) )
975 const RECT
& rc
= wp
.rcNormalPosition
;
978 *width
= rc
.right
- rc
.left
;
980 *height
= rc
.bottom
- rc
.top
;
985 wxLogLastError(wxT("GetWindowPlacement"));
989 wxTopLevelWindowBase::DoGetSize(width
, height
);
992 #endif // __WXWINCE__
995 wxTopLevelWindowMSW::MSWGetCreateWindowCoords(const wxPoint
& pos
,
998 int& w
, int& h
) const
1000 // let the system position the window if no explicit position was specified
1001 if ( pos
.x
== wxDefaultCoord
)
1003 // if x is set to CW_USEDEFAULT, y parameter is ignored anyhow so we
1004 // can just as well set it to CW_USEDEFAULT as well
1010 // OTOH, if x is not set to CW_USEDEFAULT, y shouldn't be set to it
1011 // neither because it is not handled as a special value by Windows then
1012 // and so we have to choose some default value for it, even if a
1013 // completely arbitrary one
1014 static const int DEFAULT_Y
= 200;
1017 y
= pos
.y
== wxDefaultCoord
? DEFAULT_Y
: pos
.y
;
1020 if ( size
.x
== wxDefaultCoord
|| size
.y
== wxDefaultCoord
)
1022 // We don't use CW_USEDEFAULT here for several reasons:
1024 // 1. It results in huge frames on modern screens (1000*800 is not
1025 // uncommon on my 1280*1024 screen) which is way too big for a half
1026 // empty frame of most of wxWidgets samples for example)
1028 // 2. It is buggy for frames with wxFRAME_TOOL_WINDOW style for which
1029 // the default is for whatever reason 8*8 which breaks client <->
1030 // window size calculations (it would be nice if it didn't, but it
1031 // does and the simplest way to fix it seemed to change the broken
1032 // default size anyhow)
1034 // 3. There is just no advantage in doing it: with x and y it is
1035 // possible that [future versions of] Windows position the new top
1036 // level window in some smart way which we can't do, but we can
1037 // guess a reasonably good size for a new window just as well
1040 // The only exception is for the Windows CE platform where the system
1041 // does know better than we how should the windows be sized
1045 #else // !_WIN32_WCE
1046 wxSize sizeReal
= size
;
1047 sizeReal
.SetDefaults(GetDefaultSize());
1051 #endif // _WIN32_WCE/!_WIN32_WCE
1060 // ----------------------------------------------------------------------------
1061 // wxTopLevelWindowMSW fullscreen
1062 // ----------------------------------------------------------------------------
1064 bool wxTopLevelWindowMSW::ShowFullScreen(bool show
, long style
)
1066 if ( show
== IsFullScreen() )
1072 m_fsIsShowing
= show
;
1078 // zap the frame borders
1080 // save the 'normal' window style
1081 m_fsOldWindowStyle
= GetWindowLong(GetHwnd(), GWL_STYLE
);
1083 // save the old position, width & height, maximize state
1084 m_fsOldSize
= GetRect();
1085 m_fsIsMaximized
= IsMaximized();
1087 // decide which window style flags to turn off
1088 LONG newStyle
= m_fsOldWindowStyle
;
1091 if (style
& wxFULLSCREEN_NOBORDER
)
1093 offFlags
|= WS_BORDER
;
1095 offFlags
|= WS_THICKFRAME
;
1098 if (style
& wxFULLSCREEN_NOCAPTION
)
1099 offFlags
|= WS_CAPTION
| WS_SYSMENU
;
1101 newStyle
&= ~offFlags
;
1103 // change our window style to be compatible with full-screen mode
1104 ::SetWindowLong(GetHwnd(), GWL_STYLE
, newStyle
);
1108 // resize to the size of the display containing us
1109 int dpy
= wxDisplay::GetFromWindow(this);
1110 if ( dpy
!= wxNOT_FOUND
)
1112 rect
= wxDisplay(dpy
).GetGeometry();
1114 else // fall back to the main desktop
1115 #endif // wxUSE_DISPLAY
1117 // resize to the size of the desktop
1118 wxCopyRECTToRect(wxGetWindowRect(::GetDesktopWindow()), rect
);
1120 // FIXME: size of the bottom menu (toolbar)
1121 // should be taken in account
1122 rect
.height
+= rect
.y
;
1129 // now flush the window style cache and actually go full-screen
1130 long flags
= SWP_FRAMECHANGED
;
1132 // showing the frame full screen should also show it if it's still
1136 // don't call wxWindow version to avoid flicker from calling
1137 // ::ShowWindow() -- we're going to show the window at the correct
1138 // location directly below -- but do call the wxWindowBase version
1139 // to sync the internal m_isShown flag
1140 wxWindowBase::Show();
1142 flags
|= SWP_SHOWWINDOW
;
1145 SetWindowPos(GetHwnd(), HWND_TOP
,
1146 rect
.x
, rect
.y
, rect
.width
, rect
.height
,
1149 #if !defined(__HANDHELDPC__) && (defined(__WXWINCE__) && (_WIN32_WCE < 400))
1150 ::SHFullScreen(GetHwnd(), SHFS_HIDETASKBAR
| SHFS_HIDESIPBUTTON
);
1153 // finally send an event allowing the window to relayout itself &c
1154 wxSizeEvent
event(rect
.GetSize(), GetId());
1155 event
.SetEventObject(this);
1156 HandleWindowEvent(event
);
1158 else // stop showing full screen
1160 #if !defined(__HANDHELDPC__) && (defined(__WXWINCE__) && (_WIN32_WCE < 400))
1161 ::SHFullScreen(GetHwnd(), SHFS_SHOWTASKBAR
| SHFS_SHOWSIPBUTTON
);
1163 Maximize(m_fsIsMaximized
);
1164 SetWindowLong(GetHwnd(),GWL_STYLE
, m_fsOldWindowStyle
);
1165 SetWindowPos(GetHwnd(),HWND_TOP
,m_fsOldSize
.x
, m_fsOldSize
.y
,
1166 m_fsOldSize
.width
, m_fsOldSize
.height
, SWP_FRAMECHANGED
);
1172 // ----------------------------------------------------------------------------
1173 // wxTopLevelWindowMSW misc
1174 // ----------------------------------------------------------------------------
1176 void wxTopLevelWindowMSW::SetTitle( const wxString
& title
)
1181 wxString
wxTopLevelWindowMSW::GetTitle() const
1186 bool wxTopLevelWindowMSW::DoSelectAndSetIcon(const wxIconBundle
& icons
,
1191 const wxSize
size(::GetSystemMetrics(smX
), ::GetSystemMetrics(smY
));
1193 wxIcon icon
= icons
.GetIcon(size
, wxIconBundle::FALLBACK_NEAREST_LARGER
);
1198 ::SendMessage(GetHwnd(), WM_SETICON
, i
, (LPARAM
)GetHiconOf(icon
));
1202 void wxTopLevelWindowMSW::SetIcons(const wxIconBundle
& icons
)
1204 wxTopLevelWindowBase::SetIcons(icons
);
1206 if ( icons
.IsEmpty() )
1208 // FIXME: SetIcons(wxNullIconBundle) should unset existing icons,
1209 // but we currently don't do that
1210 wxASSERT_MSG( m_icons
.IsEmpty(), "unsetting icons doesn't work" );
1214 DoSelectAndSetIcon(icons
, SM_CXSMICON
, SM_CYSMICON
, ICON_SMALL
);
1215 DoSelectAndSetIcon(icons
, SM_CXICON
, SM_CYICON
, ICON_BIG
);
1218 bool wxTopLevelWindowMSW::EnableCloseButton(bool enable
)
1220 #if !defined(__WXMICROWIN__)
1221 // get system (a.k.a. window) menu
1222 HMENU hmenu
= GetSystemMenu(GetHwnd(), FALSE
/* get it */);
1225 // no system menu at all -- ok if we want to remove the close button
1226 // anyhow, but bad if we want to show it
1230 // enabling/disabling the close item from it also automatically
1231 // disables/enables the close title bar button
1232 if ( ::EnableMenuItem(hmenu
, SC_CLOSE
,
1234 (enable
? MF_ENABLED
: MF_GRAYED
)) == -1 )
1236 wxLogLastError(wxT("EnableMenuItem(SC_CLOSE)"));
1241 // update appearance immediately
1242 if ( !::DrawMenuBar(GetHwnd()) )
1244 wxLogLastError(wxT("DrawMenuBar"));
1247 #endif // !__WXMICROWIN__
1252 void wxTopLevelWindowMSW::RequestUserAttention(int flags
)
1254 // check if we can use FlashWindowEx(): unfortunately a simple test for
1255 // FLASHW_STOP doesn't work because MSVC6 headers do #define it but don't
1256 // provide FlashWindowEx() declaration, so try to detect whether we have
1257 // real headers for WINVER 0x0500 by checking for existence of a symbol not
1258 // declated in MSVC6 header
1259 #if defined(FLASHW_STOP) && defined(VK_XBUTTON1) && wxUSE_DYNLIB_CLASS
1260 // available in the headers, check if it is supported by the system
1261 typedef BOOL (WINAPI
*FlashWindowEx_t
)(FLASHWINFO
*pfwi
);
1262 static FlashWindowEx_t s_pfnFlashWindowEx
= NULL
;
1263 if ( !s_pfnFlashWindowEx
)
1265 wxDynamicLibrary
dllUser32(wxT("user32.dll"));
1266 s_pfnFlashWindowEx
= (FlashWindowEx_t
)
1267 dllUser32
.GetSymbol(wxT("FlashWindowEx"));
1269 // we can safely unload user32.dll here, it's going to remain loaded as
1270 // long as the program is running anyhow
1273 if ( s_pfnFlashWindowEx
)
1275 WinStruct
<FLASHWINFO
> fwi
;
1276 fwi
.hwnd
= GetHwnd();
1277 fwi
.dwFlags
= FLASHW_ALL
;
1278 if ( flags
& wxUSER_ATTENTION_INFO
)
1280 // just flash a few times
1283 else // wxUSER_ATTENTION_ERROR
1285 // flash until the user notices it
1286 fwi
.dwFlags
|= FLASHW_TIMERNOFG
;
1289 s_pfnFlashWindowEx(&fwi
);
1291 else // FlashWindowEx() not available
1292 #endif // FlashWindowEx() defined
1296 ::FlashWindow(GetHwnd(), TRUE
);
1297 #endif // __WXWINCE__
1301 wxMenu
*wxTopLevelWindowMSW::MSWGetSystemMenu() const
1303 #ifndef __WXUNIVERSAL__
1304 if ( !m_menuSystem
)
1306 HMENU hmenu
= ::GetSystemMenu(GetHwnd(), FALSE
);
1309 wxLogLastError(wxT("GetSystemMenu()"));
1313 wxTopLevelWindowMSW
* const
1314 self
= const_cast<wxTopLevelWindowMSW
*>(this);
1316 self
->m_menuSystem
= wxMenu::MSWNewFromHMENU(hmenu
);
1318 // We need to somehow associate this menu with this window to ensure
1319 // that we get events from it. A natural idea would be to pretend that
1320 // it's attached to our menu bar but this wouldn't work if we don't
1321 // have any menu bar which is a common case for applications using
1322 // custom items in the system menu (they mostly do it exactly because
1323 // they don't have any other menus).
1325 // So reuse the invoking window pointer instead, this is not exactly
1326 // correct but doesn't seem to have any serious drawbacks.
1327 m_menuSystem
->SetInvokingWindow(self
);
1329 #endif // #ifndef __WXUNIVERSAL__
1331 return m_menuSystem
;
1334 // ----------------------------------------------------------------------------
1335 // Transparency support
1336 // ---------------------------------------------------------------------------
1338 bool wxTopLevelWindowMSW::SetTransparent(wxByte alpha
)
1340 #if wxUSE_DYNLIB_CLASS
1341 typedef DWORD (WINAPI
*PSETLAYEREDWINDOWATTR
)(HWND
, DWORD
, BYTE
, DWORD
);
1342 static PSETLAYEREDWINDOWATTR
1343 pSetLayeredWindowAttributes
= (PSETLAYEREDWINDOWATTR
)-1;
1345 if ( pSetLayeredWindowAttributes
== (PSETLAYEREDWINDOWATTR
)-1 )
1347 wxDynamicLibrary
dllUser32(wxT("user32.dll"));
1349 // use RawGetSymbol() and not GetSymbol() to avoid error messages under
1350 // Windows 95: there is nothing the user can do about this anyhow
1351 pSetLayeredWindowAttributes
= (PSETLAYEREDWINDOWATTR
)
1352 dllUser32
.RawGetSymbol(wxT("SetLayeredWindowAttributes"));
1354 // it's ok to destroy dllUser32 here, we link statically to user32.dll
1355 // anyhow so it won't be unloaded
1358 if ( !pSetLayeredWindowAttributes
)
1360 #endif // wxUSE_DYNLIB_CLASS
1362 LONG exstyle
= GetWindowLong(GetHwnd(), GWL_EXSTYLE
);
1364 // if setting alpha to fully opaque then turn off the layered style
1367 SetWindowLong(GetHwnd(), GWL_EXSTYLE
, exstyle
& ~WS_EX_LAYERED
);
1372 #if wxUSE_DYNLIB_CLASS
1373 // Otherwise, set the layered style if needed and set the alpha value
1374 if ((exstyle
& WS_EX_LAYERED
) == 0 )
1375 SetWindowLong(GetHwnd(), GWL_EXSTYLE
, exstyle
| WS_EX_LAYERED
);
1377 if ( pSetLayeredWindowAttributes(GetHwnd(), 0, (BYTE
)alpha
, LWA_ALPHA
) )
1379 #endif // wxUSE_DYNLIB_CLASS
1384 bool wxTopLevelWindowMSW::CanSetTransparent()
1386 // The API is available on win2k and above
1388 static int os_type
= -1;
1389 static int ver_major
= -1;
1392 os_type
= ::wxGetOsVersion(&ver_major
);
1394 return (os_type
== wxOS_WINDOWS_NT
&& ver_major
>= 5);
1397 void wxTopLevelWindowMSW::DoFreeze()
1399 // do nothing: freezing toplevel window causes paint and mouse events
1400 // to go through it any TLWs under it, so the best we can do is to freeze
1401 // all children -- and wxWindowBase::Freeze() does that
1404 void wxTopLevelWindowMSW::DoThaw()
1406 // intentionally empty -- see DoFreeze()
1410 // ----------------------------------------------------------------------------
1411 // wxTopLevelWindow event handling
1412 // ----------------------------------------------------------------------------
1414 void wxTopLevelWindowMSW::DoSaveLastFocus()
1419 // remember the last focused child if it is our child
1420 m_winLastFocused
= FindFocus();
1422 if ( m_winLastFocused
)
1424 // and don't remember it if it's a child from some other frame
1425 if ( wxGetTopLevelParent(m_winLastFocused
) != this )
1427 m_winLastFocused
= NULL
;
1432 void wxTopLevelWindowMSW::DoRestoreLastFocus()
1434 wxWindow
*parent
= m_winLastFocused
? m_winLastFocused
->GetParent()
1441 wxSetFocusToChild(parent
, &m_winLastFocused
);
1444 void wxTopLevelWindowMSW::OnActivate(wxActivateEvent
& event
)
1446 if ( event
.GetActive() )
1448 // We get WM_ACTIVATE before being restored from iconized state, so we
1449 // can be still iconized here. In this case, avoid restoring the focus
1450 // as it doesn't work anyhow and we will do when we're really restored.
1457 // restore focus to the child which was last focused unless we already
1459 wxLogTrace(wxT("focus"), wxT("wxTLW %p activated."), m_hWnd
);
1461 wxWindow
*winFocus
= FindFocus();
1462 if ( !winFocus
|| wxGetTopLevelParent(winFocus
) != this )
1463 DoRestoreLastFocus();
1465 else // deactivating
1469 wxLogTrace(wxT("focus"),
1470 wxT("wxTLW %p deactivated, last focused: %p."),
1472 m_winLastFocused
? GetHwndOf(m_winLastFocused
) : NULL
);
1481 wxTopLevelWindowMSW::HandleMenuSelect(WXWORD nItem
, WXWORD flags
, WXHMENU
WXUNUSED(hMenu
))
1483 // sign extend to int from unsigned short we get from Windows
1484 int item
= (signed short)nItem
;
1486 // WM_MENUSELECT is generated for both normal items and menus, including
1487 // the top level menus of the menu bar, which can't be represented using
1488 // any valid identifier in wxMenuEvent so use an otherwise unused value for
1490 if ( flags
& (MF_POPUP
| MF_SEPARATOR
) )
1493 wxMenuEvent
event(wxEVT_MENU_HIGHLIGHT
, item
);
1494 event
.SetEventObject(this);
1496 if ( HandleWindowEvent(event
) )
1499 // by default, i.e. if the event wasn't handled above, clear the status bar
1500 // text when an item which can't have any associated help string in wx API
1502 if ( item
== wxID_NONE
)
1503 DoGiveHelp(wxEmptyString
, true);
1509 wxTopLevelWindowMSW::DoSendMenuOpenCloseEvent(wxEventType evtType
, wxMenu
* menu
, bool popup
)
1511 wxMenuEvent
event(evtType
, popup
? wxID_ANY
: 0, menu
);
1512 event
.SetEventObject(menu
);
1514 return HandleWindowEvent(event
);
1517 bool wxTopLevelWindowMSW::HandleExitMenuLoop(WXWORD isPopup
)
1519 return DoSendMenuOpenCloseEvent(wxEVT_MENU_CLOSE
,
1520 isPopup
? wxCurrentPopupMenu
: NULL
,
1524 bool wxTopLevelWindowMSW::HandleMenuPopup(wxEventType evtType
, WXHMENU hMenu
)
1526 bool isPopup
= false;
1527 wxMenu
* menu
= NULL
;
1528 if ( wxCurrentPopupMenu
&& wxCurrentPopupMenu
->GetHMenu() == hMenu
)
1530 menu
= wxCurrentPopupMenu
;
1535 menu
= MSWFindMenuFromHMENU(hMenu
);
1539 return DoSendMenuOpenCloseEvent(evtType
, menu
, isPopup
);
1542 wxMenu
* wxTopLevelWindowMSW::MSWFindMenuFromHMENU(WXHMENU
WXUNUSED(hMenu
))
1544 // We don't have any menus at this level.
1548 #endif // wxUSE_MENUS
1552 // the DialogProc for all wxWidgets dialogs
1553 LONG APIENTRY _EXPORT
1554 wxDlgProc(HWND hDlg
,
1556 WPARAM
WXUNUSED(wParam
),
1557 LPARAM
WXUNUSED(lParam
))
1563 // under CE, add a "Ok" button in the dialog title bar and make it full
1566 // TODO: find the window for this HWND, and take into account
1567 // wxMAXIMIZE and wxCLOSE_BOX. For now, assume both are present.
1569 // Standard SDK doesn't have aygshell.dll: see
1570 // include/wx/msw/wince/libraries.h
1571 #if defined(__WXWINCE__) && !defined(__WINCE_STANDARDSDK__) && !defined(__HANDHELDPC__)
1572 SHINITDLGINFO shidi
;
1573 shidi
.dwMask
= SHIDIM_FLAGS
;
1574 shidi
.dwFlags
= SHIDIF_SIZEDLG
// take account of the SIP or menubar
1575 #ifndef __SMARTPHONE__
1580 SHInitDialog( &shidi
);
1581 #else // no SHInitDialog()
1584 // for WM_INITDIALOG, returning TRUE tells system to set focus to
1585 // the first control in the dialog box, but as we set the focus
1586 // ourselves, we return FALSE for it as well
1591 // for almost all messages, returning FALSE means that we didn't process
1596 // ============================================================================
1597 // wxTLWHiddenParentModule implementation
1598 // ============================================================================
1600 HWND
wxTLWHiddenParentModule::ms_hwnd
= NULL
;
1602 const wxChar
*wxTLWHiddenParentModule::ms_className
= NULL
;
1604 bool wxTLWHiddenParentModule::OnInit()
1607 ms_className
= NULL
;
1612 void wxTLWHiddenParentModule::OnExit()
1616 if ( !::DestroyWindow(ms_hwnd
) )
1618 wxLogLastError(wxT("DestroyWindow(hidden TLW parent)"));
1626 if ( !::UnregisterClass(ms_className
, wxGetInstance()) )
1628 wxLogLastError(wxT("UnregisterClass(\"wxTLWHiddenParent\")"));
1631 ms_className
= NULL
;
1636 HWND
wxTLWHiddenParentModule::GetHWND()
1640 if ( !ms_className
)
1642 static const wxChar
*HIDDEN_PARENT_CLASS
= wxT("wxTLWHiddenParent");
1645 wxZeroMemory(wndclass
);
1647 wndclass
.lpfnWndProc
= DefWindowProc
;
1648 wndclass
.hInstance
= wxGetInstance();
1649 wndclass
.lpszClassName
= HIDDEN_PARENT_CLASS
;
1651 if ( !::RegisterClass(&wndclass
) )
1653 wxLogLastError(wxT("RegisterClass(\"wxTLWHiddenParent\")"));
1657 ms_className
= HIDDEN_PARENT_CLASS
;
1661 ms_hwnd
= ::CreateWindow(ms_className
, wxEmptyString
, 0, 0, 0, 0, 0, NULL
,
1662 (HMENU
)NULL
, wxGetInstance(), NULL
);
1665 wxLogLastError(wxT("CreateWindow(hidden TLW parent)"));