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