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"
46 #include "wx/display.h"
56 // ----------------------------------------------------------------------------
57 // stubs for missing functions under MicroWindows
58 // ----------------------------------------------------------------------------
62 // static inline bool IsIconic(HWND WXUNUSED(hwnd)) { return FALSE; }
63 static inline bool IsZoomed(HWND
WXUNUSED(hwnd
)) { return FALSE
; }
65 #endif // __WXMICROWIN__
67 // NB: wxDlgProc must be defined here and not in dialog.cpp because the latter
68 // is not included by wxUniv build which does need wxDlgProc
70 wxDlgProc(HWND hDlg
, UINT message
, WPARAM wParam
, LPARAM lParam
);
72 // ----------------------------------------------------------------------------
74 // ----------------------------------------------------------------------------
76 // list of all frames and modeless dialogs
77 wxWindowList wxModelessWindows
;
79 // the name of the default wxWindows class
80 extern const wxChar
*wxCanvasClassName
;
82 // ----------------------------------------------------------------------------
83 // wxTLWHiddenParentModule: used to manage the hidden parent window (we need a
84 // module to ensure that the window is always deleted)
85 // ----------------------------------------------------------------------------
87 class wxTLWHiddenParentModule
: public wxModule
90 // module init/finalize
91 virtual bool OnInit();
92 virtual void OnExit();
94 // get the hidden window (creates on demand)
95 static HWND
GetHWND();
98 // the HWND of the hidden parent
101 // the class used to create it
102 static const wxChar
*ms_className
;
104 DECLARE_DYNAMIC_CLASS(wxTLWHiddenParentModule
)
107 IMPLEMENT_DYNAMIC_CLASS(wxTLWHiddenParentModule
, wxModule
)
109 // ============================================================================
110 // wxTopLevelWindowMSW implementation
111 // ============================================================================
113 BEGIN_EVENT_TABLE(wxTopLevelWindowMSW
, wxTopLevelWindowBase
)
114 EVT_ACTIVATE(wxTopLevelWindowMSW::OnActivate
)
117 // ----------------------------------------------------------------------------
118 // wxTopLevelWindowMSW creation
119 // ----------------------------------------------------------------------------
121 void wxTopLevelWindowMSW::Init()
124 m_maximizeOnShow
= FALSE
;
126 // unlike (almost?) all other windows, frames are created hidden
129 // Data to save/restore when calling ShowFullScreen
131 m_fsOldWindowStyle
= 0;
132 m_fsIsMaximized
= FALSE
;
133 m_fsIsShowing
= FALSE
;
135 m_winLastFocused
= (wxWindow
*)NULL
;
138 WXDWORD
wxTopLevelWindowMSW::MSWGetStyle(long style
, WXDWORD
*exflags
) const
140 // let the base class deal with the common styles but fix the ones which
141 // don't make sense for us (we also deal with the borders ourselves)
142 WXDWORD msflags
= wxWindow::MSWGetStyle
144 (style
& ~wxBORDER_MASK
) | wxBORDER_NONE
, exflags
145 ) & ~WS_CHILD
& ~WS_VISIBLE
;
147 // first select the kind of window being created
149 // note that if we don't set WS_POPUP, Windows assumes WS_OVERLAPPED and
150 // creates a window with both caption and border, hence we also test it
151 // below in some other cases
152 if ( style
& wxFRAME_TOOL_WINDOW
)
157 if (msflags
& WS_BORDER
)
159 msflags
|= WS_OVERLAPPED
;
162 // border and caption styles
163 if ( style
& wxRESIZE_BORDER
)
166 msflags
|= WS_THICKFRAME
;
169 else if ( !(style
& wxBORDER_NONE
) )
170 msflags
|= WS_BORDER
;
176 if ( style
& wxCAPTION
)
177 msflags
|= WS_CAPTION
;
183 // next translate the individual flags
184 if ( style
& wxMINIMIZE_BOX
)
185 msflags
|= WS_MINIMIZEBOX
;
186 if ( style
& wxMAXIMIZE_BOX
)
187 msflags
|= WS_MAXIMIZEBOX
;
188 if ( style
& wxSYSTEM_MENU
)
189 msflags
|= WS_SYSMENU
;
191 if ( style
& wxMINIMIZE
)
192 msflags
|= WS_MINIMIZE
;
193 if ( style
& wxMAXIMIZE
)
194 msflags
|= WS_MAXIMIZE
;
197 // Keep this here because it saves recoding this function in wxTinyFrame
198 #if wxUSE_ITSY_BITSY && !defined(__WIN32__)
199 if ( style
& wxTINY_CAPTION_VERT
)
200 msflags
|= IBS_VERTCAPTION
;
201 if ( style
& wxTINY_CAPTION_HORIZ
)
202 msflags
|= IBS_HORZCAPTION
;
204 if ( style
& (wxTINY_CAPTION_VERT
| wxTINY_CAPTION_HORIZ
) )
205 msflags
|= WS_CAPTION
;
210 #if !defined(__WIN16__)
211 if ( !(GetExtraStyle() & wxTOPLEVEL_EX_DIALOG
) )
213 if ( style
& wxFRAME_TOOL_WINDOW
)
215 // create the palette-like window
216 *exflags
|= WS_EX_TOOLWINDOW
;
219 // We have to solve 2 different problems here:
221 // 1. frames with wxFRAME_NO_TASKBAR flag shouldn't appear in the
222 // taskbar even if they don't have a parent
224 // 2. frames without this style should appear in the taskbar even
225 // if they're owned (Windows only puts non owned windows into
226 // the taskbar normally)
228 // The second one is solved here by using WS_EX_APPWINDOW flag, the
229 // first one is dealt with in our MSWGetParent() method
232 if ( !(style
& wxFRAME_NO_TASKBAR
) && GetParent() )
234 // need to force the frame to appear in the taskbar
235 *exflags
|= WS_EX_APPWINDOW
;
238 //else: nothing to do [here]
242 if ( style
& wxSTAY_ON_TOP
)
243 *exflags
|= WS_EX_TOPMOST
;
246 if ( GetExtraStyle() & wxFRAME_EX_CONTEXTHELP
)
247 *exflags
|= WS_EX_CONTEXTHELP
;
254 WXHWND
wxTopLevelWindowMSW::MSWGetParent() const
256 // for the frames without wxFRAME_FLOAT_ON_PARENT style we should use NULL
257 // parent HWND or it would be always on top of its parent which is not what
258 // we usually want (in fact, we only want it for frames with the
259 // wxFRAME_FLOAT_ON_PARENT flag)
260 HWND hwndParent
= NULL
;
261 if ( HasFlag(wxFRAME_FLOAT_ON_PARENT
) )
263 const wxWindow
*parent
= GetParent();
267 // this flag doesn't make sense then and will be ignored
268 wxFAIL_MSG( _T("wxFRAME_FLOAT_ON_PARENT but no parent?") );
272 hwndParent
= GetHwndOf(parent
);
275 //else: don't float on parent, must not be owned
277 // now deal with the 2nd taskbar-related problem (see comments above in
279 if ( HasFlag(wxFRAME_NO_TASKBAR
) && !hwndParent
)
282 hwndParent
= wxTLWHiddenParentModule::GetHWND();
285 return (WXHWND
)hwndParent
;
288 bool wxTopLevelWindowMSW::CreateDialog(const void *dlgTemplate
,
289 const wxString
& title
,
293 #ifdef __WXMICROWIN__
294 // no dialogs support under MicroWin yet
295 return CreateFrame(title
, pos
, size
);
296 #else // !__WXMICROWIN__
297 wxWindow
*parent
= GetParent();
299 // for the dialogs without wxDIALOG_NO_PARENT style, use the top level
300 // app window as parent - this avoids creating modal dialogs without
302 if ( !parent
&& !(GetWindowStyleFlag() & wxDIALOG_NO_PARENT
) )
304 parent
= wxTheApp
->GetTopWindow();
308 // don't use transient windows as parents, this is dangerous as it
309 // can lead to a crash if the parent is destroyed before the child
311 // also don't use the window which is currently hidden as then the
312 // dialog would be hidden as well
313 if ( (parent
->GetExtraStyle() & wxWS_EX_TRANSIENT
) ||
321 m_hWnd
= (WXHWND
)::CreateDialogIndirect
324 (DLGTEMPLATE
*)dlgTemplate
,
325 parent
? GetHwndOf(parent
) : NULL
,
331 wxFAIL_MSG(wxT("Failed to create dialog. Incorrect DLGTEMPLATE?"));
333 wxLogSysError(wxT("Can't create dialog using memory template"));
339 (void)MSWGetCreateWindowFlags(&exflags
);
343 ::SetWindowLong(GetHwnd(), GWL_EXSTYLE
, exflags
);
344 ::SetWindowPos(GetHwnd(),
345 exflags
& WS_EX_TOPMOST
? HWND_TOPMOST
: 0,
349 (exflags
& WS_EX_TOPMOST
? 0 : SWP_NOZORDER
) |
353 #if defined(__WIN95__)
354 // For some reason, the system menu is activated when we use the
355 // WS_EX_CONTEXTHELP style, so let's set a reasonable icon
356 if ( exflags
& WS_EX_CONTEXTHELP
)
358 wxFrame
*winTop
= wxDynamicCast(wxTheApp
->GetTopWindow(), wxFrame
);
361 wxIcon icon
= winTop
->GetIcon();
364 ::SendMessage(GetHwnd(), WM_SETICON
,
366 (LPARAM
)GetHiconOf(icon
));
372 // move the dialog to its initial position without forcing repainting
374 if ( !MSWGetCreateWindowCoords(pos
, size
, x
, y
, w
, h
) )
377 w
= (int)CW_USEDEFAULT
;
380 // we can't use CW_USEDEFAULT here as we're not calling CreateWindow()
381 // and passing CW_USEDEFAULT to MoveWindow() results in resizing the
382 // window to (0, 0) size which breaks quite a lot of things, e.g. the
383 // sizer calculation in wxSizer::Fit()
384 if ( w
== (int)CW_USEDEFAULT
)
386 // the exact number doesn't matter, the dialog will be resized
387 // again soon anyhow but it should be big enough to allow
388 // calculation relying on "totalSize - clientSize > 0" work, i.e.
389 // at least greater than the title bar height
394 if ( x
== (int)CW_USEDEFAULT
)
396 // centre it on the screen - what else can we do?
397 wxSize sizeDpy
= wxGetDisplaySize();
399 x
= (sizeDpy
.x
- w
) / 2;
400 y
= (sizeDpy
.y
- h
) / 2;
403 if ( !::MoveWindow(GetHwnd(), x
, y
, w
, h
, FALSE
) )
405 wxLogLastError(wxT("MoveWindow"));
408 if ( !title
.empty() )
410 ::SetWindowText(GetHwnd(), title
);
416 #endif // __WXMICROWIN__/!__WXMICROWIN__
419 bool wxTopLevelWindowMSW::CreateFrame(const wxString
& title
,
424 WXDWORD flags
= MSWGetCreateWindowFlags(&exflags
);
426 return MSWCreate(wxCanvasClassName
, title
, pos
, size
, flags
, exflags
);
429 bool wxTopLevelWindowMSW::Create(wxWindow
*parent
,
431 const wxString
& title
,
435 const wxString
& name
)
442 m_windowStyle
= style
;
446 m_windowId
= id
== -1 ? NewControlId() : id
;
448 wxTopLevelWindows
.Append(this);
451 parent
->AddChild(this);
453 if ( GetExtraStyle() & wxTOPLEVEL_EX_DIALOG
)
455 // we have different dialog templates to allows creation of dialogs
456 // with & without captions under MSWindows, resizeable or not (but a
457 // resizeable dialog always has caption - otherwise it would look too
460 // we need 3 additional WORDs for dialog menu, class and title (as we
461 // don't use DS_SETFONT we don't need the fourth WORD for the font)
462 static const int dlgsize
= sizeof(DLGTEMPLATE
) + (sizeof(WORD
) * 3);
463 DLGTEMPLATE
*dlgTemplate
= (DLGTEMPLATE
*)malloc(dlgsize
);
464 memset(dlgTemplate
, 0, dlgsize
);
466 // these values are arbitrary, they won't be used normally anyhow
469 dlgTemplate
->cx
= 144;
470 dlgTemplate
->cy
= 75;
472 // reuse the code in MSWGetStyle() but correct the results slightly for
474 dlgTemplate
->style
= MSWGetStyle(style
, NULL
);
476 // all dialogs are popups
477 dlgTemplate
->style
|= WS_POPUP
;
479 // force 3D-look if necessary, it looks impossibly ugly otherwise
480 if ( style
& (wxRESIZE_BORDER
| wxCAPTION
) )
481 dlgTemplate
->style
|= DS_MODALFRAME
;
483 ret
= CreateDialog(dlgTemplate
, title
, pos
, size
);
488 ret
= CreateFrame(title
, pos
, size
);
491 if ( ret
&& !(GetWindowStyleFlag() & wxCLOSE_BOX
) )
493 EnableCloseButton(false);
499 wxTopLevelWindowMSW::~wxTopLevelWindowMSW()
501 if ( wxModelessWindows
.Find(this) )
502 wxModelessWindows
.DeleteObject(this);
504 // after destroying an owned window, Windows activates the next top level
505 // window in Z order but it may be different from our owner (to reproduce
506 // this simply Alt-TAB to another application and back before closing the
507 // owned frame) whereas we always want to yield activation to our parent
508 if ( HasFlag(wxFRAME_FLOAT_ON_PARENT
) )
510 wxWindow
*parent
= GetParent();
513 ::BringWindowToTop(GetHwndOf(parent
));
518 // ----------------------------------------------------------------------------
519 // wxTopLevelWindowMSW showing
520 // ----------------------------------------------------------------------------
522 void wxTopLevelWindowMSW::DoShowWindow(int nShowCmd
)
524 ::ShowWindow(GetHwnd(), nShowCmd
);
526 m_iconized
= nShowCmd
== SW_MINIMIZE
;
529 bool wxTopLevelWindowMSW::Show(bool show
)
531 // don't use wxWindow version as we want to call DoShowWindow() ourselves
532 if ( !wxWindowBase::Show(show
) )
538 if ( m_maximizeOnShow
)
541 nShowCmd
= SW_MAXIMIZE
;
543 m_maximizeOnShow
= FALSE
;
547 if ( GetWindowStyle() & wxFRAME_TOOL_WINDOW
)
548 nShowCmd
= SW_SHOWNA
;
558 DoShowWindow(nShowCmd
);
562 ::BringWindowToTop(GetHwnd());
564 wxActivateEvent
event(wxEVT_ACTIVATE
, TRUE
, m_windowId
);
565 event
.SetEventObject( this );
566 GetEventHandler()->ProcessEvent(event
);
570 // Try to highlight the correct window (the parent)
573 HWND hWndParent
= GetHwndOf(GetParent());
575 ::BringWindowToTop(hWndParent
);
582 // ----------------------------------------------------------------------------
583 // wxTopLevelWindowMSW maximize/minimize
584 // ----------------------------------------------------------------------------
586 void wxTopLevelWindowMSW::Maximize(bool maximize
)
590 // just maximize it directly
591 DoShowWindow(maximize
? SW_MAXIMIZE
: SW_RESTORE
);
595 // we can't maximize the hidden frame because it shows it as well, so
596 // just remember that we should do it later in this case
597 m_maximizeOnShow
= maximize
;
601 bool wxTopLevelWindowMSW::IsMaximized() const
606 return ::IsZoomed(GetHwnd()) != 0;
610 void wxTopLevelWindowMSW::Iconize(bool iconize
)
612 DoShowWindow(iconize
? SW_MINIMIZE
: SW_RESTORE
);
615 bool wxTopLevelWindowMSW::IsIconized() const
620 // also update the current state
621 ((wxTopLevelWindowMSW
*)this)->m_iconized
= ::IsIconic(GetHwnd()) != 0;
627 void wxTopLevelWindowMSW::Restore()
629 DoShowWindow(SW_RESTORE
);
632 // ----------------------------------------------------------------------------
633 // wxTopLevelWindowMSW fullscreen
634 // ----------------------------------------------------------------------------
636 bool wxTopLevelWindowMSW::ShowFullScreen(bool show
, long style
)
638 if ( show
== IsFullScreen() )
644 m_fsIsShowing
= show
;
650 // zap the frame borders
652 // save the 'normal' window style
653 m_fsOldWindowStyle
= GetWindowLong(GetHwnd(), GWL_STYLE
);
655 // save the old position, width & height, maximize state
656 m_fsOldSize
= GetRect();
657 m_fsIsMaximized
= IsMaximized();
659 // decide which window style flags to turn off
660 LONG newStyle
= m_fsOldWindowStyle
;
663 if (style
& wxFULLSCREEN_NOBORDER
)
665 offFlags
|= WS_BORDER
;
667 offFlags
|= WS_THICKFRAME
;
670 if (style
& wxFULLSCREEN_NOCAPTION
)
671 offFlags
|= WS_CAPTION
| WS_SYSMENU
;
673 newStyle
&= ~offFlags
;
675 // change our window style to be compatible with full-screen mode
676 ::SetWindowLong(GetHwnd(), GWL_STYLE
, newStyle
);
680 // resize to the size of the display containing us
681 int dpy
= wxDisplay::GetFromWindow(this);
682 if ( dpy
!= wxNOT_FOUND
)
684 rect
= wxDisplay(dpy
).GetGeometry();
686 else // fall back to the main desktop
687 #else // wxUSE_DISPLAY
689 // FIXME: implement for WinCE
691 // resize to the size of the desktop
692 wxCopyRECTToRect(wxGetWindowRect(::GetDesktopWindow()), rect
);
695 #endif // wxUSE_DISPLAY
699 // now flush the window style cache and actually go full-screen
700 long flags
= SWP_FRAMECHANGED
;
702 // showing the frame full screen should also show it if it's still
706 // don't call wxWindow version to avoid flicker from calling
707 // ::ShowWindow() -- we're going to show the window at the correct
708 // location directly below -- but do call the wxWindowBase version
709 // to sync the internal m_isShown flag
710 wxWindowBase::Show();
712 flags
|= SWP_SHOWWINDOW
;
715 SetWindowPos(GetHwnd(), HWND_TOP
,
716 rect
.x
, rect
.y
, rect
.width
, rect
.height
,
719 // finally send an event allowing the window to relayout itself &c
720 wxSizeEvent
event(rect
.GetSize(), GetId());
721 GetEventHandler()->ProcessEvent(event
);
723 else // stop showing full screen
725 Maximize(m_fsIsMaximized
);
726 SetWindowLong(GetHwnd(),GWL_STYLE
, m_fsOldWindowStyle
);
727 SetWindowPos(GetHwnd(),HWND_TOP
,m_fsOldSize
.x
, m_fsOldSize
.y
,
728 m_fsOldSize
.width
, m_fsOldSize
.height
, SWP_FRAMECHANGED
);
734 // ----------------------------------------------------------------------------
735 // wxTopLevelWindowMSW misc
736 // ----------------------------------------------------------------------------
738 void wxTopLevelWindowMSW::SetIcon(const wxIcon
& icon
)
740 SetIcons( wxIconBundle( icon
) );
743 void wxTopLevelWindowMSW::SetIcons(const wxIconBundle
& icons
)
745 wxTopLevelWindowBase::SetIcons(icons
);
747 #if defined(__WIN95__) && !defined(__WXMICROWIN__)
748 const wxIcon
& sml
= icons
.GetIcon( wxSize( 16, 16 ) );
749 if( sml
.Ok() && sml
.GetWidth() == 16 && sml
.GetHeight() == 16 )
751 ::SendMessage( GetHwndOf( this ), WM_SETICON
, ICON_SMALL
,
752 (LPARAM
)GetHiconOf(sml
) );
755 const wxIcon
& big
= icons
.GetIcon( wxSize( 32, 32 ) );
756 if( big
.Ok() && big
.GetWidth() == 32 && big
.GetHeight() == 32 )
758 ::SendMessage( GetHwndOf( this ), WM_SETICON
, ICON_BIG
,
759 (LPARAM
)GetHiconOf(big
) );
764 bool wxTopLevelWindowMSW::EnableCloseButton(bool enable
)
766 #if !defined(__WXMICROWIN__)
767 // get system (a.k.a. window) menu
768 HMENU hmenu
= GetSystemMenu(GetHwnd(), FALSE
/* get it */);
771 // no system menu at all -- ok if we want to remove the close button
772 // anyhow, but bad if we want to show it
776 // enabling/disabling the close item from it also automatically
777 // disables/enables the close title bar button
778 if ( ::EnableMenuItem(hmenu
, SC_CLOSE
,
780 (enable
? MF_ENABLED
: MF_GRAYED
)) == -1 )
782 wxLogLastError(_T("EnableMenuItem(SC_CLOSE)"));
787 // update appearance immediately
788 if ( !::DrawMenuBar(GetHwnd()) )
790 wxLogLastError(_T("DrawMenuBar"));
792 #endif // !__WXMICROWIN__
797 bool wxTopLevelWindowMSW::SetShape(const wxRegion
& region
)
802 wxCHECK_MSG( HasFlag(wxFRAME_SHAPED
), FALSE
,
803 _T("Shaped windows must be created with the wxFRAME_SHAPED style."));
805 // The empty region signifies that the shape should be removed from the
807 if ( region
.IsEmpty() )
809 if (::SetWindowRgn(GetHwnd(), NULL
, TRUE
) == 0)
811 wxLogLastError(_T("SetWindowRgn"));
817 // Windows takes ownership of the region, so
818 // we'll have to make a copy of the region to give to it.
819 DWORD noBytes
= ::GetRegionData(GetHrgnOf(region
), 0, NULL
);
820 RGNDATA
*rgnData
= (RGNDATA
*) new char[noBytes
];
821 ::GetRegionData(GetHrgnOf(region
), noBytes
, rgnData
);
822 HRGN hrgn
= ::ExtCreateRegion(NULL
, noBytes
, rgnData
);
823 delete[] (char*) rgnData
;
825 // SetWindowRgn expects the region to be in coordinants
826 // relative to the window, not the client area. Figure
827 // out the offset, if any.
829 DWORD dwStyle
= ::GetWindowLong(GetHwnd(), GWL_STYLE
);
830 DWORD dwExStyle
= ::GetWindowLong(GetHwnd(), GWL_EXSTYLE
);
831 ::GetClientRect(GetHwnd(), &rect
);
832 ::AdjustWindowRectEx(&rect
, dwStyle
, FALSE
, dwExStyle
);
833 ::OffsetRgn(hrgn
, -rect
.left
, -rect
.top
);
835 // Now call the shape API with the new region.
836 if (::SetWindowRgn(GetHwnd(), hrgn
, TRUE
) == 0)
838 wxLogLastError(_T("SetWindowRgn"));
845 // ----------------------------------------------------------------------------
846 // wxTopLevelWindow event handling
847 // ----------------------------------------------------------------------------
849 // Default activation behaviour - set the focus for the first child
851 void wxTopLevelWindowMSW::OnActivate(wxActivateEvent
& event
)
853 if ( event
.GetActive() )
855 // restore focus to the child which was last focused
856 wxLogTrace(_T("focus"), _T("wxTLW %08x activated."), (int) m_hWnd
);
858 wxWindow
*parent
= m_winLastFocused
? m_winLastFocused
->GetParent()
865 wxSetFocusToChild(parent
, &m_winLastFocused
);
869 // remember the last focused child if it is our child
870 m_winLastFocused
= FindFocus();
872 if ( m_winLastFocused
)
874 // let it know that it doesn't have focus any more
875 m_winLastFocused
->HandleKillFocus((WXHWND
)NULL
);
878 // so we NULL it out if it's a child from some other frame
879 wxWindow
*win
= m_winLastFocused
;
882 if ( win
->IsTopLevel() )
886 m_winLastFocused
= NULL
;
892 win
= win
->GetParent();
895 wxLogTrace(_T("focus"),
896 _T("wxTLW %08x deactivated, last focused: %08x."),
898 (int) (m_winLastFocused
? GetHwndOf(m_winLastFocused
)
905 // the DialogProc for all wxWindows dialogs
906 LONG APIENTRY _EXPORT
907 wxDlgProc(HWND
WXUNUSED(hDlg
),
909 WPARAM
WXUNUSED(wParam
),
910 LPARAM
WXUNUSED(lParam
))
915 // for this message, returning TRUE tells system to set focus to
916 // the first control in the dialog box, but as we set the focus
917 // ourselves, we return FALSE from here as well, so fall through
920 // for all the other ones, FALSE means that we didn't process the
926 // ============================================================================
927 // wxTLWHiddenParentModule implementation
928 // ============================================================================
930 HWND
wxTLWHiddenParentModule::ms_hwnd
= NULL
;
932 const wxChar
*wxTLWHiddenParentModule::ms_className
= NULL
;
934 bool wxTLWHiddenParentModule::OnInit()
942 void wxTLWHiddenParentModule::OnExit()
946 if ( !::DestroyWindow(ms_hwnd
) )
948 wxLogLastError(_T("DestroyWindow(hidden TLW parent)"));
956 if ( !::UnregisterClass(ms_className
, wxGetInstance()) )
958 wxLogLastError(_T("UnregisterClass(\"wxTLWHiddenParent\")"));
966 HWND
wxTLWHiddenParentModule::GetHWND()
972 static const wxChar
*HIDDEN_PARENT_CLASS
= _T("wxTLWHiddenParent");
975 wxZeroMemory(wndclass
);
977 wndclass
.lpfnWndProc
= DefWindowProc
;
978 wndclass
.hInstance
= wxGetInstance();
979 wndclass
.lpszClassName
= HIDDEN_PARENT_CLASS
;
981 if ( !::RegisterClass(&wndclass
) )
983 wxLogLastError(_T("RegisterClass(\"wxTLWHiddenParent\")"));
987 ms_className
= HIDDEN_PARENT_CLASS
;
991 ms_hwnd
= ::CreateWindow(ms_className
, wxEmptyString
, 0, 0, 0, 0, 0, NULL
,
992 (HMENU
)NULL
, wxGetInstance(), NULL
);
995 wxLogLastError(_T("CreateWindow(hidden TLW parent)"));