1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: msw/toplevel.cpp
3 // Purpose: implements wxTopLevelWindow for MSW
4 // Author: Vadim Zeitlin
8 // Copyright: (c) 2001 SciTech Software, Inc. (www.scitechsoft.com)
9 // License: wxWindows licence
10 ///////////////////////////////////////////////////////////////////////////////
12 // ============================================================================
14 // ============================================================================
16 // ----------------------------------------------------------------------------
18 // ----------------------------------------------------------------------------
21 #pragma implementation "toplevel.h"
24 // For compilers that support precompilation, includes "wx.h".
25 #include "wx/wxprec.h"
33 #include "wx/toplevel.h"
34 #include "wx/string.h"
38 #include "wx/containr.h" // wxSetFocusToChild()
41 #include "wx/module.h"
43 #include "wx/msw/private.h"
44 #include "wx/msw/winundef.h"
50 #include "wx/display.h"
60 // ----------------------------------------------------------------------------
61 // stubs for missing functions under MicroWindows
62 // ----------------------------------------------------------------------------
66 // static inline bool IsIconic(HWND WXUNUSED(hwnd)) { return FALSE; }
67 static inline bool IsZoomed(HWND
WXUNUSED(hwnd
)) { return FALSE
; }
69 #endif // __WXMICROWIN__
71 // NB: wxDlgProc must be defined here and not in dialog.cpp because the latter
72 // is not included by wxUniv build which does need wxDlgProc
74 wxDlgProc(HWND hDlg
, UINT message
, WPARAM wParam
, LPARAM lParam
);
76 // ----------------------------------------------------------------------------
78 // ----------------------------------------------------------------------------
80 // list of all frames and modeless dialogs
81 wxWindowList wxModelessWindows
;
83 // the name of the default wxWindows class
84 extern const wxChar
*wxCanvasClassName
;
86 // ----------------------------------------------------------------------------
87 // wxTLWHiddenParentModule: used to manage the hidden parent window (we need a
88 // module to ensure that the window is always deleted)
89 // ----------------------------------------------------------------------------
91 class wxTLWHiddenParentModule
: public wxModule
94 // module init/finalize
95 virtual bool OnInit();
96 virtual void OnExit();
98 // get the hidden window (creates on demand)
99 static HWND
GetHWND();
102 // the HWND of the hidden parent
105 // the class used to create it
106 static const wxChar
*ms_className
;
108 DECLARE_DYNAMIC_CLASS(wxTLWHiddenParentModule
)
111 IMPLEMENT_DYNAMIC_CLASS(wxTLWHiddenParentModule
, wxModule
)
113 // ============================================================================
114 // wxTopLevelWindowMSW implementation
115 // ============================================================================
117 BEGIN_EVENT_TABLE(wxTopLevelWindowMSW
, wxTopLevelWindowBase
)
118 EVT_ACTIVATE(wxTopLevelWindowMSW::OnActivate
)
121 // ----------------------------------------------------------------------------
122 // wxTopLevelWindowMSW creation
123 // ----------------------------------------------------------------------------
125 void wxTopLevelWindowMSW::Init()
128 m_maximizeOnShow
= FALSE
;
130 // unlike (almost?) all other windows, frames are created hidden
133 // Data to save/restore when calling ShowFullScreen
135 m_fsOldWindowStyle
= 0;
136 m_fsIsMaximized
= FALSE
;
137 m_fsIsShowing
= FALSE
;
139 m_winLastFocused
= (wxWindow
*)NULL
;
142 WXDWORD
wxTopLevelWindowMSW::MSWGetStyle(long style
, WXDWORD
*exflags
) const
144 // let the base class deal with the common styles but fix the ones which
145 // don't make sense for us (we also deal with the borders ourselves)
146 WXDWORD msflags
= wxWindow::MSWGetStyle
148 (style
& ~wxBORDER_MASK
) | wxBORDER_NONE
, exflags
149 ) & ~WS_CHILD
& ~WS_VISIBLE
;
151 // first select the kind of window being created
153 // note that if we don't set WS_POPUP, Windows assumes WS_OVERLAPPED and
154 // creates a window with both caption and border, hence we also test it
155 // below in some other cases
156 if ( style
& wxFRAME_TOOL_WINDOW
)
161 if (msflags
& WS_BORDER
)
163 msflags
|= WS_OVERLAPPED
;
166 // border and caption styles
167 if ( style
& wxRESIZE_BORDER
)
170 msflags
|= WS_THICKFRAME
;
173 else if ( !(style
& wxBORDER_NONE
) )
174 msflags
|= WS_BORDER
;
180 if ( style
& wxCAPTION
)
181 msflags
|= WS_CAPTION
;
187 // next translate the individual flags
188 if ( style
& wxMINIMIZE_BOX
)
189 msflags
|= WS_MINIMIZEBOX
;
190 if ( style
& wxMAXIMIZE_BOX
)
191 msflags
|= WS_MAXIMIZEBOX
;
192 if ( style
& wxSYSTEM_MENU
)
193 msflags
|= WS_SYSMENU
;
195 if ( style
& wxMINIMIZE
)
196 msflags
|= WS_MINIMIZE
;
197 if ( style
& wxMAXIMIZE
)
198 msflags
|= WS_MAXIMIZE
;
201 // Keep this here because it saves recoding this function in wxTinyFrame
202 #if wxUSE_ITSY_BITSY && !defined(__WIN32__)
203 if ( style
& wxTINY_CAPTION_VERT
)
204 msflags
|= IBS_VERTCAPTION
;
205 if ( style
& wxTINY_CAPTION_HORIZ
)
206 msflags
|= IBS_HORZCAPTION
;
208 if ( style
& (wxTINY_CAPTION_VERT
| wxTINY_CAPTION_HORIZ
) )
209 msflags
|= WS_CAPTION
;
214 #if !defined(__WIN16__)
215 if ( !(GetExtraStyle() & wxTOPLEVEL_EX_DIALOG
) )
217 if ( style
& wxFRAME_TOOL_WINDOW
)
219 // create the palette-like window
220 *exflags
|= WS_EX_TOOLWINDOW
;
223 // We have to solve 2 different problems here:
225 // 1. frames with wxFRAME_NO_TASKBAR flag shouldn't appear in the
226 // taskbar even if they don't have a parent
228 // 2. frames without this style should appear in the taskbar even
229 // if they're owned (Windows only puts non owned windows into
230 // the taskbar normally)
232 // The second one is solved here by using WS_EX_APPWINDOW flag, the
233 // first one is dealt with in our MSWGetParent() method
236 if ( !(style
& wxFRAME_NO_TASKBAR
) && GetParent() )
238 // need to force the frame to appear in the taskbar
239 *exflags
|= WS_EX_APPWINDOW
;
242 //else: nothing to do [here]
246 if ( style
& wxSTAY_ON_TOP
)
247 *exflags
|= WS_EX_TOPMOST
;
250 if ( GetExtraStyle() & wxFRAME_EX_CONTEXTHELP
)
251 *exflags
|= WS_EX_CONTEXTHELP
;
258 WXHWND
wxTopLevelWindowMSW::MSWGetParent() const
260 // for the frames without wxFRAME_FLOAT_ON_PARENT style we should use NULL
261 // parent HWND or it would be always on top of its parent which is not what
262 // we usually want (in fact, we only want it for frames with the
263 // wxFRAME_FLOAT_ON_PARENT flag)
264 HWND hwndParent
= NULL
;
265 if ( HasFlag(wxFRAME_FLOAT_ON_PARENT
) )
267 const wxWindow
*parent
= GetParent();
271 // this flag doesn't make sense then and will be ignored
272 wxFAIL_MSG( _T("wxFRAME_FLOAT_ON_PARENT but no parent?") );
276 hwndParent
= GetHwndOf(parent
);
279 //else: don't float on parent, must not be owned
281 // now deal with the 2nd taskbar-related problem (see comments above in
283 if ( HasFlag(wxFRAME_NO_TASKBAR
) && !hwndParent
)
286 hwndParent
= wxTLWHiddenParentModule::GetHWND();
289 return (WXHWND
)hwndParent
;
292 bool wxTopLevelWindowMSW::CreateDialog(const void *dlgTemplate
,
293 const wxString
& title
,
297 #ifdef __WXMICROWIN__
298 // no dialogs support under MicroWin yet
299 return CreateFrame(title
, pos
, size
);
300 #else // !__WXMICROWIN__
301 wxWindow
*parent
= GetParent();
303 // for the dialogs without wxDIALOG_NO_PARENT style, use the top level
304 // app window as parent - this avoids creating modal dialogs without
306 if ( !parent
&& !(GetWindowStyleFlag() & wxDIALOG_NO_PARENT
) )
308 parent
= wxTheApp
->GetTopWindow();
312 // don't use transient windows as parents, this is dangerous as it
313 // can lead to a crash if the parent is destroyed before the child
315 // also don't use the window which is currently hidden as then the
316 // dialog would be hidden as well
317 if ( (parent
->GetExtraStyle() & wxWS_EX_TRANSIENT
) ||
325 m_hWnd
= (WXHWND
)::CreateDialogIndirect
328 (DLGTEMPLATE
*)dlgTemplate
,
329 parent
? GetHwndOf(parent
) : NULL
,
335 wxFAIL_MSG(wxT("Failed to create dialog. Incorrect DLGTEMPLATE?"));
337 wxLogSysError(wxT("Can't create dialog using memory template"));
343 (void)MSWGetCreateWindowFlags(&exflags
);
347 ::SetWindowLong(GetHwnd(), GWL_EXSTYLE
, exflags
);
348 ::SetWindowPos(GetHwnd(), NULL
, 0, 0, 0, 0,
355 #if defined(__WIN95__)
356 // For some reason, the system menu is activated when we use the
357 // WS_EX_CONTEXTHELP style, so let's set a reasonable icon
358 if ( exflags
& WS_EX_CONTEXTHELP
)
360 wxFrame
*winTop
= wxDynamicCast(wxTheApp
->GetTopWindow(), wxFrame
);
363 wxIcon icon
= winTop
->GetIcon();
366 ::SendMessage(GetHwnd(), WM_SETICON
,
368 (LPARAM
)GetHiconOf(icon
));
374 // move the dialog to its initial position without forcing repainting
376 if ( !MSWGetCreateWindowCoords(pos
, size
, x
, y
, w
, h
) )
379 w
= (int)CW_USEDEFAULT
;
382 // we can't use CW_USEDEFAULT here as we're not calling CreateWindow()
383 // and passing CW_USEDEFAULT to MoveWindow() results in resizing the
384 // window to (0, 0) size which breaks quite a lot of things, e.g. the
385 // sizer calculation in wxSizer::Fit()
386 if ( w
== (int)CW_USEDEFAULT
)
388 // the exact number doesn't matter, the dialog will be resized
389 // again soon anyhow but it should be big enough to allow
390 // calculation relying on "totalSize - clientSize > 0" work, i.e.
391 // at least greater than the title bar height
396 if ( x
== (int)CW_USEDEFAULT
)
398 // centre it on the screen - what else can we do?
399 wxSize sizeDpy
= wxGetDisplaySize();
401 x
= (sizeDpy
.x
- w
) / 2;
402 y
= (sizeDpy
.y
- h
) / 2;
405 if ( !::MoveWindow(GetHwnd(), x
, y
, w
, h
, FALSE
) )
407 wxLogLastError(wxT("MoveWindow"));
410 if ( !title
.empty() )
412 ::SetWindowText(GetHwnd(), title
);
418 #endif // __WXMICROWIN__/!__WXMICROWIN__
421 bool wxTopLevelWindowMSW::CreateFrame(const wxString
& title
,
426 WXDWORD flags
= MSWGetCreateWindowFlags(&exflags
);
428 return MSWCreate(wxCanvasClassName
, title
, pos
, size
, flags
, exflags
);
431 bool wxTopLevelWindowMSW::Create(wxWindow
*parent
,
433 const wxString
& title
,
437 const wxString
& name
)
444 m_windowStyle
= style
;
448 m_windowId
= id
== -1 ? NewControlId() : id
;
450 wxTopLevelWindows
.Append(this);
453 parent
->AddChild(this);
455 if ( GetExtraStyle() & wxTOPLEVEL_EX_DIALOG
)
457 // we have different dialog templates to allows creation of dialogs
458 // with & without captions under MSWindows, resizeable or not (but a
459 // resizeable dialog always has caption - otherwise it would look too
462 // we need 3 additional WORDs for dialog menu, class and title (as we
463 // don't use DS_SETFONT we don't need the fourth WORD for the font)
464 static const int dlgsize
= sizeof(DLGTEMPLATE
) + (sizeof(WORD
) * 3);
465 DLGTEMPLATE
*dlgTemplate
= (DLGTEMPLATE
*)malloc(dlgsize
);
466 memset(dlgTemplate
, 0, dlgsize
);
468 // these values are arbitrary, they won't be used normally anyhow
471 dlgTemplate
->cx
= 144;
472 dlgTemplate
->cy
= 75;
474 // reuse the code in MSWGetStyle() but correct the results slightly for
476 dlgTemplate
->style
= MSWGetStyle(style
, NULL
);
478 // all dialogs are popups
479 dlgTemplate
->style
|= WS_POPUP
;
481 // force 3D-look if necessary, it looks impossibly ugly otherwise
482 if ( style
& (wxRESIZE_BORDER
| wxCAPTION
) )
483 dlgTemplate
->style
|= DS_MODALFRAME
;
485 ret
= CreateDialog(dlgTemplate
, title
, pos
, size
);
490 ret
= CreateFrame(title
, pos
, size
);
493 if ( ret
&& !(GetWindowStyleFlag() & wxCLOSE_BOX
) )
495 EnableCloseButton(false);
501 wxTopLevelWindowMSW::~wxTopLevelWindowMSW()
503 if ( wxModelessWindows
.Find(this) )
504 wxModelessWindows
.DeleteObject(this);
506 // after destroying an owned window, Windows activates the next top level
507 // window in Z order but it may be different from our owner (to reproduce
508 // this simply Alt-TAB to another application and back before closing the
509 // owned frame) whereas we always want to yield activation to our parent
510 if ( HasFlag(wxFRAME_FLOAT_ON_PARENT
) )
512 wxWindow
*parent
= GetParent();
515 ::BringWindowToTop(GetHwndOf(parent
));
520 // ----------------------------------------------------------------------------
521 // wxTopLevelWindowMSW showing
522 // ----------------------------------------------------------------------------
524 void wxTopLevelWindowMSW::DoShowWindow(int nShowCmd
)
526 ::ShowWindow(GetHwnd(), nShowCmd
);
528 m_iconized
= nShowCmd
== SW_MINIMIZE
;
531 bool wxTopLevelWindowMSW::Show(bool show
)
533 // don't use wxWindow version as we want to call DoShowWindow() ourselves
534 if ( !wxWindowBase::Show(show
) )
540 if ( m_maximizeOnShow
)
543 nShowCmd
= SW_MAXIMIZE
;
545 m_maximizeOnShow
= FALSE
;
549 if ( GetWindowStyle() & wxFRAME_TOOL_WINDOW
)
550 nShowCmd
= SW_SHOWNA
;
560 DoShowWindow(nShowCmd
);
564 ::BringWindowToTop(GetHwnd());
566 wxActivateEvent
event(wxEVT_ACTIVATE
, TRUE
, m_windowId
);
567 event
.SetEventObject( this );
568 GetEventHandler()->ProcessEvent(event
);
572 // Try to highlight the correct window (the parent)
575 HWND hWndParent
= GetHwndOf(GetParent());
577 ::BringWindowToTop(hWndParent
);
584 // ----------------------------------------------------------------------------
585 // wxTopLevelWindowMSW maximize/minimize
586 // ----------------------------------------------------------------------------
588 void wxTopLevelWindowMSW::Maximize(bool maximize
)
592 // just maximize it directly
593 DoShowWindow(maximize
? SW_MAXIMIZE
: SW_RESTORE
);
597 // we can't maximize the hidden frame because it shows it as well, so
598 // just remember that we should do it later in this case
599 m_maximizeOnShow
= maximize
;
603 bool wxTopLevelWindowMSW::IsMaximized() const
608 return ::IsZoomed(GetHwnd()) != 0;
612 void wxTopLevelWindowMSW::Iconize(bool iconize
)
614 DoShowWindow(iconize
? SW_MINIMIZE
: SW_RESTORE
);
617 bool wxTopLevelWindowMSW::IsIconized() const
622 // also update the current state
623 ((wxTopLevelWindowMSW
*)this)->m_iconized
= ::IsIconic(GetHwnd()) != 0;
629 void wxTopLevelWindowMSW::Restore()
631 DoShowWindow(SW_RESTORE
);
634 // ----------------------------------------------------------------------------
635 // wxTopLevelWindowMSW fullscreen
636 // ----------------------------------------------------------------------------
638 bool wxTopLevelWindowMSW::ShowFullScreen(bool show
, long style
)
640 if ( show
== IsFullScreen() )
646 m_fsIsShowing
= show
;
652 // zap the frame borders
654 // save the 'normal' window style
655 m_fsOldWindowStyle
= GetWindowLong(GetHwnd(), GWL_STYLE
);
657 // save the old position, width & height, maximize state
658 m_fsOldSize
= GetRect();
659 m_fsIsMaximized
= IsMaximized();
661 // decide which window style flags to turn off
662 LONG newStyle
= m_fsOldWindowStyle
;
665 if (style
& wxFULLSCREEN_NOBORDER
)
667 offFlags
|= WS_BORDER
;
669 offFlags
|= WS_THICKFRAME
;
672 if (style
& wxFULLSCREEN_NOCAPTION
)
673 offFlags
|= WS_CAPTION
| WS_SYSMENU
;
675 newStyle
&= ~offFlags
;
677 // change our window style to be compatible with full-screen mode
678 ::SetWindowLong(GetHwnd(), GWL_STYLE
, newStyle
);
682 // resize to the size of the display containing us
683 int dpy
= wxDisplay::GetFromWindow(this);
684 if ( dpy
!= wxNOT_FOUND
)
686 rect
= wxDisplay(dpy
).GetGeometry();
688 else // fall back to the main desktop
689 #else // wxUSE_DISPLAY
691 // FIXME: implement for WinCE
693 // resize to the size of the desktop
694 wxCopyRECTToRect(wxGetWindowRect(::GetDesktopWindow()), rect
);
697 #endif // wxUSE_DISPLAY
701 // now flush the window style cache and actually go full-screen
702 long flags
= SWP_FRAMECHANGED
;
704 // showing the frame full screen should also show it if it's still
708 // don't call wxWindow version to avoid flicker from calling
709 // ::ShowWindow() -- we're going to show the window at the correct
710 // location directly below -- but do call the wxWindowBase version
711 // to sync the internal m_isShown flag
712 wxWindowBase::Show();
714 flags
|= SWP_SHOWWINDOW
;
717 SetWindowPos(GetHwnd(), HWND_TOP
,
718 rect
.x
, rect
.y
, rect
.width
, rect
.height
,
721 // finally send an event allowing the window to relayout itself &c
722 wxSizeEvent
event(rect
.GetSize(), GetId());
723 GetEventHandler()->ProcessEvent(event
);
725 else // stop showing full screen
727 Maximize(m_fsIsMaximized
);
728 SetWindowLong(GetHwnd(),GWL_STYLE
, m_fsOldWindowStyle
);
729 SetWindowPos(GetHwnd(),HWND_TOP
,m_fsOldSize
.x
, m_fsOldSize
.y
,
730 m_fsOldSize
.width
, m_fsOldSize
.height
, SWP_FRAMECHANGED
);
736 // ----------------------------------------------------------------------------
737 // wxTopLevelWindowMSW misc
738 // ----------------------------------------------------------------------------
740 void wxTopLevelWindowMSW::SetIcon(const wxIcon
& icon
)
742 SetIcons( wxIconBundle( icon
) );
745 void wxTopLevelWindowMSW::SetIcons(const wxIconBundle
& icons
)
747 wxTopLevelWindowBase::SetIcons(icons
);
749 #if defined(__WIN95__) && !defined(__WXMICROWIN__)
750 const wxIcon
& sml
= icons
.GetIcon( wxSize( 16, 16 ) );
751 if( sml
.Ok() && sml
.GetWidth() == 16 && sml
.GetHeight() == 16 )
753 ::SendMessage( GetHwndOf( this ), WM_SETICON
, ICON_SMALL
,
754 (LPARAM
)GetHiconOf(sml
) );
757 const wxIcon
& big
= icons
.GetIcon( wxSize( 32, 32 ) );
758 if( big
.Ok() && big
.GetWidth() == 32 && big
.GetHeight() == 32 )
760 ::SendMessage( GetHwndOf( this ), WM_SETICON
, ICON_BIG
,
761 (LPARAM
)GetHiconOf(big
) );
766 bool wxTopLevelWindowMSW::EnableCloseButton(bool enable
)
768 #if !defined(__WXMICROWIN__)
769 // get system (a.k.a. window) menu
770 HMENU hmenu
= GetSystemMenu(GetHwnd(), FALSE
/* get it */);
773 // no system menu at all -- ok if we want to remove the close button
774 // anyhow, but bad if we want to show it
778 // enabling/disabling the close item from it also automatically
779 // disables/enables the close title bar button
780 if ( ::EnableMenuItem(hmenu
, SC_CLOSE
,
782 (enable
? MF_ENABLED
: MF_GRAYED
)) == -1 )
784 wxLogLastError(_T("EnableMenuItem(SC_CLOSE)"));
789 // update appearance immediately
790 if ( !::DrawMenuBar(GetHwnd()) )
792 wxLogLastError(_T("DrawMenuBar"));
794 #endif // !__WXMICROWIN__
799 bool wxTopLevelWindowMSW::SetShape(const wxRegion
& region
)
804 wxCHECK_MSG( HasFlag(wxFRAME_SHAPED
), FALSE
,
805 _T("Shaped windows must be created with the wxFRAME_SHAPED style."));
807 // The empty region signifies that the shape should be removed from the
809 if ( region
.IsEmpty() )
811 if (::SetWindowRgn(GetHwnd(), NULL
, TRUE
) == 0)
813 wxLogLastError(_T("SetWindowRgn"));
819 // Windows takes ownership of the region, so
820 // we'll have to make a copy of the region to give to it.
821 DWORD noBytes
= ::GetRegionData(GetHrgnOf(region
), 0, NULL
);
822 RGNDATA
*rgnData
= (RGNDATA
*) new char[noBytes
];
823 ::GetRegionData(GetHrgnOf(region
), noBytes
, rgnData
);
824 HRGN hrgn
= ::ExtCreateRegion(NULL
, noBytes
, rgnData
);
825 delete[] (char*) rgnData
;
827 // SetWindowRgn expects the region to be in coordinants
828 // relative to the window, not the client area. Figure
829 // out the offset, if any.
831 DWORD dwStyle
= ::GetWindowLong(GetHwnd(), GWL_STYLE
);
832 DWORD dwExStyle
= ::GetWindowLong(GetHwnd(), GWL_EXSTYLE
);
833 ::GetClientRect(GetHwnd(), &rect
);
834 ::AdjustWindowRectEx(&rect
, dwStyle
, FALSE
, dwExStyle
);
835 ::OffsetRgn(hrgn
, -rect
.left
, -rect
.top
);
837 // Now call the shape API with the new region.
838 if (::SetWindowRgn(GetHwnd(), hrgn
, TRUE
) == 0)
840 wxLogLastError(_T("SetWindowRgn"));
847 // ----------------------------------------------------------------------------
848 // wxTopLevelWindow event handling
849 // ----------------------------------------------------------------------------
851 // Default activation behaviour - set the focus for the first child
853 void wxTopLevelWindowMSW::OnActivate(wxActivateEvent
& event
)
855 if ( event
.GetActive() )
857 // restore focus to the child which was last focused
858 wxLogTrace(_T("focus"), _T("wxTLW %08x activated."), (int) m_hWnd
);
860 wxWindow
*parent
= m_winLastFocused
? m_winLastFocused
->GetParent()
867 wxSetFocusToChild(parent
, &m_winLastFocused
);
871 // remember the last focused child if it is our child
872 m_winLastFocused
= FindFocus();
874 if ( m_winLastFocused
)
876 // let it know that it doesn't have focus any more
877 m_winLastFocused
->HandleKillFocus((WXHWND
)NULL
);
880 // so we NULL it out if it's a child from some other frame
881 wxWindow
*win
= m_winLastFocused
;
884 if ( win
->IsTopLevel() )
888 m_winLastFocused
= NULL
;
894 win
= win
->GetParent();
897 wxLogTrace(_T("focus"),
898 _T("wxTLW %08x deactivated, last focused: %08x."),
900 (int) (m_winLastFocused
? GetHwndOf(m_winLastFocused
)
907 // the DialogProc for all wxWindows dialogs
908 LONG APIENTRY _EXPORT
909 wxDlgProc(HWND
WXUNUSED(hDlg
),
911 WPARAM
WXUNUSED(wParam
),
912 LPARAM
WXUNUSED(lParam
))
917 // for this message, returning TRUE tells system to set focus to
918 // the first control in the dialog box, but as we set the focus
919 // ourselves, we return FALSE from here as well, so fall through
922 // for all the other ones, FALSE means that we didn't process the
928 // ============================================================================
929 // wxTLWHiddenParentModule implementation
930 // ============================================================================
932 HWND
wxTLWHiddenParentModule::ms_hwnd
= NULL
;
934 const wxChar
*wxTLWHiddenParentModule::ms_className
= NULL
;
936 bool wxTLWHiddenParentModule::OnInit()
944 void wxTLWHiddenParentModule::OnExit()
948 if ( !::DestroyWindow(ms_hwnd
) )
950 wxLogLastError(_T("DestroyWindow(hidden TLW parent)"));
958 if ( !::UnregisterClass(ms_className
, wxGetInstance()) )
960 wxLogLastError(_T("UnregisterClass(\"wxTLWHiddenParent\")"));
968 HWND
wxTLWHiddenParentModule::GetHWND()
974 static const wxChar
*HIDDEN_PARENT_CLASS
= _T("wxTLWHiddenParent");
977 wxZeroMemory(wndclass
);
979 wndclass
.lpfnWndProc
= DefWindowProc
;
980 wndclass
.hInstance
= wxGetInstance();
981 wndclass
.lpszClassName
= HIDDEN_PARENT_CLASS
;
983 if ( !::RegisterClass(&wndclass
) )
985 wxLogLastError(_T("RegisterClass(\"wxTLWHiddenParent\")"));
989 ms_className
= HIDDEN_PARENT_CLASS
;
993 ms_hwnd
= ::CreateWindow(ms_className
, wxEmptyString
, 0, 0, 0, 0, 0, NULL
,
994 (HMENU
)NULL
, wxGetInstance(), NULL
);
997 wxLogLastError(_T("CreateWindow(hidden TLW parent)"));