]> git.saurik.com Git - wxWidgets.git/blob - src/msw/toplevel.cpp
17392121160a0d1d9f3b05e74f7d948fd12fb69c
[wxWidgets.git] / src / msw / toplevel.cpp
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: src/msw/toplevel.cpp
3 // Purpose: implements wxTopLevelWindow for MSW
4 // Author: Vadim Zeitlin
5 // Modified by:
6 // Created: 24.09.01
7 // RCS-ID: $Id$
8 // Copyright: (c) 2001 SciTech Software, Inc. (www.scitechsoft.com)
9 // License: wxWindows licence
10 ///////////////////////////////////////////////////////////////////////////////
11
12 // ============================================================================
13 // declarations
14 // ============================================================================
15
16 // ----------------------------------------------------------------------------
17 // headers
18 // ----------------------------------------------------------------------------
19
20 // For compilers that support precompilation, includes "wx.h".
21 #include "wx/wxprec.h"
22
23 #ifdef __BORLANDC__
24 #pragma hdrstop
25 #endif
26
27 #include "wx/toplevel.h"
28
29 #ifndef WX_PRECOMP
30 #include "wx/app.h"
31 #include "wx/dialog.h"
32 #include "wx/string.h"
33 #include "wx/log.h"
34 #include "wx/intl.h"
35 #include "wx/frame.h"
36 #include "wx/containr.h" // wxSetFocusToChild()
37 #include "wx/module.h"
38 #endif //WX_PRECOMP
39
40 #include "wx/dynlib.h"
41
42 #include "wx/msw/private.h"
43 #if defined(__WXWINCE__) && !defined(__HANDHELDPC__)
44 #include <ole2.h>
45 #include <shellapi.h>
46 // Standard SDK doesn't have aygshell.dll: see include/wx/msw/wince/libraries.h
47 #if _WIN32_WCE < 400 || !defined(__WINCE_STANDARDSDK__)
48 #include <aygshell.h>
49 #endif
50 #endif
51
52 #include "wx/msw/winundef.h"
53 #include "wx/msw/missing.h"
54
55 #include "wx/display.h"
56
57 #ifndef ICON_BIG
58 #define ICON_BIG 1
59 #endif
60
61 #ifndef ICON_SMALL
62 #define ICON_SMALL 0
63 #endif
64
65 // ----------------------------------------------------------------------------
66 // stubs for missing functions under MicroWindows
67 // ----------------------------------------------------------------------------
68
69 #ifdef __WXMICROWIN__
70
71 // static inline bool IsIconic(HWND WXUNUSED(hwnd)) { return false; }
72 static inline bool IsZoomed(HWND WXUNUSED(hwnd)) { return false; }
73
74 #endif // __WXMICROWIN__
75
76 // NB: wxDlgProc must be defined here and not in dialog.cpp because the latter
77 // is not included by wxUniv build which does need wxDlgProc
78 LONG APIENTRY _EXPORT
79 wxDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam);
80
81 // ----------------------------------------------------------------------------
82 // wxTLWHiddenParentModule: used to manage the hidden parent window (we need a
83 // module to ensure that the window is always deleted)
84 // ----------------------------------------------------------------------------
85
86 class wxTLWHiddenParentModule : public wxModule
87 {
88 public:
89 // module init/finalize
90 virtual bool OnInit();
91 virtual void OnExit();
92
93 // get the hidden window (creates on demand)
94 static HWND GetHWND();
95
96 private:
97 // the HWND of the hidden parent
98 static HWND ms_hwnd;
99
100 // the class used to create it
101 static const wxChar *ms_className;
102
103 DECLARE_DYNAMIC_CLASS(wxTLWHiddenParentModule)
104 };
105
106 IMPLEMENT_DYNAMIC_CLASS(wxTLWHiddenParentModule, wxModule)
107
108 // ============================================================================
109 // wxTopLevelWindowMSW implementation
110 // ============================================================================
111
112 BEGIN_EVENT_TABLE(wxTopLevelWindowMSW, wxTopLevelWindowBase)
113 EVT_ACTIVATE(wxTopLevelWindowMSW::OnActivate)
114 END_EVENT_TABLE()
115
116 // ----------------------------------------------------------------------------
117 // wxTopLevelWindowMSW creation
118 // ----------------------------------------------------------------------------
119
120 void wxTopLevelWindowMSW::Init()
121 {
122 m_iconized =
123 m_maximizeOnShow = false;
124
125 // Data to save/restore when calling ShowFullScreen
126 m_fsStyle = 0;
127 m_fsOldWindowStyle = 0;
128 m_fsIsMaximized = false;
129 m_fsIsShowing = false;
130
131 m_winLastFocused = NULL;
132
133 #if defined(__SMARTPHONE__) && defined(__WXWINCE__)
134 m_MenuBarHWND = 0;
135 #endif
136
137 #if defined(__SMARTPHONE__) || defined(__POCKETPC__)
138 SHACTIVATEINFO* info = new SHACTIVATEINFO;
139 wxZeroMemory(*info);
140 info->cbSize = sizeof(SHACTIVATEINFO);
141
142 m_activateInfo = (void*) info;
143 #endif
144 }
145
146 WXDWORD wxTopLevelWindowMSW::MSWGetStyle(long style, WXDWORD *exflags) const
147 {
148 // let the base class deal with the common styles but fix the ones which
149 // don't make sense for us (we also deal with the borders ourselves)
150 WXDWORD msflags = wxWindow::MSWGetStyle
151 (
152 (style & ~wxBORDER_MASK) | wxBORDER_NONE, exflags
153 ) & ~WS_CHILD & ~WS_VISIBLE;
154
155 // For some reason, WS_VISIBLE needs to be defined on creation for
156 // SmartPhone 2003. The title can fail to be displayed otherwise.
157 #if defined(__SMARTPHONE__) || (defined(__WXWINCE__) && _WIN32_WCE < 400)
158 msflags |= WS_VISIBLE;
159 ((wxTopLevelWindowMSW*)this)->wxWindowBase::Show(true);
160 #endif
161
162 // first select the kind of window being created
163 //
164 // note that if we don't set WS_POPUP, Windows assumes WS_OVERLAPPED and
165 // creates a window with both caption and border, hence we need to use
166 // WS_POPUP in a few cases just to avoid having caption/border which we
167 // don't want
168
169 // border and caption styles
170 if ( ( style & wxRESIZE_BORDER ) && !IsAlwaysMaximized())
171 msflags |= WS_THICKFRAME;
172 else if ( exflags && ((style & wxBORDER_DOUBLE) || (style & wxBORDER_RAISED)) )
173 *exflags |= WS_EX_DLGMODALFRAME;
174 else if ( !(style & wxBORDER_NONE) )
175 msflags |= WS_BORDER;
176 #ifndef __POCKETPC__
177 else
178 msflags |= WS_POPUP;
179 #endif
180
181 // normally we consider that all windows without a caption must be popups,
182 // but CE is an exception: there windows normally do not have the caption
183 // but shouldn't be made popups as popups can't have menus and don't look
184 // like normal windows anyhow
185
186 // TODO: Smartphone appears to like wxCAPTION, but we should check that
187 // we need it.
188 #if defined(__SMARTPHONE__) || !defined(__WXWINCE__)
189 if ( style & wxCAPTION )
190 msflags |= WS_CAPTION;
191 #ifndef __WXWINCE__
192 else
193 msflags |= WS_POPUP;
194 #endif // !__WXWINCE__
195 #endif
196
197 // next translate the individual flags
198
199 // WS_EX_CONTEXTHELP is incompatible with WS_MINIMIZEBOX and WS_MAXIMIZEBOX
200 // and is ignored if we specify both of them, but chances are that if we
201 // use wxWS_EX_CONTEXTHELP, we really do want to have the context help
202 // button while wxMINIMIZE/wxMAXIMIZE are included by default, so the help
203 // takes precedence
204 if ( !(GetExtraStyle() & wxWS_EX_CONTEXTHELP) )
205 {
206 if ( style & wxMINIMIZE_BOX )
207 msflags |= WS_MINIMIZEBOX;
208 if ( style & wxMAXIMIZE_BOX )
209 msflags |= WS_MAXIMIZEBOX;
210 }
211
212 #ifndef __WXWINCE__
213 // notice that if wxCLOSE_BOX is specified we need to use WS_SYSMENU too as
214 // otherwise the close box doesn't appear
215 if ( style & (wxSYSTEM_MENU | wxCLOSE_BOX) )
216 msflags |= WS_SYSMENU;
217 #endif // !__WXWINCE__
218
219 // NB: under CE these 2 styles are not supported currently, we should
220 // call Minimize()/Maximize() "manually" if we want to support them
221 if ( style & wxMINIMIZE )
222 msflags |= WS_MINIMIZE;
223
224 if ( style & wxMAXIMIZE )
225 msflags |= WS_MAXIMIZE;
226
227 // Keep this here because it saves recoding this function in wxTinyFrame
228 if ( style & (wxTINY_CAPTION_VERT | wxTINY_CAPTION_HORIZ) )
229 msflags |= WS_CAPTION;
230
231 if ( exflags )
232 {
233 // there is no taskbar under CE, so omit all this
234 #if !defined(__WXWINCE__)
235 if ( !(GetExtraStyle() & wxTOPLEVEL_EX_DIALOG) )
236 {
237 if ( style & wxFRAME_TOOL_WINDOW )
238 {
239 // create the palette-like window
240 *exflags |= WS_EX_TOOLWINDOW;
241
242 // tool windows shouldn't appear on the taskbar (as documented)
243 style |= wxFRAME_NO_TASKBAR;
244 }
245
246 // We have to solve 2 different problems here:
247 //
248 // 1. frames with wxFRAME_NO_TASKBAR flag shouldn't appear in the
249 // taskbar even if they don't have a parent
250 //
251 // 2. frames without this style should appear in the taskbar even
252 // if they're owned (Windows only puts non owned windows into
253 // the taskbar normally)
254 //
255 // The second one is solved here by using WS_EX_APPWINDOW flag, the
256 // first one is dealt with in our MSWGetParent() method
257 // implementation
258 if ( !(style & wxFRAME_NO_TASKBAR) && GetParent() )
259 {
260 // need to force the frame to appear in the taskbar
261 *exflags |= WS_EX_APPWINDOW;
262 }
263 //else: nothing to do [here]
264 }
265
266 if ( GetExtraStyle() & wxWS_EX_CONTEXTHELP )
267 *exflags |= WS_EX_CONTEXTHELP;
268 #endif // !__WXWINCE__
269
270 if ( style & wxSTAY_ON_TOP )
271 *exflags |= WS_EX_TOPMOST;
272 }
273
274 return msflags;
275 }
276
277 WXHWND wxTopLevelWindowMSW::MSWGetParent() const
278 {
279 // for the frames without wxFRAME_FLOAT_ON_PARENT style we should use NULL
280 // parent HWND or it would be always on top of its parent which is not what
281 // we usually want (in fact, we only want it for frames with the
282 // wxFRAME_FLOAT_ON_PARENT flag)
283 HWND hwndParent = NULL;
284 if ( HasFlag(wxFRAME_FLOAT_ON_PARENT) )
285 {
286 const wxWindow *parent = GetParent();
287
288 if ( !parent )
289 {
290 // this flag doesn't make sense then and will be ignored
291 wxFAIL_MSG( _T("wxFRAME_FLOAT_ON_PARENT but no parent?") );
292 }
293 else
294 {
295 hwndParent = GetHwndOf(parent);
296 }
297 }
298 //else: don't float on parent, must not be owned
299
300 // now deal with the 2nd taskbar-related problem (see comments above in
301 // MSWGetStyle())
302 if ( HasFlag(wxFRAME_NO_TASKBAR) && !hwndParent )
303 {
304 // use hidden parent
305 hwndParent = wxTLWHiddenParentModule::GetHWND();
306 }
307
308 return (WXHWND)hwndParent;
309 }
310
311 #if defined(__SMARTPHONE__) || defined(__POCKETPC__)
312 bool wxTopLevelWindowMSW::HandleSettingChange(WXWPARAM wParam, WXLPARAM lParam)
313 {
314 SHACTIVATEINFO *info = (SHACTIVATEINFO*) m_activateInfo;
315 if ( info )
316 {
317 SHHandleWMSettingChange(GetHwnd(), wParam, lParam, info);
318 }
319
320 return wxWindowMSW::HandleSettingChange(wParam, lParam);
321 }
322 #endif
323
324 WXLRESULT wxTopLevelWindowMSW::MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam)
325 {
326 WXLRESULT rc = 0;
327 bool processed = false;
328
329 #if defined(__SMARTPHONE__) || defined(__POCKETPC__)
330 switch ( message )
331 {
332 case WM_ACTIVATE:
333 {
334 SHACTIVATEINFO* info = (SHACTIVATEINFO*) m_activateInfo;
335 if (info)
336 {
337 DWORD flags = 0;
338 if (GetExtraStyle() & wxTOPLEVEL_EX_DIALOG) flags = SHA_INPUTDIALOG;
339 SHHandleWMActivate(GetHwnd(), wParam, lParam, info, flags);
340 }
341
342 // This implicitly sends a wxEVT_ACTIVATE_APP event
343 if (wxTheApp)
344 wxTheApp->SetActive(wParam != 0, FindFocus());
345
346 break;
347 }
348 case WM_HIBERNATE:
349 {
350 if (wxTheApp)
351 {
352 wxActivateEvent event(wxEVT_HIBERNATE, true, wxID_ANY);
353 event.SetEventObject(wxTheApp);
354 processed = wxTheApp->ProcessEvent(event);
355 }
356 break;
357 }
358 }
359 #endif
360
361 if ( !processed )
362 rc = wxTopLevelWindowBase::MSWWindowProc(message, wParam, lParam);
363
364 return rc;
365 }
366
367 bool wxTopLevelWindowMSW::CreateDialog(const void *dlgTemplate,
368 const wxString& title,
369 const wxPoint& pos,
370 const wxSize& size)
371 {
372 #ifdef __WXMICROWIN__
373 // no dialogs support under MicroWin yet
374 return CreateFrame(title, pos, size);
375 #else // !__WXMICROWIN__
376 wxWindow *parent = GetParent();
377
378 // for the dialogs without wxDIALOG_NO_PARENT style, use the top level
379 // app window as parent - this avoids creating modal dialogs without
380 // parent
381 if ( !parent && !(GetWindowStyleFlag() & wxDIALOG_NO_PARENT) )
382 {
383 parent = wxTheApp->GetTopWindow();
384
385 if ( parent )
386 {
387 // don't use transient windows as parents, this is dangerous as it
388 // can lead to a crash if the parent is destroyed before the child
389 //
390 // also don't use the window which is currently hidden as then the
391 // dialog would be hidden as well
392 if ( (parent->GetExtraStyle() & wxWS_EX_TRANSIENT) ||
393 !parent->IsShown() )
394 {
395 parent = NULL;
396 }
397 }
398 }
399
400 m_hWnd = (WXHWND)::CreateDialogIndirect
401 (
402 wxGetInstance(),
403 (DLGTEMPLATE*)dlgTemplate,
404 parent ? GetHwndOf(parent) : NULL,
405 (DLGPROC)wxDlgProc
406 );
407
408 if ( !m_hWnd )
409 {
410 wxFAIL_MSG(wxT("Failed to create dialog. Incorrect DLGTEMPLATE?"));
411
412 wxLogSysError(wxT("Can't create dialog using memory template"));
413
414 return false;
415 }
416
417 #if !defined(__WXWINCE__)
418 // For some reason, the system menu is activated when we use the
419 // WS_EX_CONTEXTHELP style, so let's set a reasonable icon
420 if ( HasExtraStyle(wxWS_EX_CONTEXTHELP) )
421 {
422 wxFrame *winTop = wxDynamicCast(wxTheApp->GetTopWindow(), wxFrame);
423 if ( winTop )
424 {
425 wxIcon icon = winTop->GetIcon();
426 if ( icon.Ok() )
427 {
428 ::SendMessage(GetHwnd(), WM_SETICON,
429 (WPARAM)TRUE,
430 (LPARAM)GetHiconOf(icon));
431 }
432 }
433 }
434 #endif // !__WXWINCE__
435
436 // move the dialog to its initial position without forcing repainting
437 int x, y, w, h;
438 (void)MSWGetCreateWindowCoords(pos, size, x, y, w, h);
439
440 if ( x == (int)CW_USEDEFAULT )
441 {
442 // centre it on the screen - what else can we do?
443 wxSize sizeDpy = wxGetDisplaySize();
444
445 x = (sizeDpy.x - w) / 2;
446 y = (sizeDpy.y - h) / 2;
447 }
448
449 #if !defined(__WXWINCE__) || defined(__WINCE_STANDARDSDK__)
450 if ( !::MoveWindow(GetHwnd(), x, y, w, h, FALSE) )
451 {
452 wxLogLastError(wxT("MoveWindow"));
453 }
454 #endif
455
456 if ( !title.empty() )
457 {
458 ::SetWindowText(GetHwnd(), title.wx_str());
459 }
460
461 SubclassWin(m_hWnd);
462
463 #ifdef __SMARTPHONE__
464 // Work around title non-display glitch
465 Show(false);
466 #endif
467
468 return true;
469 #endif // __WXMICROWIN__/!__WXMICROWIN__
470 }
471
472 bool wxTopLevelWindowMSW::CreateFrame(const wxString& title,
473 const wxPoint& pos,
474 const wxSize& size)
475 {
476 WXDWORD exflags;
477 WXDWORD flags = MSWGetCreateWindowFlags(&exflags);
478
479 const wxSize sz = IsAlwaysMaximized() ? wxDefaultSize : size;
480
481 #ifndef __WXWINCE__
482 if ( wxTheApp->GetLayoutDirection() == wxLayout_RightToLeft )
483 exflags |= WS_EX_LAYOUTRTL;
484 #endif
485
486 return MSWCreate(MSWGetRegisteredClassName(),
487 title.wx_str(), pos, sz, flags, exflags);
488 }
489
490 bool wxTopLevelWindowMSW::Create(wxWindow *parent,
491 wxWindowID id,
492 const wxString& title,
493 const wxPoint& pos,
494 const wxSize& size,
495 long style,
496 const wxString& name)
497 {
498 bool ret wxDUMMY_INITIALIZE(false);
499
500 wxSize sizeReal = size;
501 if ( !sizeReal.IsFullySpecified() )
502 {
503 sizeReal.SetDefaults(GetDefaultSize());
504 }
505
506 m_windowStyle = style;
507
508 SetName(name);
509
510 m_windowId = id == wxID_ANY ? NewControlId() : id;
511
512 wxTopLevelWindows.Append(this);
513
514 if ( parent )
515 parent->AddChild(this);
516
517 if ( GetExtraStyle() & wxTOPLEVEL_EX_DIALOG )
518 {
519 // we have different dialog templates to allows creation of dialogs
520 // with & without captions under MSWindows, resizeable or not (but a
521 // resizeable dialog always has caption - otherwise it would look too
522 // strange)
523
524 // we need 3 additional WORDs for dialog menu, class and title (as we
525 // don't use DS_SETFONT we don't need the fourth WORD for the font)
526 static const int dlgsize = sizeof(DLGTEMPLATE) + (sizeof(WORD) * 3);
527 DLGTEMPLATE *dlgTemplate = (DLGTEMPLATE *)malloc(dlgsize);
528 memset(dlgTemplate, 0, dlgsize);
529
530 // these values are arbitrary, they won't be used normally anyhow
531 dlgTemplate->x = 34;
532 dlgTemplate->y = 22;
533 dlgTemplate->cx = 144;
534 dlgTemplate->cy = 75;
535
536 // reuse the code in MSWGetStyle() but correct the results slightly for
537 // the dialog
538 //
539 // NB: we need a temporary variable as we can't pass pointer to
540 // dwExtendedStyle directly, it's not aligned correctly for 64 bit
541 // architectures
542 WXDWORD dwExtendedStyle;
543 dlgTemplate->style = MSWGetStyle(style, &dwExtendedStyle);
544 dlgTemplate->dwExtendedStyle = dwExtendedStyle;
545
546 // all dialogs are popups
547 dlgTemplate->style |= WS_POPUP;
548
549 #ifndef __WXWINCE__
550 if ( wxTheApp->GetLayoutDirection() == wxLayout_RightToLeft )
551 {
552 dlgTemplate->dwExtendedStyle |= WS_EX_LAYOUTRTL;
553 }
554
555 // force 3D-look if necessary, it looks impossibly ugly otherwise
556 if ( style & (wxRESIZE_BORDER | wxCAPTION) )
557 dlgTemplate->style |= DS_MODALFRAME;
558 #endif
559
560 ret = CreateDialog(dlgTemplate, title, pos, sizeReal);
561 free(dlgTemplate);
562 }
563 else // !dialog
564 {
565 ret = CreateFrame(title, pos, sizeReal);
566 }
567
568 #ifndef __WXWINCE__
569 if ( ret && !(GetWindowStyleFlag() & wxCLOSE_BOX) )
570 {
571 EnableCloseButton(false);
572 }
573 #endif
574
575 // for standard dialogs the dialog manager generates WM_CHANGEUISTATE
576 // itself but for custom windows we have to do it ourselves in order to
577 // make the keyboard indicators (such as underlines for accelerators and
578 // focus rectangles) work under Win2k+
579 if ( ret )
580 {
581 MSWUpdateUIState(UIS_INITIALIZE);
582 }
583
584 // Note: if we include PocketPC in this test, dialogs can fail to show up,
585 // for example the text entry dialog in the dialogs sample. Problem with Maximise()?
586 #if defined(__WXWINCE__) && (defined(__SMARTPHONE__) || defined(__WINCE_STANDARDSDK__))
587 if ( ( style & wxMAXIMIZE ) || IsAlwaysMaximized() )
588 {
589 this->Maximize();
590 }
591 #endif
592
593 #if defined(__SMARTPHONE__) && defined(__WXWINCE__)
594 SetRightMenu(); // to nothing for initialization
595 #endif
596
597 return ret;
598 }
599
600 wxTopLevelWindowMSW::~wxTopLevelWindowMSW()
601 {
602 SendDestroyEvent();
603
604 #if defined(__SMARTPHONE__) || defined(__POCKETPC__)
605 SHACTIVATEINFO* info = (SHACTIVATEINFO*) m_activateInfo;
606 delete info;
607 m_activateInfo = NULL;
608 #endif
609
610 // after destroying an owned window, Windows activates the next top level
611 // window in Z order but it may be different from our owner (to reproduce
612 // this simply Alt-TAB to another application and back before closing the
613 // owned frame) whereas we always want to yield activation to our parent
614 if ( HasFlag(wxFRAME_FLOAT_ON_PARENT) )
615 {
616 wxWindow *parent = GetParent();
617 if ( parent )
618 {
619 ::BringWindowToTop(GetHwndOf(parent));
620 }
621 }
622 }
623
624 // ----------------------------------------------------------------------------
625 // wxTopLevelWindowMSW showing
626 // ----------------------------------------------------------------------------
627
628 void wxTopLevelWindowMSW::DoShowWindow(int nShowCmd)
629 {
630 ::ShowWindow(GetHwnd(), nShowCmd);
631
632 m_iconized = nShowCmd == SW_MINIMIZE;
633 }
634
635 bool wxTopLevelWindowMSW::Show(bool show)
636 {
637 // don't use wxWindow version as we want to call DoShowWindow() ourselves
638 if ( !wxWindowBase::Show(show) )
639 return false;
640
641 int nShowCmd;
642 if ( show )
643 {
644 if ( m_maximizeOnShow )
645 {
646 // show and maximize
647 nShowCmd = SW_MAXIMIZE;
648
649 // This is necessary, or no window appears
650 #if defined( __WINCE_STANDARDSDK__) || defined(__SMARTPHONE__)
651 DoShowWindow(SW_SHOW);
652 #endif
653
654 m_maximizeOnShow = false;
655 }
656 else // just show
657 {
658 // we shouldn't use SW_SHOW which also activates the window for
659 // tool frames (as they shouldn't steal focus from the main window)
660 // nor for the currently disabled windows as they would be enabled
661 // as a side effect
662 if ( HasFlag(wxFRAME_TOOL_WINDOW) || !IsEnabled() )
663 nShowCmd = SW_SHOWNA;
664 else
665 nShowCmd = SW_SHOW;
666 }
667 }
668 else // hide
669 {
670 nShowCmd = SW_HIDE;
671 }
672
673 DoShowWindow(nShowCmd);
674
675 #if defined(__WXWINCE__) && (_WIN32_WCE >= 400 && !defined(__POCKETPC__) && !defined(__SMARTPHONE__))
676 // Addornments have to be added when the frame is the correct size
677 wxFrame* frame = wxDynamicCast(this, wxFrame);
678 if (frame && frame->GetMenuBar())
679 frame->GetMenuBar()->AddAdornments(GetWindowStyleFlag());
680 #endif
681
682 // we only set pending size if we're maximized before being shown, now that
683 // we're shown we don't need it any more (it is reset in size event handler
684 // for child windows but we have to do it ourselves for this parent window)
685 m_pendingSize = wxDefaultSize;
686
687 return true;
688 }
689
690 // ----------------------------------------------------------------------------
691 // wxTopLevelWindowMSW maximize/minimize
692 // ----------------------------------------------------------------------------
693
694 void wxTopLevelWindowMSW::Maximize(bool maximize)
695 {
696 if ( IsShown() )
697 {
698 // just maximize it directly
699 DoShowWindow(maximize ? SW_MAXIMIZE : SW_RESTORE);
700 }
701 else // hidden
702 {
703 // we can't maximize the hidden frame because it shows it as well,
704 // so just remember that we should do it later in this case
705 m_maximizeOnShow = maximize;
706
707 // after calling Maximize() the client code expects to get the frame
708 // "real" size and doesn't want to know that, because of implementation
709 // details, the frame isn't really maximized yet but will be only once
710 // it's shown, so return our size as it will be then in this case
711 if ( maximize )
712 {
713 // we must only change pending size here, and not call SetSize()
714 // because otherwise Windows would think that this (full screen)
715 // size is the natural size for the frame and so would use it when
716 // the user clicks on "restore" title bar button instead of the
717 // correct initial frame size
718 //
719 // NB: unfortunately we don't know which display we're on yet so we
720 // have to use the default one
721 m_pendingSize = wxGetClientDisplayRect().GetSize();
722 }
723 //else: can't do anything in this case, we don't have the old size
724 }
725 }
726
727 bool wxTopLevelWindowMSW::IsMaximized() const
728 {
729 return IsAlwaysMaximized() ||
730 #if !defined(__SMARTPHONE__) && !defined(__POCKETPC__) && !defined(__WINCE_STANDARDSDK__)
731
732 (::IsZoomed(GetHwnd()) != 0) ||
733 #endif
734 m_maximizeOnShow;
735 }
736
737 void wxTopLevelWindowMSW::Iconize(bool iconize)
738 {
739 DoShowWindow(iconize ? SW_MINIMIZE : SW_RESTORE);
740 }
741
742 bool wxTopLevelWindowMSW::IsIconized() const
743 {
744 #ifdef __WXWINCE__
745 return false;
746 #else
747 // don't use m_iconized, it may be briefly out of sync with the real state
748 // as it's only modified when we receive a WM_SIZE and we could be called
749 // from an event handler from one of the messages we receive before it,
750 // such as WM_MOVE
751 return ::IsIconic(GetHwnd()) != 0;
752 #endif
753 }
754
755 void wxTopLevelWindowMSW::Restore()
756 {
757 DoShowWindow(SW_RESTORE);
758 }
759
760 void wxTopLevelWindowMSW::SetLayoutDirection(wxLayoutDirection dir)
761 {
762 if ( dir == wxLayout_Default )
763 dir = wxTheApp->GetLayoutDirection();
764
765 if ( dir != wxLayout_Default )
766 wxTopLevelWindowBase::SetLayoutDirection(dir);
767 }
768
769 // ----------------------------------------------------------------------------
770 // wxTopLevelWindowMSW geometry
771 // ----------------------------------------------------------------------------
772
773 #ifndef __WXWINCE__
774
775 void wxTopLevelWindowMSW::DoGetPosition(int *x, int *y) const
776 {
777 if ( IsIconized() )
778 {
779 WINDOWPLACEMENT wp;
780 wp.length = sizeof(WINDOWPLACEMENT);
781 if ( ::GetWindowPlacement(GetHwnd(), &wp) )
782 {
783 RECT& rc = wp.rcNormalPosition;
784
785 // the position returned by GetWindowPlacement() is in workspace
786 // coordinates except for windows with WS_EX_TOOLWINDOW style
787 if ( !HasFlag(wxFRAME_TOOL_WINDOW) )
788 {
789 // we must use the correct display for the translation as the
790 // task bar might be shown on one display but not the other one
791 int n = wxDisplay::GetFromWindow(this);
792 wxDisplay dpy(n == wxNOT_FOUND ? 0 : n);
793 const wxPoint ptOfs = dpy.GetClientArea().GetPosition() -
794 dpy.GetGeometry().GetPosition();
795
796 rc.left += ptOfs.x;
797 rc.top += ptOfs.y;
798 }
799
800 if ( x )
801 *x = rc.left;
802 if ( y )
803 *y = rc.top;
804
805 return;
806 }
807
808 wxLogLastError(_T("GetWindowPlacement"));
809 }
810 //else: normal case
811
812 wxTopLevelWindowBase::DoGetPosition(x, y);
813 }
814
815 void wxTopLevelWindowMSW::DoGetSize(int *width, int *height) const
816 {
817 if ( IsIconized() )
818 {
819 WINDOWPLACEMENT wp;
820 wp.length = sizeof(WINDOWPLACEMENT);
821 if ( ::GetWindowPlacement(GetHwnd(), &wp) )
822 {
823 const RECT& rc = wp.rcNormalPosition;
824
825 if ( width )
826 *width = rc.right - rc.left;
827 if ( height )
828 *height = rc.bottom - rc.top;
829
830 return;
831 }
832
833 wxLogLastError(_T("GetWindowPlacement"));
834 }
835 //else: normal case
836
837 wxTopLevelWindowBase::DoGetSize(width, height);
838 }
839
840 #endif // __WXWINCE__
841
842 // ----------------------------------------------------------------------------
843 // wxTopLevelWindowMSW fullscreen
844 // ----------------------------------------------------------------------------
845
846 bool wxTopLevelWindowMSW::ShowFullScreen(bool show, long style)
847 {
848 if ( show == IsFullScreen() )
849 {
850 // nothing to do
851 return true;
852 }
853
854 m_fsIsShowing = show;
855
856 if ( show )
857 {
858 m_fsStyle = style;
859
860 // zap the frame borders
861
862 // save the 'normal' window style
863 m_fsOldWindowStyle = GetWindowLong(GetHwnd(), GWL_STYLE);
864
865 // save the old position, width & height, maximize state
866 m_fsOldSize = GetRect();
867 m_fsIsMaximized = IsMaximized();
868
869 // decide which window style flags to turn off
870 LONG newStyle = m_fsOldWindowStyle;
871 LONG offFlags = 0;
872
873 if (style & wxFULLSCREEN_NOBORDER)
874 {
875 offFlags |= WS_BORDER;
876 #ifndef __WXWINCE__
877 offFlags |= WS_THICKFRAME;
878 #endif
879 }
880 if (style & wxFULLSCREEN_NOCAPTION)
881 offFlags |= WS_CAPTION | WS_SYSMENU;
882
883 newStyle &= ~offFlags;
884
885 // change our window style to be compatible with full-screen mode
886 ::SetWindowLong(GetHwnd(), GWL_STYLE, newStyle);
887
888 wxRect rect;
889 #if wxUSE_DISPLAY
890 // resize to the size of the display containing us
891 int dpy = wxDisplay::GetFromWindow(this);
892 if ( dpy != wxNOT_FOUND )
893 {
894 rect = wxDisplay(dpy).GetGeometry();
895 }
896 else // fall back to the main desktop
897 #endif // wxUSE_DISPLAY
898 {
899 // resize to the size of the desktop
900 wxCopyRECTToRect(wxGetWindowRect(::GetDesktopWindow()), rect);
901 #ifdef __WXWINCE__
902 // FIXME: size of the bottom menu (toolbar)
903 // should be taken in account
904 rect.height += rect.y;
905 rect.y = 0;
906 #endif
907 }
908
909 SetSize(rect);
910
911 // now flush the window style cache and actually go full-screen
912 long flags = SWP_FRAMECHANGED;
913
914 // showing the frame full screen should also show it if it's still
915 // hidden
916 if ( !IsShown() )
917 {
918 // don't call wxWindow version to avoid flicker from calling
919 // ::ShowWindow() -- we're going to show the window at the correct
920 // location directly below -- but do call the wxWindowBase version
921 // to sync the internal m_isShown flag
922 wxWindowBase::Show();
923
924 flags |= SWP_SHOWWINDOW;
925 }
926
927 SetWindowPos(GetHwnd(), HWND_TOP,
928 rect.x, rect.y, rect.width, rect.height,
929 flags);
930
931 #if !defined(__HANDHELDPC__) && (defined(__WXWINCE__) && (_WIN32_WCE < 400))
932 ::SHFullScreen(GetHwnd(), SHFS_HIDETASKBAR | SHFS_HIDESIPBUTTON);
933 #endif
934
935 // finally send an event allowing the window to relayout itself &c
936 wxSizeEvent event(rect.GetSize(), GetId());
937 HandleWindowEvent(event);
938 }
939 else // stop showing full screen
940 {
941 #if !defined(__HANDHELDPC__) && (defined(__WXWINCE__) && (_WIN32_WCE < 400))
942 ::SHFullScreen(GetHwnd(), SHFS_SHOWTASKBAR | SHFS_SHOWSIPBUTTON);
943 #endif
944 Maximize(m_fsIsMaximized);
945 SetWindowLong(GetHwnd(),GWL_STYLE, m_fsOldWindowStyle);
946 SetWindowPos(GetHwnd(),HWND_TOP,m_fsOldSize.x, m_fsOldSize.y,
947 m_fsOldSize.width, m_fsOldSize.height, SWP_FRAMECHANGED);
948 }
949
950 return true;
951 }
952
953 // ----------------------------------------------------------------------------
954 // wxTopLevelWindowMSW misc
955 // ----------------------------------------------------------------------------
956
957 void wxTopLevelWindowMSW::SetTitle( const wxString& title)
958 {
959 SetLabel(title);
960 }
961
962 wxString wxTopLevelWindowMSW::GetTitle() const
963 {
964 return GetLabel();
965 }
966
967 bool wxTopLevelWindowMSW::DoSelectAndSetIcon(const wxIconBundle& icons,
968 int smX,
969 int smY,
970 int i)
971 {
972 const wxSize size(::GetSystemMetrics(smX), ::GetSystemMetrics(smY));
973
974 const wxIcon icon = icons.GetIconOfExactSize(size);
975 if ( icon.Ok() )
976 {
977 ::SendMessage(GetHwnd(), WM_SETICON, i, (LPARAM)GetHiconOf(icon));
978 return true;
979 }
980
981 return false;
982 }
983
984 void wxTopLevelWindowMSW::SetIcons(const wxIconBundle& icons)
985 {
986 wxTopLevelWindowBase::SetIcons(icons);
987
988 if ( icons.IsEmpty() )
989 {
990 // FIXME: SetIcons(wxNullIconBundle) should unset existing icons,
991 // but we currently don't do that
992 wxASSERT_MSG( m_icons.IsEmpty(), "unsetting icons doesn't work" );
993 return;
994 }
995
996 if ( !DoSelectAndSetIcon(icons, SM_CXSMICON, SM_CYSMICON, ICON_SMALL) &&
997 !DoSelectAndSetIcon(icons, SM_CXICON, SM_CYICON, ICON_BIG) )
998 {
999 wxFAIL_MSG( "icon bundle doesn't contain any suitable icon" );
1000 }
1001 }
1002
1003 bool wxTopLevelWindowMSW::EnableCloseButton(bool enable)
1004 {
1005 #if !defined(__WXMICROWIN__)
1006 // get system (a.k.a. window) menu
1007 HMENU hmenu = GetSystemMenu(GetHwnd(), FALSE /* get it */);
1008 if ( !hmenu )
1009 {
1010 // no system menu at all -- ok if we want to remove the close button
1011 // anyhow, but bad if we want to show it
1012 return !enable;
1013 }
1014
1015 // enabling/disabling the close item from it also automatically
1016 // disables/enables the close title bar button
1017 if ( ::EnableMenuItem(hmenu, SC_CLOSE,
1018 MF_BYCOMMAND |
1019 (enable ? MF_ENABLED : MF_GRAYED)) == -1 )
1020 {
1021 wxLogLastError(_T("EnableMenuItem(SC_CLOSE)"));
1022
1023 return false;
1024 }
1025 #ifndef __WXWINCE__
1026 // update appearance immediately
1027 if ( !::DrawMenuBar(GetHwnd()) )
1028 {
1029 wxLogLastError(_T("DrawMenuBar"));
1030 }
1031 #endif
1032 #endif // !__WXMICROWIN__
1033
1034 return true;
1035 }
1036
1037 #ifndef __WXWINCE__
1038
1039 bool wxTopLevelWindowMSW::SetShape(const wxRegion& region)
1040 {
1041 wxCHECK_MSG( HasFlag(wxFRAME_SHAPED), false,
1042 _T("Shaped windows must be created with the wxFRAME_SHAPED style."));
1043
1044 // The empty region signifies that the shape should be removed from the
1045 // window.
1046 if ( region.IsEmpty() )
1047 {
1048 if (::SetWindowRgn(GetHwnd(), NULL, TRUE) == 0)
1049 {
1050 wxLogLastError(_T("SetWindowRgn"));
1051 return false;
1052 }
1053 return true;
1054 }
1055
1056 // Windows takes ownership of the region, so
1057 // we'll have to make a copy of the region to give to it.
1058 DWORD noBytes = ::GetRegionData(GetHrgnOf(region), 0, NULL);
1059 RGNDATA *rgnData = (RGNDATA*) new char[noBytes];
1060 ::GetRegionData(GetHrgnOf(region), noBytes, rgnData);
1061 HRGN hrgn = ::ExtCreateRegion(NULL, noBytes, rgnData);
1062 delete[] (char*) rgnData;
1063
1064 // SetWindowRgn expects the region to be in coordinants
1065 // relative to the window, not the client area. Figure
1066 // out the offset, if any.
1067 RECT rect;
1068 DWORD dwStyle = ::GetWindowLong(GetHwnd(), GWL_STYLE);
1069 DWORD dwExStyle = ::GetWindowLong(GetHwnd(), GWL_EXSTYLE);
1070 ::GetClientRect(GetHwnd(), &rect);
1071 ::AdjustWindowRectEx(&rect, dwStyle, FALSE, dwExStyle);
1072 ::OffsetRgn(hrgn, -rect.left, -rect.top);
1073
1074 // Now call the shape API with the new region.
1075 if (::SetWindowRgn(GetHwnd(), hrgn, TRUE) == 0)
1076 {
1077 wxLogLastError(_T("SetWindowRgn"));
1078 return false;
1079 }
1080 return true;
1081 }
1082
1083 #endif // !__WXWINCE__
1084
1085 void wxTopLevelWindowMSW::RequestUserAttention(int flags)
1086 {
1087 // check if we can use FlashWindowEx(): unfortunately a simple test for
1088 // FLASHW_STOP doesn't work because MSVC6 headers do #define it but don't
1089 // provide FlashWindowEx() declaration, so try to detect whether we have
1090 // real headers for WINVER 0x0500 by checking for existence of a symbol not
1091 // declated in MSVC6 header
1092 #if defined(FLASHW_STOP) && defined(VK_XBUTTON1) && wxUSE_DYNLIB_CLASS
1093 // available in the headers, check if it is supported by the system
1094 typedef BOOL (WINAPI *FlashWindowEx_t)(FLASHWINFO *pfwi);
1095 static FlashWindowEx_t s_pfnFlashWindowEx = NULL;
1096 if ( !s_pfnFlashWindowEx )
1097 {
1098 wxDynamicLibrary dllUser32(_T("user32.dll"));
1099 s_pfnFlashWindowEx = (FlashWindowEx_t)
1100 dllUser32.GetSymbol(_T("FlashWindowEx"));
1101
1102 // we can safely unload user32.dll here, it's going to remain loaded as
1103 // long as the program is running anyhow
1104 }
1105
1106 if ( s_pfnFlashWindowEx )
1107 {
1108 WinStruct<FLASHWINFO> fwi;
1109 fwi.hwnd = GetHwnd();
1110 fwi.dwFlags = FLASHW_ALL;
1111 if ( flags & wxUSER_ATTENTION_INFO )
1112 {
1113 // just flash a few times
1114 fwi.uCount = 3;
1115 }
1116 else // wxUSER_ATTENTION_ERROR
1117 {
1118 // flash until the user notices it
1119 fwi.dwFlags |= FLASHW_TIMERNOFG;
1120 }
1121
1122 s_pfnFlashWindowEx(&fwi);
1123 }
1124 else // FlashWindowEx() not available
1125 #endif // FlashWindowEx() defined
1126 {
1127 wxUnusedVar(flags);
1128 #ifndef __WXWINCE__
1129 ::FlashWindow(GetHwnd(), TRUE);
1130 #endif // __WXWINCE__
1131 }
1132 }
1133
1134 // ---------------------------------------------------------------------------
1135
1136 bool wxTopLevelWindowMSW::SetTransparent(wxByte alpha)
1137 {
1138 #if wxUSE_DYNLIB_CLASS
1139 typedef DWORD (WINAPI *PSETLAYEREDWINDOWATTR)(HWND, DWORD, BYTE, DWORD);
1140 static PSETLAYEREDWINDOWATTR
1141 pSetLayeredWindowAttributes = (PSETLAYEREDWINDOWATTR)-1;
1142
1143 if ( pSetLayeredWindowAttributes == (PSETLAYEREDWINDOWATTR)-1 )
1144 {
1145 wxDynamicLibrary dllUser32(_T("user32.dll"));
1146
1147 // use RawGetSymbol() and not GetSymbol() to avoid error messages under
1148 // Windows 95: there is nothing the user can do about this anyhow
1149 pSetLayeredWindowAttributes = (PSETLAYEREDWINDOWATTR)
1150 dllUser32.RawGetSymbol(wxT("SetLayeredWindowAttributes"));
1151
1152 // it's ok to destroy dllUser32 here, we link statically to user32.dll
1153 // anyhow so it won't be unloaded
1154 }
1155
1156 if ( !pSetLayeredWindowAttributes )
1157 return false;
1158 #endif // wxUSE_DYNLIB_CLASS
1159
1160 LONG exstyle = GetWindowLong(GetHwnd(), GWL_EXSTYLE);
1161
1162 // if setting alpha to fully opaque then turn off the layered style
1163 if (alpha == 255)
1164 {
1165 SetWindowLong(GetHwnd(), GWL_EXSTYLE, exstyle & ~WS_EX_LAYERED);
1166 Refresh();
1167 return true;
1168 }
1169
1170 #if wxUSE_DYNLIB_CLASS
1171 // Otherwise, set the layered style if needed and set the alpha value
1172 if ((exstyle & WS_EX_LAYERED) == 0 )
1173 SetWindowLong(GetHwnd(), GWL_EXSTYLE, exstyle | WS_EX_LAYERED);
1174
1175 if ( pSetLayeredWindowAttributes(GetHwnd(), 0, (BYTE)alpha, LWA_ALPHA) )
1176 return true;
1177 #endif // wxUSE_DYNLIB_CLASS
1178
1179 return false;
1180 }
1181
1182 bool wxTopLevelWindowMSW::CanSetTransparent()
1183 {
1184 // The API is available on win2k and above
1185
1186 static int os_type = -1;
1187 static int ver_major = -1;
1188
1189 if (os_type == -1)
1190 os_type = ::wxGetOsVersion(&ver_major);
1191
1192 return (os_type == wxOS_WINDOWS_NT && ver_major >= 5);
1193 }
1194
1195
1196 void wxTopLevelWindowMSW::DoFreeze()
1197 {
1198 // do nothing: freezing toplevel window causes paint and mouse events
1199 // to go through it any TLWs under it, so the best we can do is to freeze
1200 // all children -- and wxWindowBase::Freeze() does that
1201 }
1202
1203 void wxTopLevelWindowMSW::DoThaw()
1204 {
1205 // intentionally empty -- see DoFreeze()
1206 }
1207
1208
1209 // ----------------------------------------------------------------------------
1210 // wxTopLevelWindow event handling
1211 // ----------------------------------------------------------------------------
1212
1213 // Default activation behaviour - set the focus for the first child
1214 // subwindow found.
1215 void wxTopLevelWindowMSW::OnActivate(wxActivateEvent& event)
1216 {
1217 if ( event.GetActive() )
1218 {
1219 // restore focus to the child which was last focused unless we already
1220 // have it
1221 wxLogTrace(_T("focus"), _T("wxTLW %p activated."), m_hWnd);
1222
1223 wxWindow *winFocus = FindFocus();
1224 if ( !winFocus || wxGetTopLevelParent(winFocus) != this )
1225 {
1226 wxWindow *parent = m_winLastFocused ? m_winLastFocused->GetParent()
1227 : NULL;
1228 if ( !parent )
1229 {
1230 parent = this;
1231 }
1232
1233 wxSetFocusToChild(parent, &m_winLastFocused);
1234 }
1235 }
1236 else // deactivating
1237 {
1238 // remember the last focused child if it is our child
1239 m_winLastFocused = FindFocus();
1240
1241 if ( m_winLastFocused )
1242 {
1243 // let it know that it doesn't have focus any more
1244 // But this will already be done via WM_KILLFOCUS, so we'll get two kill
1245 // focus events if we call it explicitly.
1246 // m_winLastFocused->HandleKillFocus((WXHWND)NULL);
1247
1248 // and don't remember it if it's a child from some other frame
1249 if ( wxGetTopLevelParent(m_winLastFocused) != this )
1250 {
1251 m_winLastFocused = NULL;
1252 }
1253 }
1254
1255 wxLogTrace(_T("focus"),
1256 _T("wxTLW %p deactivated, last focused: %p."),
1257 m_hWnd,
1258 m_winLastFocused ? GetHwndOf(m_winLastFocused) : NULL);
1259
1260 event.Skip();
1261 }
1262 }
1263
1264 // the DialogProc for all wxWidgets dialogs
1265 LONG APIENTRY _EXPORT
1266 wxDlgProc(HWND hDlg,
1267 UINT message,
1268 WPARAM WXUNUSED(wParam),
1269 LPARAM WXUNUSED(lParam))
1270 {
1271 switch ( message )
1272 {
1273 case WM_INITDIALOG:
1274 {
1275 // under CE, add a "Ok" button in the dialog title bar and make it full
1276 // screen
1277 //
1278 // TODO: find the window for this HWND, and take into account
1279 // wxMAXIMIZE and wxCLOSE_BOX. For now, assume both are present.
1280 //
1281 // Standard SDK doesn't have aygshell.dll: see
1282 // include/wx/msw/wince/libraries.h
1283 #if defined(__WXWINCE__) && !defined(__WINCE_STANDARDSDK__) && !defined(__HANDHELDPC__)
1284 SHINITDLGINFO shidi;
1285 shidi.dwMask = SHIDIM_FLAGS;
1286 shidi.dwFlags = SHIDIF_SIZEDLG // take account of the SIP or menubar
1287 #ifndef __SMARTPHONE__
1288 | SHIDIF_DONEBUTTON
1289 #endif
1290 ;
1291 shidi.hDlg = hDlg;
1292 SHInitDialog( &shidi );
1293 #else // no SHInitDialog()
1294 wxUnusedVar(hDlg);
1295 #endif
1296 // for WM_INITDIALOG, returning TRUE tells system to set focus to
1297 // the first control in the dialog box, but as we set the focus
1298 // ourselves, we return FALSE for it as well
1299 return FALSE;
1300 }
1301 }
1302
1303 // for almost all messages, returning FALSE means that we didn't process
1304 // the message
1305 return FALSE;
1306 }
1307
1308 // ============================================================================
1309 // wxTLWHiddenParentModule implementation
1310 // ============================================================================
1311
1312 HWND wxTLWHiddenParentModule::ms_hwnd = NULL;
1313
1314 const wxChar *wxTLWHiddenParentModule::ms_className = NULL;
1315
1316 bool wxTLWHiddenParentModule::OnInit()
1317 {
1318 ms_hwnd = NULL;
1319 ms_className = NULL;
1320
1321 return true;
1322 }
1323
1324 void wxTLWHiddenParentModule::OnExit()
1325 {
1326 if ( ms_hwnd )
1327 {
1328 if ( !::DestroyWindow(ms_hwnd) )
1329 {
1330 wxLogLastError(_T("DestroyWindow(hidden TLW parent)"));
1331 }
1332
1333 ms_hwnd = NULL;
1334 }
1335
1336 if ( ms_className )
1337 {
1338 if ( !::UnregisterClass(ms_className, wxGetInstance()) )
1339 {
1340 wxLogLastError(_T("UnregisterClass(\"wxTLWHiddenParent\")"));
1341 }
1342
1343 ms_className = NULL;
1344 }
1345 }
1346
1347 /* static */
1348 HWND wxTLWHiddenParentModule::GetHWND()
1349 {
1350 if ( !ms_hwnd )
1351 {
1352 if ( !ms_className )
1353 {
1354 static const wxChar *HIDDEN_PARENT_CLASS = _T("wxTLWHiddenParent");
1355
1356 WNDCLASS wndclass;
1357 wxZeroMemory(wndclass);
1358
1359 wndclass.lpfnWndProc = DefWindowProc;
1360 wndclass.hInstance = wxGetInstance();
1361 wndclass.lpszClassName = HIDDEN_PARENT_CLASS;
1362
1363 if ( !::RegisterClass(&wndclass) )
1364 {
1365 wxLogLastError(_T("RegisterClass(\"wxTLWHiddenParent\")"));
1366 }
1367 else
1368 {
1369 ms_className = HIDDEN_PARENT_CLASS;
1370 }
1371 }
1372
1373 ms_hwnd = ::CreateWindow(ms_className, wxEmptyString, 0, 0, 0, 0, 0, NULL,
1374 (HMENU)NULL, wxGetInstance(), NULL);
1375 if ( !ms_hwnd )
1376 {
1377 wxLogLastError(_T("CreateWindow(hidden TLW parent)"));
1378 }
1379 }
1380
1381 return ms_hwnd;
1382 }