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 // ----------------------------------------------------------------------------
68 // ----------------------------------------------------------------------------
70 #if wxUSE_MENUS || wxUSE_MENUS_NATIVE
71 extern wxMenu
*wxCurrentPopupMenu
;
72 #endif // wxUSE_MENUS || wxUSE_MENUS_NATIVE
75 // ----------------------------------------------------------------------------
76 // stubs for missing functions under MicroWindows
77 // ----------------------------------------------------------------------------
81 // static inline bool IsIconic(HWND WXUNUSED(hwnd)) { return false; }
82 static inline bool IsZoomed(HWND
WXUNUSED(hwnd
)) { return false; }
84 #endif // __WXMICROWIN__
86 // NB: wxDlgProc must be defined here and not in dialog.cpp because the latter
87 // is not included by wxUniv build which does need wxDlgProc
89 wxDlgProc(HWND hDlg
, UINT message
, WPARAM wParam
, LPARAM lParam
);
91 // ----------------------------------------------------------------------------
92 // wxTLWHiddenParentModule: used to manage the hidden parent window (we need a
93 // module to ensure that the window is always deleted)
94 // ----------------------------------------------------------------------------
96 class wxTLWHiddenParentModule
: public wxModule
99 // module init/finalize
100 virtual bool OnInit();
101 virtual void OnExit();
103 // get the hidden window (creates on demand)
104 static HWND
GetHWND();
107 // the HWND of the hidden parent
110 // the class used to create it
111 static const wxChar
*ms_className
;
113 DECLARE_DYNAMIC_CLASS(wxTLWHiddenParentModule
)
116 IMPLEMENT_DYNAMIC_CLASS(wxTLWHiddenParentModule
, wxModule
)
118 // ============================================================================
119 // wxTopLevelWindowMSW implementation
120 // ============================================================================
122 BEGIN_EVENT_TABLE(wxTopLevelWindowMSW
, wxTopLevelWindowBase
)
123 EVT_ACTIVATE(wxTopLevelWindowMSW::OnActivate
)
126 // ----------------------------------------------------------------------------
127 // wxTopLevelWindowMSW creation
128 // ----------------------------------------------------------------------------
130 void wxTopLevelWindowMSW::Init()
133 m_maximizeOnShow
= false;
135 // Data to save/restore when calling ShowFullScreen
137 m_fsOldWindowStyle
= 0;
138 m_fsIsMaximized
= false;
139 m_fsIsShowing
= false;
141 m_winLastFocused
= NULL
;
143 #if defined(__SMARTPHONE__) && defined(__WXWINCE__)
147 #if defined(__SMARTPHONE__) || defined(__POCKETPC__)
148 SHACTIVATEINFO
* info
= new SHACTIVATEINFO
;
150 info
->cbSize
= sizeof(SHACTIVATEINFO
);
152 m_activateInfo
= (void*) info
;
158 WXDWORD
wxTopLevelWindowMSW::MSWGetStyle(long style
, WXDWORD
*exflags
) const
160 // let the base class deal with the common styles but fix the ones which
161 // don't make sense for us (we also deal with the borders ourselves)
162 WXDWORD msflags
= wxWindow::MSWGetStyle
164 (style
& ~wxBORDER_MASK
) | wxBORDER_NONE
, exflags
165 ) & ~WS_CHILD
& ~WS_VISIBLE
;
167 // For some reason, WS_VISIBLE needs to be defined on creation for
168 // SmartPhone 2003. The title can fail to be displayed otherwise.
169 #if defined(__SMARTPHONE__) || (defined(__WXWINCE__) && _WIN32_WCE < 400)
170 msflags
|= WS_VISIBLE
;
171 ((wxTopLevelWindowMSW
*)this)->wxWindowBase::Show(true);
174 // first select the kind of window being created
176 // note that if we don't set WS_POPUP, Windows assumes WS_OVERLAPPED and
177 // creates a window with both caption and border, hence we need to use
178 // WS_POPUP in a few cases just to avoid having caption/border which we
181 // border and caption styles
182 if ( ( style
& wxRESIZE_BORDER
) && !IsAlwaysMaximized())
183 msflags
|= WS_THICKFRAME
;
184 else if ( exflags
&& ((style
& wxBORDER_DOUBLE
) || (style
& wxBORDER_RAISED
)) )
185 *exflags
|= WS_EX_DLGMODALFRAME
;
186 else if ( !(style
& wxBORDER_NONE
) )
187 msflags
|= WS_BORDER
;
193 // normally we consider that all windows without a caption must be popups,
194 // but CE is an exception: there windows normally do not have the caption
195 // but shouldn't be made popups as popups can't have menus and don't look
196 // like normal windows anyhow
198 // TODO: Smartphone appears to like wxCAPTION, but we should check that
200 #if defined(__SMARTPHONE__) || !defined(__WXWINCE__)
201 if ( style
& wxCAPTION
)
202 msflags
|= WS_CAPTION
;
206 #endif // !__WXWINCE__
209 // next translate the individual flags
211 // WS_EX_CONTEXTHELP is incompatible with WS_MINIMIZEBOX and WS_MAXIMIZEBOX
212 // and is ignored if we specify both of them, but chances are that if we
213 // use wxWS_EX_CONTEXTHELP, we really do want to have the context help
214 // button while wxMINIMIZE/wxMAXIMIZE are included by default, so the help
216 if ( !(GetExtraStyle() & wxWS_EX_CONTEXTHELP
) )
218 if ( style
& wxMINIMIZE_BOX
)
219 msflags
|= WS_MINIMIZEBOX
;
220 if ( style
& wxMAXIMIZE_BOX
)
221 msflags
|= WS_MAXIMIZEBOX
;
225 // notice that if wxCLOSE_BOX is specified we need to use WS_SYSMENU too as
226 // otherwise the close box doesn't appear
227 if ( style
& (wxSYSTEM_MENU
| wxCLOSE_BOX
) )
228 msflags
|= WS_SYSMENU
;
229 #endif // !__WXWINCE__
231 // NB: under CE these 2 styles are not supported currently, we should
232 // call Minimize()/Maximize() "manually" if we want to support them
233 if ( style
& wxMINIMIZE
)
234 msflags
|= WS_MINIMIZE
;
236 if ( style
& wxMAXIMIZE
)
237 msflags
|= WS_MAXIMIZE
;
239 // Keep this here because it saves recoding this function in wxTinyFrame
240 if ( style
& wxTINY_CAPTION
)
241 msflags
|= WS_CAPTION
;
245 // there is no taskbar under CE, so omit all this
246 #if !defined(__WXWINCE__)
247 if ( !(GetExtraStyle() & wxTOPLEVEL_EX_DIALOG
) )
249 if ( style
& wxFRAME_TOOL_WINDOW
)
251 // create the palette-like window
252 *exflags
|= WS_EX_TOOLWINDOW
;
254 // tool windows shouldn't appear on the taskbar (as documented)
255 style
|= wxFRAME_NO_TASKBAR
;
258 // We have to solve 2 different problems here:
260 // 1. frames with wxFRAME_NO_TASKBAR flag shouldn't appear in the
261 // taskbar even if they don't have a parent
263 // 2. frames without this style should appear in the taskbar even
264 // if they're owned (Windows only puts non owned windows into
265 // the taskbar normally)
267 // The second one is solved here by using WS_EX_APPWINDOW flag, the
268 // first one is dealt with in our MSWGetParent() method
270 if ( !(style
& wxFRAME_NO_TASKBAR
) && GetParent() )
272 // need to force the frame to appear in the taskbar
273 *exflags
|= WS_EX_APPWINDOW
;
275 //else: nothing to do [here]
278 if ( GetExtraStyle() & wxWS_EX_CONTEXTHELP
)
279 *exflags
|= WS_EX_CONTEXTHELP
;
280 #endif // !__WXWINCE__
282 if ( style
& wxSTAY_ON_TOP
)
283 *exflags
|= WS_EX_TOPMOST
;
289 WXHWND
wxTopLevelWindowMSW::MSWGetParent() const
291 // for the frames without wxFRAME_FLOAT_ON_PARENT style we should use NULL
292 // parent HWND or it would be always on top of its parent which is not what
293 // we usually want (in fact, we only want it for frames with the
294 // wxFRAME_FLOAT_ON_PARENT flag)
295 HWND hwndParent
= NULL
;
296 if ( HasFlag(wxFRAME_FLOAT_ON_PARENT
) )
298 const wxWindow
*parent
= GetParent();
302 // this flag doesn't make sense then and will be ignored
303 wxFAIL_MSG( wxT("wxFRAME_FLOAT_ON_PARENT but no parent?") );
307 hwndParent
= GetHwndOf(parent
);
310 //else: don't float on parent, must not be owned
312 // now deal with the 2nd taskbar-related problem (see comments above in
314 if ( HasFlag(wxFRAME_NO_TASKBAR
) && !hwndParent
)
317 hwndParent
= wxTLWHiddenParentModule::GetHWND();
320 return (WXHWND
)hwndParent
;
323 #if defined(__SMARTPHONE__) || defined(__POCKETPC__)
324 bool wxTopLevelWindowMSW::HandleSettingChange(WXWPARAM wParam
, WXLPARAM lParam
)
326 SHACTIVATEINFO
*info
= (SHACTIVATEINFO
*) m_activateInfo
;
329 SHHandleWMSettingChange(GetHwnd(), wParam
, lParam
, info
);
332 return wxWindowMSW::HandleSettingChange(wParam
, lParam
);
336 WXLRESULT
wxTopLevelWindowMSW::MSWWindowProc(WXUINT message
, WXWPARAM wParam
, WXLPARAM lParam
)
339 bool processed
= false;
343 #if defined(__SMARTPHONE__) || defined(__POCKETPC__)
346 SHACTIVATEINFO
* info
= (SHACTIVATEINFO
*) m_activateInfo
;
350 if (GetExtraStyle() & wxTOPLEVEL_EX_DIALOG
) flags
= SHA_INPUTDIALOG
;
351 SHHandleWMActivate(GetHwnd(), wParam
, lParam
, info
, flags
);
354 // This implicitly sends a wxEVT_ACTIVATE_APP event
356 wxTheApp
->SetActive(wParam
!= 0, FindFocus());
364 wxActivateEvent
event(wxEVT_HIBERNATE
, true, wxID_ANY
);
365 event
.SetEventObject(wxTheApp
);
366 processed
= wxTheApp
->ProcessEvent(event
);
370 #endif // __SMARTPHONE__ || __POCKETPC__
376 // ... the four low-order bits of the wParam parameter are
377 // used internally by the system. To obtain the correct
378 // result when testing the value of wParam, an application
379 // must combine the value 0xFFF0 with the wParam value by
380 // using the bitwise AND operator.
381 unsigned id
= wParam
& 0xfff0;
383 // Preserve the focus when minimizing/restoring the window: we
384 // need to do it manually as DefWindowProc() doesn't appear to
385 // do this for us for some reason (perhaps because we don't use
386 // WM_NEXTDLGCTL for setting focus?). Moreover, our code in
387 // OnActivate() doesn't work in this case as we receive the
388 // deactivation event too late when the window is being
389 // minimized and the focus is already NULL by then. Similarly,
390 // we receive the activation event too early and restoring
391 // focus in it fails because the window is still minimized. So
392 // we need to do it here.
393 if ( id
== SC_MINIMIZE
)
395 // For minimization, it's simple enough: just save the
396 // focus as usual. The important thing is that we're not
397 // minimized yet, so this works correctly.
400 else if ( id
== SC_RESTORE
)
402 // For restoring, it's trickier as DefWindowProc() sets
403 // focus to the window itself. So run it first and restore
404 // our saved focus only afterwards.
406 rc
= wxTopLevelWindowBase::MSWWindowProc(message
,
409 DoRestoreLastFocus();
412 #ifndef __WXUNIVERSAL__
413 // We need to generate events for the custom items added to the
414 // system menu if it had been created (and presumably modified).
415 // As SC_SIZE is the first of the system-defined commands, we
416 // only do this for the custom commands before it and leave
417 // SC_SIZE and everything after it to DefWindowProc().
418 if ( m_menuSystem
&& id
< SC_SIZE
)
420 if ( m_menuSystem
->MSWCommand(0 /* unused anyhow */, id
) )
423 #endif // #ifndef __WXUNIVERSAL__
427 #if !defined(__WXMICROWIN__) && !defined(__WXWINCE__)
429 case WM_INITMENUPOPUP
:
430 processed
= HandleMenuPopup(wxEVT_MENU_OPEN
, (WXHMENU
)wParam
);
437 UnpackMenuSelect(wParam
, lParam
, &item
, &flags
, &hmenu
);
439 processed
= HandleMenuSelect(item
, flags
, hmenu
);
443 case WM_EXITMENULOOP
:
444 // Under Windows 98 and 2000 and later we're going to get
445 // WM_UNINITMENUPOPUP which will be used to generate this event
446 // with more information (notably the menu that was closed) so we
447 // only need this one under old Windows systems where the newer
448 // event is never sent.
449 if ( wxGetWinVersion() < wxWinVersion_98
)
450 processed
= HandleExitMenuLoop(wParam
);
453 case WM_UNINITMENUPOPUP
:
454 processed
= HandleMenuPopup(wxEVT_MENU_CLOSE
, (WXHMENU
)wParam
);
456 #endif // wxUSE_MENUS
457 #endif // !__WXMICROWIN__
461 rc
= wxTopLevelWindowBase::MSWWindowProc(message
, wParam
, lParam
);
466 bool wxTopLevelWindowMSW::CreateDialog(const void *dlgTemplate
,
467 const wxString
& title
,
471 #ifdef __WXMICROWIN__
472 // no dialogs support under MicroWin yet
473 return CreateFrame(title
, pos
, size
);
474 #else // !__WXMICROWIN__
475 // static cast is valid as we're only ever called for dialogs
477 parent
= static_cast<wxDialog
*>(this)->GetParentForModalDialog();
479 m_hWnd
= (WXHWND
)::CreateDialogIndirect
482 (DLGTEMPLATE
*)dlgTemplate
,
483 parent
? GetHwndOf(parent
) : NULL
,
489 wxFAIL_MSG(wxT("Failed to create dialog. Incorrect DLGTEMPLATE?"));
491 wxLogSysError(wxT("Can't create dialog using memory template"));
496 #if !defined(__WXWINCE__)
497 // For some reason, the system menu is activated when we use the
498 // WS_EX_CONTEXTHELP style, so let's set a reasonable icon
499 if ( HasExtraStyle(wxWS_EX_CONTEXTHELP
) )
501 wxFrame
*winTop
= wxDynamicCast(wxTheApp
->GetTopWindow(), wxFrame
);
504 wxIcon icon
= winTop
->GetIcon();
507 ::SendMessage(GetHwnd(), WM_SETICON
,
509 (LPARAM
)GetHiconOf(icon
));
513 #endif // !__WXWINCE__
515 if ( !title
.empty() )
517 ::SetWindowText(GetHwnd(), title
.t_str());
522 #if !defined(__WXWINCE__) || defined(__WINCE_STANDARDSDK__)
523 // move the dialog to its initial position without forcing repainting
525 (void)MSWGetCreateWindowCoords(pos
, size
, x
, y
, w
, h
);
527 if ( x
== (int)CW_USEDEFAULT
)
529 // Let the system position the window, just set its size.
530 ::SetWindowPos(GetHwnd(), 0,
532 SWP_NOMOVE
| SWP_NOZORDER
| SWP_NOACTIVATE
);
534 else // Move the window to the desired location and set its size too.
536 if ( !::MoveWindow(GetHwnd(), x
, y
, w
, h
, FALSE
) )
538 wxLogLastError(wxT("MoveWindow"));
541 #endif // !__WXWINCE__
543 #ifdef __SMARTPHONE__
544 // Work around title non-display glitch
549 #endif // __WXMICROWIN__/!__WXMICROWIN__
552 bool wxTopLevelWindowMSW::CreateFrame(const wxString
& title
,
557 WXDWORD flags
= MSWGetCreateWindowFlags(&exflags
);
559 const wxSize sz
= IsAlwaysMaximized() ? wxDefaultSize
: size
;
562 if ( wxTheApp
->GetLayoutDirection() == wxLayout_RightToLeft
)
563 exflags
|= WS_EX_LAYOUTRTL
;
566 return MSWCreate(MSWGetRegisteredClassName(),
567 title
.t_str(), pos
, sz
, flags
, exflags
);
570 bool wxTopLevelWindowMSW::Create(wxWindow
*parent
,
572 const wxString
& title
,
576 const wxString
& name
)
578 wxSize sizeReal
= size
;
579 if ( !sizeReal
.IsFullySpecified() )
581 sizeReal
.SetDefaults(GetDefaultSize());
584 // notice that we should append this window to wxTopLevelWindows list
585 // before calling CreateBase() as it behaves differently for TLW and
587 wxTopLevelWindows
.Append(this);
589 bool ret
= CreateBase(parent
, id
, pos
, sizeReal
, style
, name
);
594 parent
->AddChild(this);
596 if ( GetExtraStyle() & wxTOPLEVEL_EX_DIALOG
)
598 // we have different dialog templates to allows creation of dialogs
599 // with & without captions under MSWindows, resizable or not (but a
600 // resizable dialog always has caption - otherwise it would look too
603 // we need 3 additional WORDs for dialog menu, class and title (as we
604 // don't use DS_SETFONT we don't need the fourth WORD for the font)
605 static const int dlgsize
= sizeof(DLGTEMPLATE
) + (sizeof(WORD
) * 3);
606 DLGTEMPLATE
*dlgTemplate
= (DLGTEMPLATE
*)malloc(dlgsize
);
607 memset(dlgTemplate
, 0, dlgsize
);
609 // these values are arbitrary, they won't be used normally anyhow
612 dlgTemplate
->cx
= 144;
613 dlgTemplate
->cy
= 75;
615 // reuse the code in MSWGetStyle() but correct the results slightly for
618 // NB: we need a temporary variable as we can't pass pointer to
619 // dwExtendedStyle directly, it's not aligned correctly for 64 bit
621 WXDWORD dwExtendedStyle
;
622 dlgTemplate
->style
= MSWGetStyle(style
, &dwExtendedStyle
);
623 dlgTemplate
->dwExtendedStyle
= dwExtendedStyle
;
625 // all dialogs are popups
626 dlgTemplate
->style
|= WS_POPUP
;
629 if ( wxTheApp
->GetLayoutDirection() == wxLayout_RightToLeft
)
631 dlgTemplate
->dwExtendedStyle
|= WS_EX_LAYOUTRTL
;
634 // force 3D-look if necessary, it looks impossibly ugly otherwise
635 if ( style
& (wxRESIZE_BORDER
| wxCAPTION
) )
636 dlgTemplate
->style
|= DS_MODALFRAME
;
639 ret
= CreateDialog(dlgTemplate
, title
, pos
, sizeReal
);
644 ret
= CreateFrame(title
, pos
, sizeReal
);
648 if ( ret
&& !(GetWindowStyleFlag() & wxCLOSE_BOX
) )
650 EnableCloseButton(false);
654 // for standard dialogs the dialog manager generates WM_CHANGEUISTATE
655 // itself but for custom windows we have to do it ourselves in order to
656 // make the keyboard indicators (such as underlines for accelerators and
657 // focus rectangles) work under Win2k+
660 MSWUpdateUIState(UIS_INITIALIZE
);
663 // Note: if we include PocketPC in this test, dialogs can fail to show up,
664 // for example the text entry dialog in the dialogs sample. Problem with Maximise()?
665 #if defined(__WXWINCE__) && (defined(__SMARTPHONE__) || defined(__WINCE_STANDARDSDK__))
666 if ( ( style
& wxMAXIMIZE
) || IsAlwaysMaximized() )
672 #if defined(__SMARTPHONE__) && defined(__WXWINCE__)
673 SetRightMenu(); // to nothing for initialization
679 wxTopLevelWindowMSW::~wxTopLevelWindowMSW()
685 #if defined(__SMARTPHONE__) || defined(__POCKETPC__)
686 SHACTIVATEINFO
* info
= (SHACTIVATEINFO
*) m_activateInfo
;
688 m_activateInfo
= NULL
;
691 // after destroying an owned window, Windows activates the next top level
692 // window in Z order but it may be different from our owner (to reproduce
693 // this simply Alt-TAB to another application and back before closing the
694 // owned frame) whereas we always want to yield activation to our parent
695 if ( HasFlag(wxFRAME_FLOAT_ON_PARENT
) )
697 wxWindow
*parent
= GetParent();
700 ::BringWindowToTop(GetHwndOf(parent
));
705 // ----------------------------------------------------------------------------
706 // wxTopLevelWindowMSW showing
707 // ----------------------------------------------------------------------------
709 void wxTopLevelWindowMSW::DoShowWindow(int nShowCmd
)
711 ::ShowWindow(GetHwnd(), nShowCmd
);
713 // Hiding the window doesn't change its iconized state.
714 if ( nShowCmd
!= SW_HIDE
)
716 // Otherwise restoring, maximizing or showing the window normally also
717 // makes it not iconized and only minimizing it does make it iconized.
718 m_iconized
= nShowCmd
== SW_MINIMIZE
;
722 void wxTopLevelWindowMSW::ShowWithoutActivating()
724 if ( !wxWindowBase::Show(true) )
727 DoShowWindow(SW_SHOWNA
);
730 bool wxTopLevelWindowMSW::Show(bool show
)
732 // don't use wxWindow version as we want to call DoShowWindow() ourselves
733 if ( !wxWindowBase::Show(show
) )
739 if ( m_maximizeOnShow
)
742 nShowCmd
= SW_MAXIMIZE
;
744 // This is necessary, or no window appears
745 #if defined( __WINCE_STANDARDSDK__) || defined(__SMARTPHONE__)
746 DoShowWindow(SW_SHOW
);
749 m_maximizeOnShow
= false;
751 else if ( m_iconized
)
753 // We were iconized while we were hidden, so now we need to show
754 // the window in iconized state.
755 nShowCmd
= SW_MINIMIZE
;
757 else if ( ::IsIconic(GetHwnd()) )
759 // We were restored while we were hidden, so now we need to show
760 // the window in its normal state.
762 // As below, don't activate some kinds of windows.
763 if ( HasFlag(wxFRAME_TOOL_WINDOW
) || !IsEnabled() )
764 nShowCmd
= SW_SHOWNOACTIVATE
;
766 nShowCmd
= SW_RESTORE
;
770 // we shouldn't use SW_SHOW which also activates the window for
771 // tool frames (as they shouldn't steal focus from the main window)
772 // nor for the currently disabled windows as they would be enabled
774 if ( HasFlag(wxFRAME_TOOL_WINDOW
) || !IsEnabled() )
775 nShowCmd
= SW_SHOWNA
;
785 #if wxUSE_DEFERRED_SIZING
786 // we only set pending size if we're maximized before being shown, now that
787 // we're shown we don't need it any more (it is reset in size event handler
788 // for child windows but we have to do it ourselves for this parent window)
790 // make sure to reset it before actually showing the window as this will
791 // generate WM_SIZE events and we want to use the correct client size from
792 // them, not the size returned by WM_NCCALCSIZE in DoGetClientSize() which
793 // turns out to be wrong for maximized windows (see #11762)
794 m_pendingSize
= wxDefaultSize
;
795 #endif // wxUSE_DEFERRED_SIZING
797 DoShowWindow(nShowCmd
);
799 #if defined(__WXWINCE__) && (_WIN32_WCE >= 400 && !defined(__POCKETPC__) && !defined(__SMARTPHONE__))
800 // Addornments have to be added when the frame is the correct size
801 wxFrame
* frame
= wxDynamicCast(this, wxFrame
);
802 if (frame
&& frame
->GetMenuBar())
803 frame
->GetMenuBar()->AddAdornments(GetWindowStyleFlag());
809 void wxTopLevelWindowMSW::Raise()
811 ::SetForegroundWindow(GetHwnd());
814 // ----------------------------------------------------------------------------
815 // wxTopLevelWindowMSW maximize/minimize
816 // ----------------------------------------------------------------------------
818 void wxTopLevelWindowMSW::Maximize(bool maximize
)
822 // just maximize it directly
823 DoShowWindow(maximize
? SW_MAXIMIZE
: SW_RESTORE
);
827 // we can't maximize the hidden frame because it shows it as well,
828 // so just remember that we should do it later in this case
829 m_maximizeOnShow
= maximize
;
831 #if wxUSE_DEFERRED_SIZING
832 // after calling Maximize() the client code expects to get the frame
833 // "real" size and doesn't want to know that, because of implementation
834 // details, the frame isn't really maximized yet but will be only once
835 // it's shown, so return our size as it will be then in this case
838 // we must only change pending size here, and not call SetSize()
839 // because otherwise Windows would think that this (full screen)
840 // size is the natural size for the frame and so would use it when
841 // the user clicks on "restore" title bar button instead of the
842 // correct initial frame size
844 // NB: unfortunately we don't know which display we're on yet so we
845 // have to use the default one
846 m_pendingSize
= wxGetClientDisplayRect().GetSize();
848 //else: can't do anything in this case, we don't have the old size
849 #endif // wxUSE_DEFERRED_SIZING
853 bool wxTopLevelWindowMSW::IsMaximized() const
855 return IsAlwaysMaximized() ||
856 #if !defined(__SMARTPHONE__) && !defined(__POCKETPC__) && !defined(__WINCE_STANDARDSDK__)
858 (::IsZoomed(GetHwnd()) != 0) ||
863 void wxTopLevelWindowMSW::Iconize(bool iconize
)
865 if ( iconize
== m_iconized
)
867 // Do nothing, in particular don't restore non-iconized windows when
868 // Iconize(false) is called as this would wrongly un-maximize them.
874 // change the window state immediately
875 DoShowWindow(iconize
? SW_MINIMIZE
: SW_RESTORE
);
879 // iconizing the window shouldn't show it so just update the internal
880 // state (otherwise it's done by DoShowWindow() itself)
881 m_iconized
= iconize
;
885 bool wxTopLevelWindowMSW::IsIconized() const
893 // don't use m_iconized, it may be briefly out of sync with the real state
894 // as it's only modified when we receive a WM_SIZE and we could be called
895 // from an event handler from one of the messages we receive before it,
897 return ::IsIconic(GetHwnd()) != 0;
901 void wxTopLevelWindowMSW::Restore()
903 DoShowWindow(SW_RESTORE
);
906 void wxTopLevelWindowMSW::SetLayoutDirection(wxLayoutDirection dir
)
908 if ( dir
== wxLayout_Default
)
909 dir
= wxTheApp
->GetLayoutDirection();
911 if ( dir
!= wxLayout_Default
)
912 wxTopLevelWindowBase::SetLayoutDirection(dir
);
915 // ----------------------------------------------------------------------------
916 // wxTopLevelWindowMSW geometry
917 // ----------------------------------------------------------------------------
921 void wxTopLevelWindowMSW::DoGetPosition(int *x
, int *y
) const
926 wp
.length
= sizeof(WINDOWPLACEMENT
);
927 if ( ::GetWindowPlacement(GetHwnd(), &wp
) )
929 RECT
& rc
= wp
.rcNormalPosition
;
931 // the position returned by GetWindowPlacement() is in workspace
932 // coordinates except for windows with WS_EX_TOOLWINDOW style
933 if ( !HasFlag(wxFRAME_TOOL_WINDOW
) )
935 // we must use the correct display for the translation as the
936 // task bar might be shown on one display but not the other one
937 int n
= wxDisplay::GetFromWindow(this);
938 wxDisplay
dpy(n
== wxNOT_FOUND
? 0 : n
);
939 const wxPoint ptOfs
= dpy
.GetClientArea().GetPosition() -
940 dpy
.GetGeometry().GetPosition();
954 wxLogLastError(wxT("GetWindowPlacement"));
958 wxTopLevelWindowBase::DoGetPosition(x
, y
);
961 void wxTopLevelWindowMSW::DoGetSize(int *width
, int *height
) const
966 wp
.length
= sizeof(WINDOWPLACEMENT
);
967 if ( ::GetWindowPlacement(GetHwnd(), &wp
) )
969 const RECT
& rc
= wp
.rcNormalPosition
;
972 *width
= rc
.right
- rc
.left
;
974 *height
= rc
.bottom
- rc
.top
;
979 wxLogLastError(wxT("GetWindowPlacement"));
983 wxTopLevelWindowBase::DoGetSize(width
, height
);
986 #endif // __WXWINCE__
989 wxTopLevelWindowMSW::MSWGetCreateWindowCoords(const wxPoint
& pos
,
992 int& w
, int& h
) const
994 // let the system position the window if no explicit position was specified
995 if ( pos
.x
== wxDefaultCoord
)
997 // if x is set to CW_USEDEFAULT, y parameter is ignored anyhow so we
998 // can just as well set it to CW_USEDEFAULT as well
1004 // OTOH, if x is not set to CW_USEDEFAULT, y shouldn't be set to it
1005 // neither because it is not handled as a special value by Windows then
1006 // and so we have to choose some default value for it, even if a
1007 // completely arbitrary one
1008 static const int DEFAULT_Y
= 200;
1011 y
= pos
.y
== wxDefaultCoord
? DEFAULT_Y
: pos
.y
;
1014 if ( size
.x
== wxDefaultCoord
|| size
.y
== wxDefaultCoord
)
1016 // We don't use CW_USEDEFAULT here for several reasons:
1018 // 1. It results in huge frames on modern screens (1000*800 is not
1019 // uncommon on my 1280*1024 screen) which is way too big for a half
1020 // empty frame of most of wxWidgets samples for example)
1022 // 2. It is buggy for frames with wxFRAME_TOOL_WINDOW style for which
1023 // the default is for whatever reason 8*8 which breaks client <->
1024 // window size calculations (it would be nice if it didn't, but it
1025 // does and the simplest way to fix it seemed to change the broken
1026 // default size anyhow)
1028 // 3. There is just no advantage in doing it: with x and y it is
1029 // possible that [future versions of] Windows position the new top
1030 // level window in some smart way which we can't do, but we can
1031 // guess a reasonably good size for a new window just as well
1034 // The only exception is for the Windows CE platform where the system
1035 // does know better than we how should the windows be sized
1039 #else // !_WIN32_WCE
1040 wxSize sizeReal
= size
;
1041 sizeReal
.SetDefaults(GetDefaultSize());
1045 #endif // _WIN32_WCE/!_WIN32_WCE
1054 // ----------------------------------------------------------------------------
1055 // wxTopLevelWindowMSW fullscreen
1056 // ----------------------------------------------------------------------------
1058 bool wxTopLevelWindowMSW::ShowFullScreen(bool show
, long style
)
1060 if ( show
== IsFullScreen() )
1066 m_fsIsShowing
= show
;
1072 // zap the frame borders
1074 // save the 'normal' window style
1075 m_fsOldWindowStyle
= GetWindowLong(GetHwnd(), GWL_STYLE
);
1077 // save the old position, width & height, maximize state
1078 m_fsOldSize
= GetRect();
1079 m_fsIsMaximized
= IsMaximized();
1081 // decide which window style flags to turn off
1082 LONG newStyle
= m_fsOldWindowStyle
;
1085 if (style
& wxFULLSCREEN_NOBORDER
)
1087 offFlags
|= WS_BORDER
;
1089 offFlags
|= WS_THICKFRAME
;
1092 if (style
& wxFULLSCREEN_NOCAPTION
)
1093 offFlags
|= WS_CAPTION
| WS_SYSMENU
;
1095 newStyle
&= ~offFlags
;
1097 // change our window style to be compatible with full-screen mode
1098 ::SetWindowLong(GetHwnd(), GWL_STYLE
, newStyle
);
1102 // resize to the size of the display containing us
1103 int dpy
= wxDisplay::GetFromWindow(this);
1104 if ( dpy
!= wxNOT_FOUND
)
1106 rect
= wxDisplay(dpy
).GetGeometry();
1108 else // fall back to the main desktop
1109 #endif // wxUSE_DISPLAY
1111 // resize to the size of the desktop
1112 wxCopyRECTToRect(wxGetWindowRect(::GetDesktopWindow()), rect
);
1114 // FIXME: size of the bottom menu (toolbar)
1115 // should be taken in account
1116 rect
.height
+= rect
.y
;
1123 // now flush the window style cache and actually go full-screen
1124 long flags
= SWP_FRAMECHANGED
;
1126 // showing the frame full screen should also show it if it's still
1130 // don't call wxWindow version to avoid flicker from calling
1131 // ::ShowWindow() -- we're going to show the window at the correct
1132 // location directly below -- but do call the wxWindowBase version
1133 // to sync the internal m_isShown flag
1134 wxWindowBase::Show();
1136 flags
|= SWP_SHOWWINDOW
;
1139 SetWindowPos(GetHwnd(), HWND_TOP
,
1140 rect
.x
, rect
.y
, rect
.width
, rect
.height
,
1143 #if !defined(__HANDHELDPC__) && (defined(__WXWINCE__) && (_WIN32_WCE < 400))
1144 ::SHFullScreen(GetHwnd(), SHFS_HIDETASKBAR
| SHFS_HIDESIPBUTTON
);
1147 // finally send an event allowing the window to relayout itself &c
1148 wxSizeEvent
event(rect
.GetSize(), GetId());
1149 event
.SetEventObject(this);
1150 HandleWindowEvent(event
);
1152 else // stop showing full screen
1154 #if !defined(__HANDHELDPC__) && (defined(__WXWINCE__) && (_WIN32_WCE < 400))
1155 ::SHFullScreen(GetHwnd(), SHFS_SHOWTASKBAR
| SHFS_SHOWSIPBUTTON
);
1157 Maximize(m_fsIsMaximized
);
1158 SetWindowLong(GetHwnd(),GWL_STYLE
, m_fsOldWindowStyle
);
1159 SetWindowPos(GetHwnd(),HWND_TOP
,m_fsOldSize
.x
, m_fsOldSize
.y
,
1160 m_fsOldSize
.width
, m_fsOldSize
.height
, SWP_FRAMECHANGED
);
1166 // ----------------------------------------------------------------------------
1167 // wxTopLevelWindowMSW misc
1168 // ----------------------------------------------------------------------------
1170 void wxTopLevelWindowMSW::SetTitle( const wxString
& title
)
1175 wxString
wxTopLevelWindowMSW::GetTitle() const
1180 bool wxTopLevelWindowMSW::DoSelectAndSetIcon(const wxIconBundle
& icons
,
1185 const wxSize
size(::GetSystemMetrics(smX
), ::GetSystemMetrics(smY
));
1187 wxIcon icon
= icons
.GetIcon(size
, wxIconBundle::FALLBACK_NEAREST_LARGER
);
1192 ::SendMessage(GetHwnd(), WM_SETICON
, i
, (LPARAM
)GetHiconOf(icon
));
1196 void wxTopLevelWindowMSW::SetIcons(const wxIconBundle
& icons
)
1198 wxTopLevelWindowBase::SetIcons(icons
);
1200 if ( icons
.IsEmpty() )
1202 // FIXME: SetIcons(wxNullIconBundle) should unset existing icons,
1203 // but we currently don't do that
1204 wxASSERT_MSG( m_icons
.IsEmpty(), "unsetting icons doesn't work" );
1208 DoSelectAndSetIcon(icons
, SM_CXSMICON
, SM_CYSMICON
, ICON_SMALL
);
1209 DoSelectAndSetIcon(icons
, SM_CXICON
, SM_CYICON
, ICON_BIG
);
1212 bool wxTopLevelWindowMSW::EnableCloseButton(bool enable
)
1214 #if !defined(__WXMICROWIN__)
1215 // get system (a.k.a. window) menu
1216 HMENU hmenu
= GetSystemMenu(GetHwnd(), FALSE
/* get it */);
1219 // no system menu at all -- ok if we want to remove the close button
1220 // anyhow, but bad if we want to show it
1224 // enabling/disabling the close item from it also automatically
1225 // disables/enables the close title bar button
1226 if ( ::EnableMenuItem(hmenu
, SC_CLOSE
,
1228 (enable
? MF_ENABLED
: MF_GRAYED
)) == -1 )
1230 wxLogLastError(wxT("EnableMenuItem(SC_CLOSE)"));
1235 // update appearance immediately
1236 if ( !::DrawMenuBar(GetHwnd()) )
1238 wxLogLastError(wxT("DrawMenuBar"));
1241 #endif // !__WXMICROWIN__
1246 void wxTopLevelWindowMSW::RequestUserAttention(int flags
)
1248 // check if we can use FlashWindowEx(): unfortunately a simple test for
1249 // FLASHW_STOP doesn't work because MSVC6 headers do #define it but don't
1250 // provide FlashWindowEx() declaration, so try to detect whether we have
1251 // real headers for WINVER 0x0500 by checking for existence of a symbol not
1252 // declated in MSVC6 header
1253 #if defined(FLASHW_STOP) && defined(VK_XBUTTON1) && wxUSE_DYNLIB_CLASS
1254 // available in the headers, check if it is supported by the system
1255 typedef BOOL (WINAPI
*FlashWindowEx_t
)(FLASHWINFO
*pfwi
);
1256 static FlashWindowEx_t s_pfnFlashWindowEx
= NULL
;
1257 if ( !s_pfnFlashWindowEx
)
1259 wxDynamicLibrary
dllUser32(wxT("user32.dll"));
1260 s_pfnFlashWindowEx
= (FlashWindowEx_t
)
1261 dllUser32
.GetSymbol(wxT("FlashWindowEx"));
1263 // we can safely unload user32.dll here, it's going to remain loaded as
1264 // long as the program is running anyhow
1267 if ( s_pfnFlashWindowEx
)
1269 WinStruct
<FLASHWINFO
> fwi
;
1270 fwi
.hwnd
= GetHwnd();
1271 fwi
.dwFlags
= FLASHW_ALL
;
1272 if ( flags
& wxUSER_ATTENTION_INFO
)
1274 // just flash a few times
1277 else // wxUSER_ATTENTION_ERROR
1279 // flash until the user notices it
1280 fwi
.dwFlags
|= FLASHW_TIMERNOFG
;
1283 s_pfnFlashWindowEx(&fwi
);
1285 else // FlashWindowEx() not available
1286 #endif // FlashWindowEx() defined
1290 ::FlashWindow(GetHwnd(), TRUE
);
1291 #endif // __WXWINCE__
1295 wxMenu
*wxTopLevelWindowMSW::MSWGetSystemMenu() const
1297 #ifndef __WXUNIVERSAL__
1298 if ( !m_menuSystem
)
1300 HMENU hmenu
= ::GetSystemMenu(GetHwnd(), FALSE
);
1303 wxLogLastError(wxT("GetSystemMenu()"));
1307 wxTopLevelWindowMSW
* const
1308 self
= const_cast<wxTopLevelWindowMSW
*>(this);
1310 self
->m_menuSystem
= wxMenu::MSWNewFromHMENU(hmenu
);
1312 // We need to somehow associate this menu with this window to ensure
1313 // that we get events from it. A natural idea would be to pretend that
1314 // it's attached to our menu bar but this wouldn't work if we don't
1315 // have any menu bar which is a common case for applications using
1316 // custom items in the system menu (they mostly do it exactly because
1317 // they don't have any other menus).
1319 // So reuse the invoking window pointer instead, this is not exactly
1320 // correct but doesn't seem to have any serious drawbacks.
1321 m_menuSystem
->SetInvokingWindow(self
);
1323 #endif // #ifndef __WXUNIVERSAL__
1325 return m_menuSystem
;
1328 // ----------------------------------------------------------------------------
1329 // Transparency support
1330 // ---------------------------------------------------------------------------
1332 bool wxTopLevelWindowMSW::SetTransparent(wxByte alpha
)
1334 #if wxUSE_DYNLIB_CLASS
1335 typedef DWORD (WINAPI
*PSETLAYEREDWINDOWATTR
)(HWND
, DWORD
, BYTE
, DWORD
);
1336 static PSETLAYEREDWINDOWATTR
1337 pSetLayeredWindowAttributes
= (PSETLAYEREDWINDOWATTR
)-1;
1339 if ( pSetLayeredWindowAttributes
== (PSETLAYEREDWINDOWATTR
)-1 )
1341 wxDynamicLibrary
dllUser32(wxT("user32.dll"));
1343 // use RawGetSymbol() and not GetSymbol() to avoid error messages under
1344 // Windows 95: there is nothing the user can do about this anyhow
1345 pSetLayeredWindowAttributes
= (PSETLAYEREDWINDOWATTR
)
1346 dllUser32
.RawGetSymbol(wxT("SetLayeredWindowAttributes"));
1348 // it's ok to destroy dllUser32 here, we link statically to user32.dll
1349 // anyhow so it won't be unloaded
1352 if ( !pSetLayeredWindowAttributes
)
1354 #endif // wxUSE_DYNLIB_CLASS
1356 LONG exstyle
= GetWindowLong(GetHwnd(), GWL_EXSTYLE
);
1358 // if setting alpha to fully opaque then turn off the layered style
1361 SetWindowLong(GetHwnd(), GWL_EXSTYLE
, exstyle
& ~WS_EX_LAYERED
);
1366 #if wxUSE_DYNLIB_CLASS
1367 // Otherwise, set the layered style if needed and set the alpha value
1368 if ((exstyle
& WS_EX_LAYERED
) == 0 )
1369 SetWindowLong(GetHwnd(), GWL_EXSTYLE
, exstyle
| WS_EX_LAYERED
);
1371 if ( pSetLayeredWindowAttributes(GetHwnd(), 0, (BYTE
)alpha
, LWA_ALPHA
) )
1373 #endif // wxUSE_DYNLIB_CLASS
1378 bool wxTopLevelWindowMSW::CanSetTransparent()
1380 // The API is available on win2k and above
1382 static int os_type
= -1;
1383 static int ver_major
= -1;
1386 os_type
= ::wxGetOsVersion(&ver_major
);
1388 return (os_type
== wxOS_WINDOWS_NT
&& ver_major
>= 5);
1391 void wxTopLevelWindowMSW::DoFreeze()
1393 // do nothing: freezing toplevel window causes paint and mouse events
1394 // to go through it any TLWs under it, so the best we can do is to freeze
1395 // all children -- and wxWindowBase::Freeze() does that
1398 void wxTopLevelWindowMSW::DoThaw()
1400 // intentionally empty -- see DoFreeze()
1404 // ----------------------------------------------------------------------------
1405 // wxTopLevelWindow event handling
1406 // ----------------------------------------------------------------------------
1408 void wxTopLevelWindowMSW::DoSaveLastFocus()
1413 // remember the last focused child if it is our child
1414 m_winLastFocused
= FindFocus();
1416 if ( m_winLastFocused
)
1418 // and don't remember it if it's a child from some other frame
1419 if ( wxGetTopLevelParent(m_winLastFocused
) != this )
1421 m_winLastFocused
= NULL
;
1426 void wxTopLevelWindowMSW::DoRestoreLastFocus()
1428 wxWindow
*parent
= m_winLastFocused
? m_winLastFocused
->GetParent()
1435 wxSetFocusToChild(parent
, &m_winLastFocused
);
1438 void wxTopLevelWindowMSW::OnActivate(wxActivateEvent
& event
)
1440 if ( event
.GetActive() )
1442 // We get WM_ACTIVATE before being restored from iconized state, so we
1443 // can be still iconized here. In this case, avoid restoring the focus
1444 // as it doesn't work anyhow and we will do when we're really restored.
1451 // restore focus to the child which was last focused unless we already
1453 wxLogTrace(wxT("focus"), wxT("wxTLW %p activated."), m_hWnd
);
1455 wxWindow
*winFocus
= FindFocus();
1456 if ( !winFocus
|| wxGetTopLevelParent(winFocus
) != this )
1457 DoRestoreLastFocus();
1459 else // deactivating
1463 wxLogTrace(wxT("focus"),
1464 wxT("wxTLW %p deactivated, last focused: %p."),
1466 m_winLastFocused
? GetHwndOf(m_winLastFocused
) : NULL
);
1475 wxTopLevelWindowMSW::HandleMenuSelect(WXWORD nItem
, WXWORD flags
, WXHMENU
WXUNUSED(hMenu
))
1477 // sign extend to int from unsigned short we get from Windows
1478 int item
= (signed short)nItem
;
1480 // WM_MENUSELECT is generated for both normal items and menus, including
1481 // the top level menus of the menu bar, which can't be represented using
1482 // any valid identifier in wxMenuEvent so use an otherwise unused value for
1484 if ( flags
& (MF_POPUP
| MF_SEPARATOR
) )
1487 wxMenuEvent
event(wxEVT_MENU_HIGHLIGHT
, item
);
1488 event
.SetEventObject(this);
1490 if ( HandleWindowEvent(event
) )
1493 // by default, i.e. if the event wasn't handled above, clear the status bar
1494 // text when an item which can't have any associated help string in wx API
1496 if ( item
== wxID_NONE
)
1497 DoGiveHelp(wxEmptyString
, true);
1503 wxTopLevelWindowMSW::DoSendMenuOpenCloseEvent(wxEventType evtType
, wxMenu
* menu
, bool popup
)
1505 wxMenuEvent
event(evtType
, popup
? wxID_ANY
: 0, menu
);
1506 event
.SetEventObject(menu
);
1508 return HandleWindowEvent(event
);
1511 bool wxTopLevelWindowMSW::HandleExitMenuLoop(WXWORD isPopup
)
1513 return DoSendMenuOpenCloseEvent(wxEVT_MENU_CLOSE
,
1514 isPopup
? wxCurrentPopupMenu
: NULL
,
1518 bool wxTopLevelWindowMSW::HandleMenuPopup(wxEventType evtType
, WXHMENU hMenu
)
1520 bool isPopup
= false;
1521 wxMenu
* menu
= NULL
;
1522 if ( wxCurrentPopupMenu
&& wxCurrentPopupMenu
->GetHMenu() == hMenu
)
1524 menu
= wxCurrentPopupMenu
;
1529 menu
= MSWFindMenuFromHMENU(hMenu
);
1533 return DoSendMenuOpenCloseEvent(evtType
, menu
, isPopup
);
1536 wxMenu
* wxTopLevelWindowMSW::MSWFindMenuFromHMENU(WXHMENU
WXUNUSED(hMenu
))
1538 // We don't have any menus at this level.
1542 #endif // wxUSE_MENUS
1546 // the DialogProc for all wxWidgets dialogs
1547 LONG APIENTRY _EXPORT
1548 wxDlgProc(HWND hDlg
,
1550 WPARAM
WXUNUSED(wParam
),
1551 LPARAM
WXUNUSED(lParam
))
1557 // under CE, add a "Ok" button in the dialog title bar and make it full
1560 // TODO: find the window for this HWND, and take into account
1561 // wxMAXIMIZE and wxCLOSE_BOX. For now, assume both are present.
1563 // Standard SDK doesn't have aygshell.dll: see
1564 // include/wx/msw/wince/libraries.h
1565 #if defined(__WXWINCE__) && !defined(__WINCE_STANDARDSDK__) && !defined(__HANDHELDPC__)
1566 SHINITDLGINFO shidi
;
1567 shidi
.dwMask
= SHIDIM_FLAGS
;
1568 shidi
.dwFlags
= SHIDIF_SIZEDLG
// take account of the SIP or menubar
1569 #ifndef __SMARTPHONE__
1574 SHInitDialog( &shidi
);
1575 #else // no SHInitDialog()
1578 // for WM_INITDIALOG, returning TRUE tells system to set focus to
1579 // the first control in the dialog box, but as we set the focus
1580 // ourselves, we return FALSE for it as well
1585 // for almost all messages, returning FALSE means that we didn't process
1590 // ============================================================================
1591 // wxTLWHiddenParentModule implementation
1592 // ============================================================================
1594 HWND
wxTLWHiddenParentModule::ms_hwnd
= NULL
;
1596 const wxChar
*wxTLWHiddenParentModule::ms_className
= NULL
;
1598 bool wxTLWHiddenParentModule::OnInit()
1601 ms_className
= NULL
;
1606 void wxTLWHiddenParentModule::OnExit()
1610 if ( !::DestroyWindow(ms_hwnd
) )
1612 wxLogLastError(wxT("DestroyWindow(hidden TLW parent)"));
1620 if ( !::UnregisterClass(ms_className
, wxGetInstance()) )
1622 wxLogLastError(wxT("UnregisterClass(\"wxTLWHiddenParent\")"));
1625 ms_className
= NULL
;
1630 HWND
wxTLWHiddenParentModule::GetHWND()
1634 if ( !ms_className
)
1636 static const wxChar
*HIDDEN_PARENT_CLASS
= wxT("wxTLWHiddenParent");
1639 wxZeroMemory(wndclass
);
1641 wndclass
.lpfnWndProc
= DefWindowProc
;
1642 wndclass
.hInstance
= wxGetInstance();
1643 wndclass
.lpszClassName
= HIDDEN_PARENT_CLASS
;
1645 if ( !::RegisterClass(&wndclass
) )
1647 wxLogLastError(wxT("RegisterClass(\"wxTLWHiddenParent\")"));
1651 ms_className
= HIDDEN_PARENT_CLASS
;
1655 ms_hwnd
= ::CreateWindow(ms_className
, wxEmptyString
, 0, 0, 0, 0, 0, NULL
,
1656 (HMENU
)NULL
, wxGetInstance(), NULL
);
1659 wxLogLastError(wxT("CreateWindow(hidden TLW parent)"));