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 // ----------------------------------------------------------------------------
20 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
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"
46 // This can't be undefed in winundef.h or
47 // there are further errors
48 #if defined(__WXWINCE__) && defined(CreateDialog)
52 #include "wx/display.h"
62 // ----------------------------------------------------------------------------
63 // stubs for missing functions under MicroWindows
64 // ----------------------------------------------------------------------------
68 // static inline bool IsIconic(HWND WXUNUSED(hwnd)) { return FALSE; }
69 static inline bool IsZoomed(HWND
WXUNUSED(hwnd
)) { return FALSE
; }
71 #endif // __WXMICROWIN__
73 // NB: wxDlgProc must be defined here and not in dialog.cpp because the latter
74 // is not included by wxUniv build which does need wxDlgProc
76 wxDlgProc(HWND hDlg
, UINT message
, WPARAM wParam
, LPARAM lParam
);
78 // ----------------------------------------------------------------------------
80 // ----------------------------------------------------------------------------
82 // list of all frames and modeless dialogs
83 wxWindowList wxModelessWindows
;
85 // the name of the default wxWindows class
86 extern const wxChar
*wxCanvasClassName
;
88 // ----------------------------------------------------------------------------
89 // wxTLWHiddenParentModule: used to manage the hidden parent window (we need a
90 // module to ensure that the window is always deleted)
91 // ----------------------------------------------------------------------------
93 class wxTLWHiddenParentModule
: public wxModule
96 // module init/finalize
97 virtual bool OnInit();
98 virtual void OnExit();
100 // get the hidden window (creates on demand)
101 static HWND
GetHWND();
104 // the HWND of the hidden parent
107 // the class used to create it
108 static const wxChar
*ms_className
;
110 DECLARE_DYNAMIC_CLASS(wxTLWHiddenParentModule
)
113 IMPLEMENT_DYNAMIC_CLASS(wxTLWHiddenParentModule
, wxModule
)
115 // ============================================================================
116 // wxTopLevelWindowMSW implementation
117 // ============================================================================
119 BEGIN_EVENT_TABLE(wxTopLevelWindowMSW
, wxTopLevelWindowBase
)
120 EVT_ACTIVATE(wxTopLevelWindowMSW::OnActivate
)
123 // ----------------------------------------------------------------------------
124 // wxTopLevelWindowMSW creation
125 // ----------------------------------------------------------------------------
127 void wxTopLevelWindowMSW::Init()
130 m_maximizeOnShow
= FALSE
;
132 // unlike (almost?) all other windows, frames are created hidden
135 // Data to save/restore when calling ShowFullScreen
137 m_fsOldWindowStyle
= 0;
138 m_fsIsMaximized
= FALSE
;
139 m_fsIsShowing
= FALSE
;
141 m_winLastFocused
= (wxWindow
*)NULL
;
144 WXDWORD
wxTopLevelWindowMSW::MSWGetStyle(long style
, WXDWORD
*exflags
) const
146 // let the base class deal with the common styles but fix the ones which
147 // don't make sense for us (we also deal with the borders ourselves)
148 WXDWORD msflags
= wxWindow::MSWGetStyle
150 (style
& ~wxBORDER_MASK
) | wxBORDER_NONE
, exflags
151 ) & ~WS_CHILD
& ~WS_VISIBLE
;
153 // first select the kind of window being created
155 // note that if we don't set WS_POPUP, Windows assumes WS_OVERLAPPED and
156 // creates a window with both caption and border, hence we also test it
157 // below in some other cases
158 if ( style
& wxFRAME_TOOL_WINDOW
)
163 if (msflags
& WS_BORDER
)
165 msflags
|= WS_OVERLAPPED
;
168 // border and caption styles
169 if ( style
& wxRESIZE_BORDER
)
172 msflags
|= WS_THICKFRAME
;
175 else if ( !(style
& wxBORDER_NONE
) )
176 msflags
|= WS_BORDER
;
182 if ( style
& wxCAPTION
)
183 msflags
|= WS_CAPTION
;
189 // next translate the individual flags
190 if ( style
& wxMINIMIZE_BOX
)
191 msflags
|= WS_MINIMIZEBOX
;
192 if ( style
& wxMAXIMIZE_BOX
)
193 msflags
|= WS_MAXIMIZEBOX
;
194 if ( style
& wxSYSTEM_MENU
)
195 msflags
|= WS_SYSMENU
;
197 if ( style
& wxMINIMIZE
)
198 msflags
|= WS_MINIMIZE
;
199 if ( style
& wxMAXIMIZE
)
200 msflags
|= WS_MAXIMIZE
;
203 // Keep this here because it saves recoding this function in wxTinyFrame
204 #if wxUSE_ITSY_BITSY && !defined(__WIN32__)
205 if ( style
& wxTINY_CAPTION_VERT
)
206 msflags
|= IBS_VERTCAPTION
;
207 if ( style
& wxTINY_CAPTION_HORIZ
)
208 msflags
|= IBS_HORZCAPTION
;
210 if ( style
& (wxTINY_CAPTION_VERT
| wxTINY_CAPTION_HORIZ
) )
211 msflags
|= WS_CAPTION
;
216 #if !defined(__WIN16__)
217 if ( !(GetExtraStyle() & wxTOPLEVEL_EX_DIALOG
) )
219 if ( style
& wxFRAME_TOOL_WINDOW
)
221 // create the palette-like window
222 *exflags
|= WS_EX_TOOLWINDOW
;
225 // We have to solve 2 different problems here:
227 // 1. frames with wxFRAME_NO_TASKBAR flag shouldn't appear in the
228 // taskbar even if they don't have a parent
230 // 2. frames without this style should appear in the taskbar even
231 // if they're owned (Windows only puts non owned windows into
232 // the taskbar normally)
234 // The second one is solved here by using WS_EX_APPWINDOW flag, the
235 // first one is dealt with in our MSWGetParent() method
238 if ( !(style
& wxFRAME_NO_TASKBAR
) && GetParent() )
240 // need to force the frame to appear in the taskbar
241 *exflags
|= WS_EX_APPWINDOW
;
244 //else: nothing to do [here]
248 if ( style
& wxSTAY_ON_TOP
)
249 *exflags
|= WS_EX_TOPMOST
;
252 if ( GetExtraStyle() & wxFRAME_EX_CONTEXTHELP
)
253 *exflags
|= WS_EX_CONTEXTHELP
;
260 WXHWND
wxTopLevelWindowMSW::MSWGetParent() const
262 // for the frames without wxFRAME_FLOAT_ON_PARENT style we should use NULL
263 // parent HWND or it would be always on top of its parent which is not what
264 // we usually want (in fact, we only want it for frames with the
265 // wxFRAME_FLOAT_ON_PARENT flag)
266 HWND hwndParent
= NULL
;
267 if ( HasFlag(wxFRAME_FLOAT_ON_PARENT
) )
269 const wxWindow
*parent
= GetParent();
273 // this flag doesn't make sense then and will be ignored
274 wxFAIL_MSG( _T("wxFRAME_FLOAT_ON_PARENT but no parent?") );
278 hwndParent
= GetHwndOf(parent
);
281 //else: don't float on parent, must not be owned
283 // now deal with the 2nd taskbar-related problem (see comments above in
285 if ( HasFlag(wxFRAME_NO_TASKBAR
) && !hwndParent
)
288 hwndParent
= wxTLWHiddenParentModule::GetHWND();
291 return (WXHWND
)hwndParent
;
294 bool wxTopLevelWindowMSW::CreateDialog(const void *dlgTemplate
,
295 const wxString
& title
,
299 #ifdef __WXMICROWIN__
300 // no dialogs support under MicroWin yet
301 return CreateFrame(title
, pos
, size
);
302 #else // !__WXMICROWIN__
303 wxWindow
*parent
= GetParent();
305 // for the dialogs without wxDIALOG_NO_PARENT style, use the top level
306 // app window as parent - this avoids creating modal dialogs without
308 if ( !parent
&& !(GetWindowStyleFlag() & wxDIALOG_NO_PARENT
) )
310 parent
= wxTheApp
->GetTopWindow();
314 // don't use transient windows as parents, this is dangerous as it
315 // can lead to a crash if the parent is destroyed before the child
317 // also don't use the window which is currently hidden as then the
318 // dialog would be hidden as well
319 if ( (parent
->GetExtraStyle() & wxWS_EX_TRANSIENT
) ||
327 m_hWnd
= (WXHWND
)::CreateDialogIndirect
330 (DLGTEMPLATE
*)dlgTemplate
,
331 parent
? GetHwndOf(parent
) : NULL
,
337 wxFAIL_MSG(wxT("Failed to create dialog. Incorrect DLGTEMPLATE?"));
339 wxLogSysError(wxT("Can't create dialog using memory template"));
345 (void)MSWGetCreateWindowFlags(&exflags
);
349 ::SetWindowLong(GetHwnd(), GWL_EXSTYLE
, exflags
);
350 ::SetWindowPos(GetHwnd(),
351 exflags
& WS_EX_TOPMOST
? HWND_TOPMOST
: 0,
355 (exflags
& WS_EX_TOPMOST
? 0 : SWP_NOZORDER
) |
359 #if defined(__WIN95__)
360 // For some reason, the system menu is activated when we use the
361 // WS_EX_CONTEXTHELP style, so let's set a reasonable icon
362 if ( exflags
& WS_EX_CONTEXTHELP
)
364 wxFrame
*winTop
= wxDynamicCast(wxTheApp
->GetTopWindow(), wxFrame
);
367 wxIcon icon
= winTop
->GetIcon();
370 ::SendMessage(GetHwnd(), WM_SETICON
,
372 (LPARAM
)GetHiconOf(icon
));
378 // move the dialog to its initial position without forcing repainting
380 if ( !MSWGetCreateWindowCoords(pos
, size
, x
, y
, w
, h
) )
383 w
= (int)CW_USEDEFAULT
;
386 // we can't use CW_USEDEFAULT here as we're not calling CreateWindow()
387 // and passing CW_USEDEFAULT to MoveWindow() results in resizing the
388 // window to (0, 0) size which breaks quite a lot of things, e.g. the
389 // sizer calculation in wxSizer::Fit()
390 if ( w
== (int)CW_USEDEFAULT
)
392 // the exact number doesn't matter, the dialog will be resized
393 // again soon anyhow but it should be big enough to allow
394 // calculation relying on "totalSize - clientSize > 0" work, i.e.
395 // at least greater than the title bar height
400 if ( x
== (int)CW_USEDEFAULT
)
402 // centre it on the screen - what else can we do?
403 wxSize sizeDpy
= wxGetDisplaySize();
405 x
= (sizeDpy
.x
- w
) / 2;
406 y
= (sizeDpy
.y
- h
) / 2;
409 if ( !::MoveWindow(GetHwnd(), x
, y
, w
, h
, FALSE
) )
411 wxLogLastError(wxT("MoveWindow"));
414 if ( !title
.empty() )
416 ::SetWindowText(GetHwnd(), title
);
422 #endif // __WXMICROWIN__/!__WXMICROWIN__
425 bool wxTopLevelWindowMSW::CreateFrame(const wxString
& title
,
430 WXDWORD flags
= MSWGetCreateWindowFlags(&exflags
);
432 return MSWCreate(wxCanvasClassName
, title
, pos
, size
, flags
, exflags
);
435 bool wxTopLevelWindowMSW::Create(wxWindow
*parent
,
437 const wxString
& title
,
441 const wxString
& name
)
448 m_windowStyle
= style
;
452 m_windowId
= id
== -1 ? NewControlId() : id
;
454 wxTopLevelWindows
.Append(this);
457 parent
->AddChild(this);
459 if ( GetExtraStyle() & wxTOPLEVEL_EX_DIALOG
)
461 // we have different dialog templates to allows creation of dialogs
462 // with & without captions under MSWindows, resizeable or not (but a
463 // resizeable dialog always has caption - otherwise it would look too
466 // we need 3 additional WORDs for dialog menu, class and title (as we
467 // don't use DS_SETFONT we don't need the fourth WORD for the font)
468 static const int dlgsize
= sizeof(DLGTEMPLATE
) + (sizeof(WORD
) * 3);
469 DLGTEMPLATE
*dlgTemplate
= (DLGTEMPLATE
*)malloc(dlgsize
);
470 memset(dlgTemplate
, 0, dlgsize
);
472 // these values are arbitrary, they won't be used normally anyhow
475 dlgTemplate
->cx
= 144;
476 dlgTemplate
->cy
= 75;
478 // reuse the code in MSWGetStyle() but correct the results slightly for
480 dlgTemplate
->style
= MSWGetStyle(style
, NULL
);
482 // all dialogs are popups
483 dlgTemplate
->style
|= WS_POPUP
;
485 // force 3D-look if necessary, it looks impossibly ugly otherwise
486 if ( style
& (wxRESIZE_BORDER
| wxCAPTION
) )
487 dlgTemplate
->style
|= DS_MODALFRAME
;
489 ret
= CreateDialog(dlgTemplate
, title
, pos
, size
);
494 ret
= CreateFrame(title
, pos
, size
);
497 if ( ret
&& !(GetWindowStyleFlag() & wxCLOSE_BOX
) )
499 EnableCloseButton(false);
505 wxTopLevelWindowMSW::~wxTopLevelWindowMSW()
507 if ( wxModelessWindows
.Find(this) )
508 wxModelessWindows
.DeleteObject(this);
510 // after destroying an owned window, Windows activates the next top level
511 // window in Z order but it may be different from our owner (to reproduce
512 // this simply Alt-TAB to another application and back before closing the
513 // owned frame) whereas we always want to yield activation to our parent
514 if ( HasFlag(wxFRAME_FLOAT_ON_PARENT
) )
516 wxWindow
*parent
= GetParent();
519 ::BringWindowToTop(GetHwndOf(parent
));
524 // ----------------------------------------------------------------------------
525 // wxTopLevelWindowMSW showing
526 // ----------------------------------------------------------------------------
528 void wxTopLevelWindowMSW::DoShowWindow(int nShowCmd
)
530 ::ShowWindow(GetHwnd(), nShowCmd
);
532 m_iconized
= nShowCmd
== SW_MINIMIZE
;
535 bool wxTopLevelWindowMSW::Show(bool show
)
537 // don't use wxWindow version as we want to call DoShowWindow() ourselves
538 if ( !wxWindowBase::Show(show
) )
544 if ( m_maximizeOnShow
)
547 nShowCmd
= SW_MAXIMIZE
;
549 m_maximizeOnShow
= FALSE
;
553 if ( GetWindowStyle() & wxFRAME_TOOL_WINDOW
)
554 nShowCmd
= SW_SHOWNA
;
564 DoShowWindow(nShowCmd
);
568 ::BringWindowToTop(GetHwnd());
570 wxActivateEvent
event(wxEVT_ACTIVATE
, TRUE
, m_windowId
);
571 event
.SetEventObject( this );
572 GetEventHandler()->ProcessEvent(event
);
576 // Try to highlight the correct window (the parent)
579 HWND hWndParent
= GetHwndOf(GetParent());
581 ::BringWindowToTop(hWndParent
);
588 // ----------------------------------------------------------------------------
589 // wxTopLevelWindowMSW maximize/minimize
590 // ----------------------------------------------------------------------------
592 void wxTopLevelWindowMSW::Maximize(bool maximize
)
596 // just maximize it directly
597 DoShowWindow(maximize
? SW_MAXIMIZE
: SW_RESTORE
);
601 // we can't maximize the hidden frame because it shows it as well, so
602 // just remember that we should do it later in this case
603 m_maximizeOnShow
= maximize
;
607 bool wxTopLevelWindowMSW::IsMaximized() const
612 return ::IsZoomed(GetHwnd()) != 0;
616 void wxTopLevelWindowMSW::Iconize(bool iconize
)
618 DoShowWindow(iconize
? SW_MINIMIZE
: SW_RESTORE
);
621 bool wxTopLevelWindowMSW::IsIconized() const
626 // also update the current state
627 ((wxTopLevelWindowMSW
*)this)->m_iconized
= ::IsIconic(GetHwnd()) != 0;
633 void wxTopLevelWindowMSW::Restore()
635 DoShowWindow(SW_RESTORE
);
638 // ----------------------------------------------------------------------------
639 // wxTopLevelWindowMSW fullscreen
640 // ----------------------------------------------------------------------------
642 bool wxTopLevelWindowMSW::ShowFullScreen(bool show
, long style
)
644 if ( show
== IsFullScreen() )
650 m_fsIsShowing
= show
;
656 // zap the frame borders
658 // save the 'normal' window style
659 m_fsOldWindowStyle
= GetWindowLong(GetHwnd(), GWL_STYLE
);
661 // save the old position, width & height, maximize state
662 m_fsOldSize
= GetRect();
663 m_fsIsMaximized
= IsMaximized();
665 // decide which window style flags to turn off
666 LONG newStyle
= m_fsOldWindowStyle
;
669 if (style
& wxFULLSCREEN_NOBORDER
)
671 offFlags
|= WS_BORDER
;
673 offFlags
|= WS_THICKFRAME
;
676 if (style
& wxFULLSCREEN_NOCAPTION
)
677 offFlags
|= WS_CAPTION
| WS_SYSMENU
;
679 newStyle
&= ~offFlags
;
681 // change our window style to be compatible with full-screen mode
682 ::SetWindowLong(GetHwnd(), GWL_STYLE
, newStyle
);
686 // resize to the size of the display containing us
687 int dpy
= wxDisplay::GetFromWindow(this);
688 if ( dpy
!= wxNOT_FOUND
)
690 rect
= wxDisplay(dpy
).GetGeometry();
692 else // fall back to the main desktop
693 #else // wxUSE_DISPLAY
695 // FIXME: implement for WinCE
697 // resize to the size of the desktop
698 wxCopyRECTToRect(wxGetWindowRect(::GetDesktopWindow()), rect
);
701 #endif // wxUSE_DISPLAY
705 // now flush the window style cache and actually go full-screen
706 long flags
= SWP_FRAMECHANGED
;
708 // showing the frame full screen should also show it if it's still
712 // don't call wxWindow version to avoid flicker from calling
713 // ::ShowWindow() -- we're going to show the window at the correct
714 // location directly below -- but do call the wxWindowBase version
715 // to sync the internal m_isShown flag
716 wxWindowBase::Show();
718 flags
|= SWP_SHOWWINDOW
;
721 SetWindowPos(GetHwnd(), HWND_TOP
,
722 rect
.x
, rect
.y
, rect
.width
, rect
.height
,
725 // finally send an event allowing the window to relayout itself &c
726 wxSizeEvent
event(rect
.GetSize(), GetId());
727 GetEventHandler()->ProcessEvent(event
);
729 else // stop showing full screen
731 Maximize(m_fsIsMaximized
);
732 SetWindowLong(GetHwnd(),GWL_STYLE
, m_fsOldWindowStyle
);
733 SetWindowPos(GetHwnd(),HWND_TOP
,m_fsOldSize
.x
, m_fsOldSize
.y
,
734 m_fsOldSize
.width
, m_fsOldSize
.height
, SWP_FRAMECHANGED
);
740 // ----------------------------------------------------------------------------
741 // wxTopLevelWindowMSW misc
742 // ----------------------------------------------------------------------------
744 void wxTopLevelWindowMSW::SetIcon(const wxIcon
& icon
)
746 SetIcons( wxIconBundle( icon
) );
749 void wxTopLevelWindowMSW::SetIcons(const wxIconBundle
& icons
)
751 wxTopLevelWindowBase::SetIcons(icons
);
753 #if defined(__WIN95__) && !defined(__WXMICROWIN__)
754 const wxIcon
& sml
= icons
.GetIcon( wxSize( 16, 16 ) );
755 if( sml
.Ok() && sml
.GetWidth() == 16 && sml
.GetHeight() == 16 )
757 ::SendMessage( GetHwndOf( this ), WM_SETICON
, ICON_SMALL
,
758 (LPARAM
)GetHiconOf(sml
) );
761 const wxIcon
& big
= icons
.GetIcon( wxSize( 32, 32 ) );
762 if( big
.Ok() && big
.GetWidth() == 32 && big
.GetHeight() == 32 )
764 ::SendMessage( GetHwndOf( this ), WM_SETICON
, ICON_BIG
,
765 (LPARAM
)GetHiconOf(big
) );
770 bool wxTopLevelWindowMSW::EnableCloseButton(bool enable
)
772 #if !defined(__WXMICROWIN__)
773 // get system (a.k.a. window) menu
774 HMENU hmenu
= GetSystemMenu(GetHwnd(), FALSE
/* get it */);
777 // no system menu at all -- ok if we want to remove the close button
778 // anyhow, but bad if we want to show it
782 // enabling/disabling the close item from it also automatically
783 // disables/enables the close title bar button
784 if ( ::EnableMenuItem(hmenu
, SC_CLOSE
,
786 (enable
? MF_ENABLED
: MF_GRAYED
)) == -1 )
788 wxLogLastError(_T("EnableMenuItem(SC_CLOSE)"));
793 // update appearance immediately
794 if ( !::DrawMenuBar(GetHwnd()) )
796 wxLogLastError(_T("DrawMenuBar"));
798 #endif // !__WXMICROWIN__
803 bool wxTopLevelWindowMSW::SetShape(const wxRegion
& region
)
808 wxCHECK_MSG( HasFlag(wxFRAME_SHAPED
), FALSE
,
809 _T("Shaped windows must be created with the wxFRAME_SHAPED style."));
811 // The empty region signifies that the shape should be removed from the
813 if ( region
.IsEmpty() )
815 if (::SetWindowRgn(GetHwnd(), NULL
, TRUE
) == 0)
817 wxLogLastError(_T("SetWindowRgn"));
823 // Windows takes ownership of the region, so
824 // we'll have to make a copy of the region to give to it.
825 DWORD noBytes
= ::GetRegionData(GetHrgnOf(region
), 0, NULL
);
826 RGNDATA
*rgnData
= (RGNDATA
*) new char[noBytes
];
827 ::GetRegionData(GetHrgnOf(region
), noBytes
, rgnData
);
828 HRGN hrgn
= ::ExtCreateRegion(NULL
, noBytes
, rgnData
);
829 delete[] (char*) rgnData
;
831 // SetWindowRgn expects the region to be in coordinants
832 // relative to the window, not the client area. Figure
833 // out the offset, if any.
835 DWORD dwStyle
= ::GetWindowLong(GetHwnd(), GWL_STYLE
);
836 DWORD dwExStyle
= ::GetWindowLong(GetHwnd(), GWL_EXSTYLE
);
837 ::GetClientRect(GetHwnd(), &rect
);
838 ::AdjustWindowRectEx(&rect
, dwStyle
, FALSE
, dwExStyle
);
839 ::OffsetRgn(hrgn
, -rect
.left
, -rect
.top
);
841 // Now call the shape API with the new region.
842 if (::SetWindowRgn(GetHwnd(), hrgn
, TRUE
) == 0)
844 wxLogLastError(_T("SetWindowRgn"));
851 // ----------------------------------------------------------------------------
852 // wxTopLevelWindow event handling
853 // ----------------------------------------------------------------------------
855 // Default activation behaviour - set the focus for the first child
857 void wxTopLevelWindowMSW::OnActivate(wxActivateEvent
& event
)
859 if ( event
.GetActive() )
861 // restore focus to the child which was last focused
862 wxLogTrace(_T("focus"), _T("wxTLW %08x activated."), (int) m_hWnd
);
864 wxWindow
*parent
= m_winLastFocused
? m_winLastFocused
->GetParent()
871 wxSetFocusToChild(parent
, &m_winLastFocused
);
875 // remember the last focused child if it is our child
876 m_winLastFocused
= FindFocus();
878 if ( m_winLastFocused
)
880 // let it know that it doesn't have focus any more
881 m_winLastFocused
->HandleKillFocus((WXHWND
)NULL
);
884 // so we NULL it out if it's a child from some other frame
885 wxWindow
*win
= m_winLastFocused
;
888 if ( win
->IsTopLevel() )
892 m_winLastFocused
= NULL
;
898 win
= win
->GetParent();
901 wxLogTrace(_T("focus"),
902 _T("wxTLW %08x deactivated, last focused: %08x."),
904 (int) (m_winLastFocused
? GetHwndOf(m_winLastFocused
)
911 // the DialogProc for all wxWindows dialogs
912 LONG APIENTRY _EXPORT
913 wxDlgProc(HWND
WXUNUSED(hDlg
),
915 WPARAM
WXUNUSED(wParam
),
916 LPARAM
WXUNUSED(lParam
))
921 // for this message, returning TRUE tells system to set focus to
922 // the first control in the dialog box, but as we set the focus
923 // ourselves, we return FALSE from here as well, so fall through
926 // for all the other ones, FALSE means that we didn't process the
932 // ============================================================================
933 // wxTLWHiddenParentModule implementation
934 // ============================================================================
936 HWND
wxTLWHiddenParentModule::ms_hwnd
= NULL
;
938 const wxChar
*wxTLWHiddenParentModule::ms_className
= NULL
;
940 bool wxTLWHiddenParentModule::OnInit()
948 void wxTLWHiddenParentModule::OnExit()
952 if ( !::DestroyWindow(ms_hwnd
) )
954 wxLogLastError(_T("DestroyWindow(hidden TLW parent)"));
962 if ( !::UnregisterClass(ms_className
, wxGetInstance()) )
964 wxLogLastError(_T("UnregisterClass(\"wxTLWHiddenParent\")"));
972 HWND
wxTLWHiddenParentModule::GetHWND()
978 static const wxChar
*HIDDEN_PARENT_CLASS
= _T("wxTLWHiddenParent");
981 wxZeroMemory(wndclass
);
983 wndclass
.lpfnWndProc
= DefWindowProc
;
984 wndclass
.hInstance
= wxGetInstance();
985 wndclass
.lpszClassName
= HIDDEN_PARENT_CLASS
;
987 if ( !::RegisterClass(&wndclass
) )
989 wxLogLastError(_T("RegisterClass(\"wxTLWHiddenParent\")"));
993 ms_className
= HIDDEN_PARENT_CLASS
;
997 ms_hwnd
= ::CreateWindow(ms_className
, wxEmptyString
, 0, 0, 0, 0, 0, NULL
,
998 (HMENU
)NULL
, wxGetInstance(), NULL
);
1001 wxLogLastError(_T("CreateWindow(hidden TLW parent)"));