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
)
159 msflags
|= WS_OVERLAPPED
;
161 // border and caption styles
162 if ( style
& wxRESIZE_BORDER
)
165 msflags
|= WS_THICKFRAME
;
168 else if ( !(style
& wxBORDER_NONE
) )
169 msflags
|= WS_BORDER
;
173 if ( style
& wxCAPTION
)
174 msflags
|= WS_CAPTION
;
178 // next translate the individual flags
179 if ( style
& wxMINIMIZE_BOX
)
180 msflags
|= WS_MINIMIZEBOX
;
181 if ( style
& wxMAXIMIZE_BOX
)
182 msflags
|= WS_MAXIMIZEBOX
;
183 if ( style
& wxSYSTEM_MENU
)
184 msflags
|= WS_SYSMENU
;
186 if ( style
& wxMINIMIZE
)
187 msflags
|= WS_MINIMIZE
;
188 if ( style
& wxMAXIMIZE
)
189 msflags
|= WS_MAXIMIZE
;
192 // Keep this here because it saves recoding this function in wxTinyFrame
193 #if wxUSE_ITSY_BITSY && !defined(__WIN32__)
194 if ( style
& wxTINY_CAPTION_VERT
)
195 msflags
|= IBS_VERTCAPTION
;
196 if ( style
& wxTINY_CAPTION_HORIZ
)
197 msflags
|= IBS_HORZCAPTION
;
199 if ( style
& (wxTINY_CAPTION_VERT
| wxTINY_CAPTION_HORIZ
) )
200 msflags
|= WS_CAPTION
;
205 #if !defined(__WIN16__)
206 if ( !(GetExtraStyle() & wxTOPLEVEL_EX_DIALOG
) )
208 if ( style
& wxFRAME_TOOL_WINDOW
)
210 // create the palette-like window
211 *exflags
|= WS_EX_TOOLWINDOW
;
214 // We have to solve 2 different problems here:
216 // 1. frames with wxFRAME_NO_TASKBAR flag shouldn't appear in the
217 // taskbar even if they don't have a parent
219 // 2. frames without this style should appear in the taskbar even
220 // if they're owned (Windows only puts non owned windows into
221 // the taskbar normally)
223 // The second one is solved here by using WS_EX_APPWINDOW flag, the
224 // first one is dealt with in our MSWGetParent() method
227 if ( !(style
& wxFRAME_NO_TASKBAR
) && GetParent() )
229 // need to force the frame to appear in the taskbar
230 *exflags
|= WS_EX_APPWINDOW
;
233 //else: nothing to do [here]
237 if ( style
& wxSTAY_ON_TOP
)
238 *exflags
|= WS_EX_TOPMOST
;
241 if ( GetExtraStyle() & wxFRAME_EX_CONTEXTHELP
)
242 *exflags
|= WS_EX_CONTEXTHELP
;
249 WXHWND
wxTopLevelWindowMSW::MSWGetParent() const
251 // for the frames without wxFRAME_FLOAT_ON_PARENT style we should use NULL
252 // parent HWND or it would be always on top of its parent which is not what
253 // we usually want (in fact, we only want it for frames with the
254 // wxFRAME_FLOAT_ON_PARENT flag)
255 HWND hwndParent
= NULL
;
256 if ( HasFlag(wxFRAME_FLOAT_ON_PARENT
) )
258 const wxWindow
*parent
= GetParent();
262 // this flag doesn't make sense then and will be ignored
263 wxFAIL_MSG( _T("wxFRAME_FLOAT_ON_PARENT but no parent?") );
267 hwndParent
= GetHwndOf(parent
);
270 //else: don't float on parent, must not be owned
272 // now deal with the 2nd taskbar-related problem (see comments above in
274 if ( HasFlag(wxFRAME_NO_TASKBAR
) && !hwndParent
)
277 hwndParent
= wxTLWHiddenParentModule::GetHWND();
280 return (WXHWND
)hwndParent
;
283 bool wxTopLevelWindowMSW::CreateDialog(const void *dlgTemplate
,
284 const wxString
& title
,
288 #ifdef __WXMICROWIN__
289 // no dialogs support under MicroWin yet
290 return CreateFrame(title
, pos
, size
);
291 #else // !__WXMICROWIN__
292 wxWindow
*parent
= GetParent();
294 // for the dialogs without wxDIALOG_NO_PARENT style, use the top level
295 // app window as parent - this avoids creating modal dialogs without
297 if ( !parent
&& !(GetWindowStyleFlag() & wxDIALOG_NO_PARENT
) )
299 parent
= wxTheApp
->GetTopWindow();
303 // don't use transient windows as parents, this is dangerous as it
304 // can lead to a crash if the parent is destroyed before the child
306 // also don't use the window which is currently hidden as then the
307 // dialog would be hidden as well
308 if ( (parent
->GetExtraStyle() & wxWS_EX_TRANSIENT
) ||
316 m_hWnd
= (WXHWND
)::CreateDialogIndirect
319 (DLGTEMPLATE
*)dlgTemplate
,
320 parent
? GetHwndOf(parent
) : NULL
,
326 wxFAIL_MSG(wxT("Failed to create dialog. Incorrect DLGTEMPLATE?"));
328 wxLogSysError(wxT("Can't create dialog using memory template"));
334 (void)MSWGetCreateWindowFlags(&exflags
);
338 ::SetWindowLong(GetHwnd(), GWL_EXSTYLE
, exflags
);
339 ::SetWindowPos(GetHwnd(), NULL
, 0, 0, 0, 0,
346 #if defined(__WIN95__)
347 // For some reason, the system menu is activated when we use the
348 // WS_EX_CONTEXTHELP style, so let's set a reasonable icon
349 if ( exflags
& WS_EX_CONTEXTHELP
)
351 wxFrame
*winTop
= wxDynamicCast(wxTheApp
->GetTopWindow(), wxFrame
);
354 wxIcon icon
= winTop
->GetIcon();
357 ::SendMessage(GetHwnd(), WM_SETICON
,
359 (LPARAM
)GetHiconOf(icon
));
365 // move the dialog to its initial position without forcing repainting
367 if ( !MSWGetCreateWindowCoords(pos
, size
, x
, y
, w
, h
) )
370 w
= (int)CW_USEDEFAULT
;
373 // we can't use CW_USEDEFAULT here as we're not calling CreateWindow()
374 // and passing CW_USEDEFAULT to MoveWindow() results in resizing the
375 // window to (0, 0) size which breaks quite a lot of things, e.g. the
376 // sizer calculation in wxSizer::Fit()
377 if ( w
== (int)CW_USEDEFAULT
)
379 // the exact number doesn't matter, the dialog will be resized
380 // again soon anyhow but it should be big enough to allow
381 // calculation relying on "totalSize - clientSize > 0" work, i.e.
382 // at least greater than the title bar height
387 if ( x
== (int)CW_USEDEFAULT
)
389 // centre it on the screen - what else can we do?
390 wxSize sizeDpy
= wxGetDisplaySize();
392 x
= (sizeDpy
.x
- w
) / 2;
393 y
= (sizeDpy
.y
- h
) / 2;
396 if ( !::MoveWindow(GetHwnd(), x
, y
, w
, h
, FALSE
) )
398 wxLogLastError(wxT("MoveWindow"));
401 if ( !title
.empty() )
403 ::SetWindowText(GetHwnd(), title
);
409 #endif // __WXMICROWIN__/!__WXMICROWIN__
412 bool wxTopLevelWindowMSW::CreateFrame(const wxString
& title
,
417 WXDWORD flags
= MSWGetCreateWindowFlags(&exflags
);
419 return MSWCreate(wxCanvasClassName
, title
, pos
, size
, flags
, exflags
);
422 bool wxTopLevelWindowMSW::Create(wxWindow
*parent
,
424 const wxString
& title
,
428 const wxString
& name
)
435 m_windowStyle
= style
;
439 m_windowId
= id
== -1 ? NewControlId() : id
;
441 wxTopLevelWindows
.Append(this);
444 parent
->AddChild(this);
446 if ( GetExtraStyle() & wxTOPLEVEL_EX_DIALOG
)
448 // we have different dialog templates to allows creation of dialogs
449 // with & without captions under MSWindows, resizeable or not (but a
450 // resizeable dialog always has caption - otherwise it would look too
453 // we need 3 additional WORDs for dialog menu, class and title (as we
454 // don't use DS_SETFONT we don't need the fourth WORD for the font)
455 static const int dlgsize
= sizeof(DLGTEMPLATE
) + (sizeof(WORD
) * 3);
456 DLGTEMPLATE
*dlgTemplate
= (DLGTEMPLATE
*)malloc(dlgsize
);
457 memset(dlgTemplate
, 0, dlgsize
);
459 // these values are arbitrary, they won't be used normally anyhow
462 dlgTemplate
->cx
= 144;
463 dlgTemplate
->cy
= 75;
465 // reuse the code in MSWGetStyle() but correct the results slightly for
467 dlgTemplate
->style
= MSWGetStyle(style
, NULL
);
469 // all dialogs are popups
470 dlgTemplate
->style
|= WS_POPUP
;
472 // force 3D-look if necessary, it looks impossibly ugly otherwise
473 if ( style
& (wxRESIZE_BORDER
| wxCAPTION
) )
474 dlgTemplate
->style
|= DS_MODALFRAME
;
476 ret
= CreateDialog(dlgTemplate
, title
, pos
, size
);
481 ret
= CreateFrame(title
, pos
, size
);
484 if ( ret
&& !(GetWindowStyleFlag() & wxCLOSE_BOX
) )
486 EnableCloseButton(false);
492 wxTopLevelWindowMSW::~wxTopLevelWindowMSW()
494 if ( wxModelessWindows
.Find(this) )
495 wxModelessWindows
.DeleteObject(this);
497 // after destroying an owned window, Windows activates the next top level
498 // window in Z order but it may be different from our owner (to reproduce
499 // this simply Alt-TAB to another application and back before closing the
500 // owned frame) whereas we always want to yield activation to our parent
501 if ( HasFlag(wxFRAME_FLOAT_ON_PARENT
) )
503 wxWindow
*parent
= GetParent();
506 ::BringWindowToTop(GetHwndOf(parent
));
511 // ----------------------------------------------------------------------------
512 // wxTopLevelWindowMSW showing
513 // ----------------------------------------------------------------------------
515 void wxTopLevelWindowMSW::DoShowWindow(int nShowCmd
)
517 ::ShowWindow(GetHwnd(), nShowCmd
);
519 m_iconized
= nShowCmd
== SW_MINIMIZE
;
522 bool wxTopLevelWindowMSW::Show(bool show
)
524 // don't use wxWindow version as we want to call DoShowWindow() ourselves
525 if ( !wxWindowBase::Show(show
) )
531 if ( m_maximizeOnShow
)
534 nShowCmd
= SW_MAXIMIZE
;
536 m_maximizeOnShow
= FALSE
;
540 if ( GetWindowStyle() & wxFRAME_TOOL_WINDOW
)
541 nShowCmd
= SW_SHOWNA
;
551 DoShowWindow(nShowCmd
);
555 ::BringWindowToTop(GetHwnd());
557 wxActivateEvent
event(wxEVT_ACTIVATE
, TRUE
, m_windowId
);
558 event
.SetEventObject( this );
559 GetEventHandler()->ProcessEvent(event
);
563 // Try to highlight the correct window (the parent)
566 HWND hWndParent
= GetHwndOf(GetParent());
568 ::BringWindowToTop(hWndParent
);
575 // ----------------------------------------------------------------------------
576 // wxTopLevelWindowMSW maximize/minimize
577 // ----------------------------------------------------------------------------
579 void wxTopLevelWindowMSW::Maximize(bool maximize
)
583 // just maximize it directly
584 DoShowWindow(maximize
? SW_MAXIMIZE
: SW_RESTORE
);
588 // we can't maximize the hidden frame because it shows it as well, so
589 // just remember that we should do it later in this case
590 m_maximizeOnShow
= maximize
;
594 bool wxTopLevelWindowMSW::IsMaximized() const
599 return ::IsZoomed(GetHwnd()) != 0;
603 void wxTopLevelWindowMSW::Iconize(bool iconize
)
605 DoShowWindow(iconize
? SW_MINIMIZE
: SW_RESTORE
);
608 bool wxTopLevelWindowMSW::IsIconized() const
613 // also update the current state
614 ((wxTopLevelWindowMSW
*)this)->m_iconized
= ::IsIconic(GetHwnd()) != 0;
620 void wxTopLevelWindowMSW::Restore()
622 DoShowWindow(SW_RESTORE
);
625 // ----------------------------------------------------------------------------
626 // wxTopLevelWindowMSW fullscreen
627 // ----------------------------------------------------------------------------
629 bool wxTopLevelWindowMSW::ShowFullScreen(bool show
, long style
)
631 if ( show
== IsFullScreen() )
637 m_fsIsShowing
= show
;
643 // zap the frame borders
645 // save the 'normal' window style
646 m_fsOldWindowStyle
= GetWindowLong(GetHwnd(), GWL_STYLE
);
648 // save the old position, width & height, maximize state
649 m_fsOldSize
= GetRect();
650 m_fsIsMaximized
= IsMaximized();
652 // decide which window style flags to turn off
653 LONG newStyle
= m_fsOldWindowStyle
;
656 if (style
& wxFULLSCREEN_NOBORDER
)
658 offFlags
|= WS_BORDER
;
660 offFlags
|= WS_THICKFRAME
;
663 if (style
& wxFULLSCREEN_NOCAPTION
)
664 offFlags
|= WS_CAPTION
| WS_SYSMENU
;
666 newStyle
&= ~offFlags
;
668 // change our window style to be compatible with full-screen mode
669 ::SetWindowLong(GetHwnd(), GWL_STYLE
, newStyle
);
673 // resize to the size of the display containing us
674 int dpy
= wxDisplay::GetFromWindow(this);
675 if ( dpy
!= wxNOT_FOUND
)
677 rect
= wxDisplay(dpy
).GetGeometry();
679 else // fall back to the main desktop
680 #else // wxUSE_DISPLAY
682 // FIXME: implement for WinCE
684 // resize to the size of the desktop
685 wxCopyRECTToRect(wxGetWindowRect(::GetDesktopWindow()), rect
);
688 #endif // wxUSE_DISPLAY
692 // now flush the window style cache and actually go full-screen
693 long flags
= SWP_FRAMECHANGED
;
695 // showing the frame full screen should also show it if it's still
699 // don't call wxWindow version to avoid flicker from calling
700 // ::ShowWindow() -- we're going to show the window at the correct
701 // location directly below -- but do call the wxWindowBase version
702 // to sync the internal m_isShown flag
703 wxWindowBase::Show();
705 flags
|= SWP_SHOWWINDOW
;
708 SetWindowPos(GetHwnd(), HWND_TOP
,
709 rect
.x
, rect
.y
, rect
.width
, rect
.height
,
712 // finally send an event allowing the window to relayout itself &c
713 wxSizeEvent
event(rect
.GetSize(), GetId());
714 GetEventHandler()->ProcessEvent(event
);
716 else // stop showing full screen
718 Maximize(m_fsIsMaximized
);
719 SetWindowLong(GetHwnd(),GWL_STYLE
, m_fsOldWindowStyle
);
720 SetWindowPos(GetHwnd(),HWND_TOP
,m_fsOldSize
.x
, m_fsOldSize
.y
,
721 m_fsOldSize
.width
, m_fsOldSize
.height
, SWP_FRAMECHANGED
);
727 // ----------------------------------------------------------------------------
728 // wxTopLevelWindowMSW misc
729 // ----------------------------------------------------------------------------
731 void wxTopLevelWindowMSW::SetIcon(const wxIcon
& icon
)
733 SetIcons( wxIconBundle( icon
) );
736 void wxTopLevelWindowMSW::SetIcons(const wxIconBundle
& icons
)
738 wxTopLevelWindowBase::SetIcons(icons
);
740 #if defined(__WIN95__) && !defined(__WXMICROWIN__)
741 const wxIcon
& sml
= icons
.GetIcon( wxSize( 16, 16 ) );
742 if( sml
.Ok() && sml
.GetWidth() == 16 && sml
.GetHeight() == 16 )
744 ::SendMessage( GetHwndOf( this ), WM_SETICON
, ICON_SMALL
,
745 (LPARAM
)GetHiconOf(sml
) );
748 const wxIcon
& big
= icons
.GetIcon( wxSize( 32, 32 ) );
749 if( big
.Ok() && big
.GetWidth() == 32 && big
.GetHeight() == 32 )
751 ::SendMessage( GetHwndOf( this ), WM_SETICON
, ICON_BIG
,
752 (LPARAM
)GetHiconOf(big
) );
757 bool wxTopLevelWindowMSW::EnableCloseButton(bool enable
)
759 #if !defined(__WXMICROWIN__)
760 // get system (a.k.a. window) menu
761 HMENU hmenu
= GetSystemMenu(GetHwnd(), FALSE
/* get it */);
764 // no system menu at all -- ok if we want to remove the close button
765 // anyhow, but bad if we want to show it
769 // enabling/disabling the close item from it also automatically
770 // disables/enables the close title bar button
771 if ( ::EnableMenuItem(hmenu
, SC_CLOSE
,
773 (enable
? MF_ENABLED
: MF_GRAYED
)) == -1 )
775 wxLogLastError(_T("EnableMenuItem(SC_CLOSE)"));
780 // update appearance immediately
781 if ( !::DrawMenuBar(GetHwnd()) )
783 wxLogLastError(_T("DrawMenuBar"));
785 #endif // !__WXMICROWIN__
790 bool wxTopLevelWindowMSW::SetShape(const wxRegion
& region
)
795 wxCHECK_MSG( HasFlag(wxFRAME_SHAPED
), FALSE
,
796 _T("Shaped windows must be created with the wxFRAME_SHAPED style."));
798 // The empty region signifies that the shape should be removed from the
800 if ( region
.IsEmpty() )
802 if (::SetWindowRgn(GetHwnd(), NULL
, TRUE
) == 0)
804 wxLogLastError(_T("SetWindowRgn"));
810 // Windows takes ownership of the region, so
811 // we'll have to make a copy of the region to give to it.
812 DWORD noBytes
= ::GetRegionData(GetHrgnOf(region
), 0, NULL
);
813 RGNDATA
*rgnData
= (RGNDATA
*) new char[noBytes
];
814 ::GetRegionData(GetHrgnOf(region
), noBytes
, rgnData
);
815 HRGN hrgn
= ::ExtCreateRegion(NULL
, noBytes
, rgnData
);
816 delete[] (char*) rgnData
;
818 // SetWindowRgn expects the region to be in coordinants
819 // relative to the window, not the client area. Figure
820 // out the offset, if any.
822 DWORD dwStyle
= ::GetWindowLong(GetHwnd(), GWL_STYLE
);
823 DWORD dwExStyle
= ::GetWindowLong(GetHwnd(), GWL_EXSTYLE
);
824 ::GetClientRect(GetHwnd(), &rect
);
825 ::AdjustWindowRectEx(&rect
, dwStyle
, FALSE
, dwExStyle
);
826 ::OffsetRgn(hrgn
, -rect
.left
, -rect
.top
);
828 // Now call the shape API with the new region.
829 if (::SetWindowRgn(GetHwnd(), hrgn
, TRUE
) == 0)
831 wxLogLastError(_T("SetWindowRgn"));
838 // ----------------------------------------------------------------------------
839 // wxTopLevelWindow event handling
840 // ----------------------------------------------------------------------------
842 // Default activation behaviour - set the focus for the first child
844 void wxTopLevelWindowMSW::OnActivate(wxActivateEvent
& event
)
846 if ( event
.GetActive() )
848 // restore focus to the child which was last focused
849 wxLogTrace(_T("focus"), _T("wxTLW %08x activated."), (int) m_hWnd
);
851 wxWindow
*parent
= m_winLastFocused
? m_winLastFocused
->GetParent()
858 wxSetFocusToChild(parent
, &m_winLastFocused
);
862 // remember the last focused child if it is our child
863 m_winLastFocused
= FindFocus();
865 if ( m_winLastFocused
)
867 // let it know that it doesn't have focus any more
868 m_winLastFocused
->HandleKillFocus((WXHWND
)NULL
);
871 // so we NULL it out if it's a child from some other frame
872 wxWindow
*win
= m_winLastFocused
;
875 if ( win
->IsTopLevel() )
879 m_winLastFocused
= NULL
;
885 win
= win
->GetParent();
888 wxLogTrace(_T("focus"),
889 _T("wxTLW %08x deactivated, last focused: %08x."),
891 (int) (m_winLastFocused
? GetHwndOf(m_winLastFocused
)
898 // the DialogProc for all wxWindows dialogs
899 LONG APIENTRY _EXPORT
900 wxDlgProc(HWND hDlg
, UINT message
, WPARAM wParam
, LPARAM lParam
)
905 // for this message, returning TRUE tells system to set focus to
906 // the first control in the dialog box, but as we set the focus
907 // ourselves, we return FALSE from here as well, so fall through
910 // for all the other ones, FALSE means that we didn't process the
916 // ============================================================================
917 // wxTLWHiddenParentModule implementation
918 // ============================================================================
920 HWND
wxTLWHiddenParentModule::ms_hwnd
= NULL
;
922 const wxChar
*wxTLWHiddenParentModule::ms_className
= NULL
;
924 bool wxTLWHiddenParentModule::OnInit()
932 void wxTLWHiddenParentModule::OnExit()
936 if ( !::DestroyWindow(ms_hwnd
) )
938 wxLogLastError(_T("DestroyWindow(hidden TLW parent)"));
946 if ( !::UnregisterClass(ms_className
, wxGetInstance()) )
948 wxLogLastError(_T("UnregisterClass(\"wxTLWHiddenParent\")"));
956 HWND
wxTLWHiddenParentModule::GetHWND()
962 static const wxChar
*HIDDEN_PARENT_CLASS
= _T("wxTLWHiddenParent");
965 wxZeroMemory(wndclass
);
967 wndclass
.lpfnWndProc
= DefWindowProc
;
968 wndclass
.hInstance
= wxGetInstance();
969 wndclass
.lpszClassName
= HIDDEN_PARENT_CLASS
;
971 if ( !::RegisterClass(&wndclass
) )
973 wxLogLastError(_T("RegisterClass(\"wxTLWHiddenParent\")"));
977 ms_className
= HIDDEN_PARENT_CLASS
;
981 ms_hwnd
= ::CreateWindow(ms_className
, wxEmptyString
, 0, 0, 0, 0, 0, NULL
,
982 (HMENU
)NULL
, wxGetInstance(), NULL
);
985 wxLogLastError(_T("CreateWindow(hidden TLW parent)"));