Include wx/toolbar.h according to precompiled headers of wx/wx.h (with other minor...
[wxWidgets.git] / src / msw / mdi.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/msw/mdi.cpp
3 // Purpose: MDI classes for wxMSW
4 // Author: Julian Smart
5 // Modified by:
6 // Created: 04/01/98
7 // RCS-ID: $Id$
8 // Copyright: (c) Julian Smart
9 // Licence: 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 #if wxUSE_MDI && !defined(__WXUNIVERSAL__)
28
29 #ifndef WX_PRECOMP
30 #include "wx/frame.h"
31 #include "wx/menu.h"
32 #include "wx/app.h"
33 #include "wx/utils.h"
34 #include "wx/dialog.h"
35 #if wxUSE_STATUSBAR
36 #include "wx/statusbr.h"
37 #endif
38 #include "wx/settings.h"
39 #include "wx/intl.h"
40 #include "wx/log.h"
41 #include "wx/toolbar.h"
42 #endif
43
44 #include "wx/stockitem.h"
45 #include "wx/mdi.h"
46 #include "wx/msw/private.h"
47
48 #if wxUSE_STATUSBAR && wxUSE_NATIVE_STATUSBAR
49 #include "wx/msw/statbr95.h"
50 #endif
51
52 #include <string.h>
53
54 // ---------------------------------------------------------------------------
55 // global variables
56 // ---------------------------------------------------------------------------
57
58 extern wxMenu *wxCurrentPopupMenu;
59
60 extern const wxChar *wxMDIFrameClassName; // from app.cpp
61 extern const wxChar *wxMDIChildFrameClassName;
62 extern const wxChar *wxMDIChildFrameClassNameNoRedraw;
63 extern void wxRemoveHandleAssociation(wxWindow *win);
64
65 // ---------------------------------------------------------------------------
66 // constants
67 // ---------------------------------------------------------------------------
68
69 static const int IDM_WINDOWTILEHOR = 4001;
70 static const int IDM_WINDOWCASCADE = 4002;
71 static const int IDM_WINDOWICONS = 4003;
72 static const int IDM_WINDOWNEXT = 4004;
73 static const int IDM_WINDOWTILEVERT = 4005;
74 static const int IDM_WINDOWPREV = 4006;
75
76 // This range gives a maximum of 500 MDI children. Should be enough :-)
77 static const int wxFIRST_MDI_CHILD = 4100;
78 static const int wxLAST_MDI_CHILD = 4600;
79
80 // ---------------------------------------------------------------------------
81 // private functions
82 // ---------------------------------------------------------------------------
83
84 // set the MDI menus (by sending the WM_MDISETMENU message) and update the menu
85 // of the parent of win (which is supposed to be the MDI client window)
86 static void MDISetMenu(wxWindow *win, HMENU hmenuFrame, HMENU hmenuWindow);
87
88 // insert the window menu (subMenu) into menu just before "Help" submenu or at
89 // the very end if not found
90 static void InsertWindowMenu(wxWindow *win, WXHMENU menu, HMENU subMenu);
91
92 // Remove the window menu
93 static void RemoveWindowMenu(wxWindow *win, WXHMENU menu);
94
95 // is this an id of an MDI child?
96 inline bool IsMdiCommandId(int id)
97 {
98 return (id >= wxFIRST_MDI_CHILD) && (id <= wxLAST_MDI_CHILD);
99 }
100
101 // unpack the parameters of WM_MDIACTIVATE message
102 static void UnpackMDIActivate(WXWPARAM wParam, WXLPARAM lParam,
103 WXWORD *activate, WXHWND *hwndAct, WXHWND *hwndDeact);
104
105 // return the HMENU of the MDI menu
106 static inline HMENU GetMDIWindowMenu(wxMDIParentFrame *frame)
107 {
108 wxMenu *menu = frame->GetWindowMenu();
109 return menu ? GetHmenuOf(menu) : 0;
110 }
111
112 // ===========================================================================
113 // implementation
114 // ===========================================================================
115
116 // ---------------------------------------------------------------------------
117 // wxWin macros
118 // ---------------------------------------------------------------------------
119
120 IMPLEMENT_DYNAMIC_CLASS(wxMDIParentFrame, wxFrame)
121 IMPLEMENT_DYNAMIC_CLASS(wxMDIChildFrame, wxFrame)
122 IMPLEMENT_DYNAMIC_CLASS(wxMDIClientWindow, wxWindow)
123
124 BEGIN_EVENT_TABLE(wxMDIParentFrame, wxFrame)
125 EVT_SIZE(wxMDIParentFrame::OnSize)
126 EVT_ICONIZE(wxMDIParentFrame::OnIconized)
127 EVT_SYS_COLOUR_CHANGED(wxMDIParentFrame::OnSysColourChanged)
128 END_EVENT_TABLE()
129
130 BEGIN_EVENT_TABLE(wxMDIChildFrame, wxFrame)
131 EVT_IDLE(wxMDIChildFrame::OnIdle)
132 END_EVENT_TABLE()
133
134 BEGIN_EVENT_TABLE(wxMDIClientWindow, wxWindow)
135 EVT_SCROLL(wxMDIClientWindow::OnScroll)
136 END_EVENT_TABLE()
137
138 // ===========================================================================
139 // wxMDIParentFrame: the frame which contains the client window which manages
140 // the children
141 // ===========================================================================
142
143 wxMDIParentFrame::wxMDIParentFrame()
144 {
145 m_clientWindow = NULL;
146 m_currentChild = NULL;
147 m_windowMenu = (wxMenu*) NULL;
148 m_parentFrameActive = true;
149 }
150
151 bool wxMDIParentFrame::Create(wxWindow *parent,
152 wxWindowID id,
153 const wxString& title,
154 const wxPoint& pos,
155 const wxSize& size,
156 long style,
157 const wxString& name)
158 {
159 m_clientWindow = NULL;
160 m_currentChild = NULL;
161
162 // this style can be used to prevent a window from having the standard MDI
163 // "Window" menu
164 if ( style & wxFRAME_NO_WINDOW_MENU )
165 {
166 m_windowMenu = (wxMenu *)NULL;
167 }
168 else // normal case: we have the window menu, so construct it
169 {
170 m_windowMenu = new wxMenu;
171
172 m_windowMenu->Append(IDM_WINDOWCASCADE, _("&Cascade"));
173 m_windowMenu->Append(IDM_WINDOWTILEHOR, _("Tile &Horizontally"));
174 m_windowMenu->Append(IDM_WINDOWTILEVERT, _("Tile &Vertically"));
175 m_windowMenu->AppendSeparator();
176 m_windowMenu->Append(IDM_WINDOWICONS, _("&Arrange Icons"));
177 m_windowMenu->Append(IDM_WINDOWNEXT, _("&Next"));
178 m_windowMenu->Append(IDM_WINDOWPREV, _("&Previous"));
179 }
180
181 m_parentFrameActive = true;
182
183 if (!parent)
184 wxTopLevelWindows.Append(this);
185
186 SetName(name);
187 m_windowStyle = style;
188
189 if ( parent )
190 parent->AddChild(this);
191
192 if ( id != wxID_ANY )
193 m_windowId = id;
194 else
195 m_windowId = NewControlId();
196
197 WXDWORD exflags;
198 WXDWORD msflags = MSWGetCreateWindowFlags(&exflags);
199 msflags &= ~WS_VSCROLL;
200 msflags &= ~WS_HSCROLL;
201
202 if ( !wxWindow::MSWCreate(wxMDIFrameClassName,
203 title,
204 pos, size,
205 msflags,
206 exflags) )
207 {
208 return false;
209 }
210
211 SetOwnBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_APPWORKSPACE));
212
213 // unlike (almost?) all other windows, frames are created hidden
214 m_isShown = false;
215
216 return true;
217 }
218
219 wxMDIParentFrame::~wxMDIParentFrame()
220 {
221 // see comment in ~wxMDIChildFrame
222 #if wxUSE_TOOLBAR
223 m_frameToolBar = NULL;
224 #endif
225 #if wxUSE_STATUSBAR
226 m_frameStatusBar = NULL;
227 #endif // wxUSE_STATUSBAR
228
229 DestroyChildren();
230
231 if (m_windowMenu)
232 {
233 delete m_windowMenu;
234 m_windowMenu = (wxMenu*) NULL;
235 }
236
237 // the MDI frame menubar is not automatically deleted by Windows unlike for
238 // the normal frames
239 if ( m_hMenu )
240 {
241 ::DestroyMenu((HMENU)m_hMenu);
242 m_hMenu = (WXHMENU)NULL;
243 }
244
245 if ( m_clientWindow )
246 {
247 if ( m_clientWindow->MSWGetOldWndProc() )
248 m_clientWindow->UnsubclassWin();
249
250 m_clientWindow->SetHWND(0);
251 delete m_clientWindow;
252 }
253 }
254
255 #if wxUSE_MENUS_NATIVE
256
257 void wxMDIParentFrame::InternalSetMenuBar()
258 {
259 m_parentFrameActive = true;
260
261 InsertWindowMenu(GetClientWindow(), m_hMenu, GetMDIWindowMenu(this));
262 }
263
264 #endif // wxUSE_MENUS_NATIVE
265
266 void wxMDIParentFrame::SetWindowMenu(wxMenu* menu)
267 {
268 if (m_windowMenu)
269 {
270 if (GetMenuBar())
271 {
272 // Remove old window menu
273 RemoveWindowMenu(GetClientWindow(), m_hMenu);
274 }
275
276 delete m_windowMenu;
277 m_windowMenu = (wxMenu*) NULL;
278 }
279
280 if (menu)
281 {
282 m_windowMenu = menu;
283 if (GetMenuBar())
284 {
285 InsertWindowMenu(GetClientWindow(), m_hMenu,
286 GetHmenuOf(m_windowMenu));
287 }
288 }
289 }
290
291 void wxMDIParentFrame::DoMenuUpdates(wxMenu* menu)
292 {
293 wxMDIChildFrame *child = GetActiveChild();
294 if ( child )
295 {
296 wxEvtHandler* source = child->GetEventHandler();
297 wxMenuBar* bar = child->GetMenuBar();
298
299 if (menu)
300 {
301 menu->UpdateUI(source);
302 }
303 else
304 {
305 if ( bar != NULL )
306 {
307 int nCount = bar->GetMenuCount();
308 for (int n = 0; n < nCount; n++)
309 bar->GetMenu(n)->UpdateUI(source);
310 }
311 }
312 }
313 else
314 {
315 wxFrameBase::DoMenuUpdates(menu);
316 }
317 }
318
319 void wxMDIParentFrame::UpdateClientSize()
320 {
321 if ( GetClientWindow() )
322 {
323 int width, height;
324 GetClientSize(&width, &height);
325
326 GetClientWindow()->SetSize(0, 0, width, height);
327 }
328 }
329
330 void wxMDIParentFrame::OnSize(wxSizeEvent& WXUNUSED(event))
331 {
332 UpdateClientSize();
333
334 // do not call event.Skip() here, it somehow messes up MDI client window
335 }
336
337 void wxMDIParentFrame::OnIconized(wxIconizeEvent& event)
338 {
339 event.Skip();
340
341 if ( !event.Iconized() )
342 {
343 UpdateClientSize();
344 }
345 }
346
347 // Returns the active MDI child window
348 wxMDIChildFrame *wxMDIParentFrame::GetActiveChild() const
349 {
350 HWND hWnd = (HWND)::SendMessage(GetWinHwnd(GetClientWindow()),
351 WM_MDIGETACTIVE, 0, 0L);
352 if ( hWnd == 0 )
353 return NULL;
354 else
355 return (wxMDIChildFrame *)wxFindWinFromHandle((WXHWND) hWnd);
356 }
357
358 // Create the client window class (don't Create the window, just return a new
359 // class)
360 wxMDIClientWindow *wxMDIParentFrame::OnCreateClient()
361 {
362 return new wxMDIClientWindow;
363 }
364
365 // Responds to colour changes, and passes event on to children.
366 void wxMDIParentFrame::OnSysColourChanged(wxSysColourChangedEvent& event)
367 {
368 if ( m_clientWindow )
369 {
370 m_clientWindow->SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_APPWORKSPACE));
371 m_clientWindow->Refresh();
372 }
373
374 event.Skip();
375 }
376
377 WXHICON wxMDIParentFrame::GetDefaultIcon() const
378 {
379 // we don't have any standard icons (any more)
380 return (WXHICON)0;
381 }
382
383 // ---------------------------------------------------------------------------
384 // MDI operations
385 // ---------------------------------------------------------------------------
386
387 void wxMDIParentFrame::Cascade()
388 {
389 ::SendMessage(GetWinHwnd(GetClientWindow()), WM_MDICASCADE, 0, 0);
390 }
391
392 void wxMDIParentFrame::Tile(wxOrientation orient)
393 {
394 wxASSERT_MSG( orient == wxHORIZONTAL || orient == wxVERTICAL,
395 _T("invalid orientation value") );
396
397 ::SendMessage(GetWinHwnd(GetClientWindow()), WM_MDITILE,
398 orient == wxHORIZONTAL ? MDITILE_HORIZONTAL
399 : MDITILE_VERTICAL, 0);
400 }
401
402 void wxMDIParentFrame::ArrangeIcons()
403 {
404 ::SendMessage(GetWinHwnd(GetClientWindow()), WM_MDIICONARRANGE, 0, 0);
405 }
406
407 void wxMDIParentFrame::ActivateNext()
408 {
409 ::SendMessage(GetWinHwnd(GetClientWindow()), WM_MDINEXT, 0, 0);
410 }
411
412 void wxMDIParentFrame::ActivatePrevious()
413 {
414 ::SendMessage(GetWinHwnd(GetClientWindow()), WM_MDINEXT, 0, 1);
415 }
416
417 // ---------------------------------------------------------------------------
418 // the MDI parent frame window proc
419 // ---------------------------------------------------------------------------
420
421 WXLRESULT wxMDIParentFrame::MSWWindowProc(WXUINT message,
422 WXWPARAM wParam,
423 WXLPARAM lParam)
424 {
425 WXLRESULT rc = 0;
426 bool processed = false;
427
428 switch ( message )
429 {
430 case WM_ACTIVATE:
431 {
432 WXWORD state, minimized;
433 WXHWND hwnd;
434 UnpackActivate(wParam, lParam, &state, &minimized, &hwnd);
435
436 processed = HandleActivate(state, minimized != 0, hwnd);
437 }
438 break;
439
440 case WM_COMMAND:
441 {
442 WXWORD id, cmd;
443 WXHWND hwnd;
444 UnpackCommand(wParam, lParam, &id, &hwnd, &cmd);
445
446 (void)HandleCommand(id, cmd, hwnd);
447
448 // even if the frame didn't process it, there is no need to try it
449 // once again (i.e. call wxFrame::HandleCommand()) - we just did it,
450 // so pretend we processed the message anyhow
451 processed = true;
452 }
453
454 // always pass this message DefFrameProc(), otherwise MDI menu
455 // commands (and sys commands - more surprisingly!) won't work
456 MSWDefWindowProc(message, wParam, lParam);
457 break;
458
459 case WM_CREATE:
460 m_clientWindow = OnCreateClient();
461 // Uses own style for client style
462 if ( !m_clientWindow->CreateClient(this, GetWindowStyleFlag()) )
463 {
464 wxLogMessage(_("Failed to create MDI parent frame."));
465
466 rc = -1;
467 }
468
469 processed = true;
470 break;
471
472 case WM_ERASEBKGND:
473 processed = true;
474
475 // we erase background ourselves
476 rc = true;
477 break;
478
479 case WM_MENUSELECT:
480 {
481 WXWORD item, flags;
482 WXHMENU hmenu;
483 UnpackMenuSelect(wParam, lParam, &item, &flags, &hmenu);
484
485 if ( m_parentFrameActive )
486 {
487 processed = HandleMenuSelect(item, flags, hmenu);
488 }
489 else if (m_currentChild)
490 {
491 processed = m_currentChild->
492 HandleMenuSelect(item, flags, hmenu);
493 }
494 }
495 break;
496
497 case WM_SIZE:
498 // though we don't (usually) resize the MDI client to exactly fit the
499 // client area we need to pass this one to DefFrameProc to allow the children to show
500 break;
501 }
502
503 if ( !processed )
504 rc = wxFrame::MSWWindowProc(message, wParam, lParam);
505
506 return rc;
507 }
508
509 bool wxMDIParentFrame::HandleActivate(int state, bool minimized, WXHWND activate)
510 {
511 bool processed = false;
512
513 if ( wxWindow::HandleActivate(state, minimized, activate) )
514 {
515 // already processed
516 processed = true;
517 }
518
519 // If this window is an MDI parent, we must also send an OnActivate message
520 // to the current child.
521 if ( (m_currentChild != NULL) &&
522 ((state == WA_ACTIVE) || (state == WA_CLICKACTIVE)) )
523 {
524 wxActivateEvent event(wxEVT_ACTIVATE, true, m_currentChild->GetId());
525 event.SetEventObject( m_currentChild );
526 if ( m_currentChild->GetEventHandler()->ProcessEvent(event) )
527 processed = true;
528 }
529
530 return processed;
531 }
532
533 bool wxMDIParentFrame::HandleCommand(WXWORD id, WXWORD cmd, WXHWND hwnd)
534 {
535 // In case it's e.g. a toolbar.
536 if ( hwnd )
537 {
538 wxWindow *win = wxFindWinFromHandle(hwnd);
539 if ( win )
540 return win->MSWCommand(cmd, id);
541 }
542
543 if (wxCurrentPopupMenu)
544 {
545 wxMenu *popupMenu = wxCurrentPopupMenu;
546 wxCurrentPopupMenu = NULL;
547 if (popupMenu->MSWCommand(cmd, id))
548 return true;
549 }
550
551 // is it one of standard MDI commands?
552 WXWPARAM wParam = 0;
553 WXLPARAM lParam = 0;
554 int msg;
555 switch ( id )
556 {
557 case IDM_WINDOWCASCADE:
558 msg = WM_MDICASCADE;
559 wParam = MDITILE_SKIPDISABLED;
560 break;
561
562 case IDM_WINDOWTILEHOR:
563 wParam |= MDITILE_HORIZONTAL;
564 // fall through
565
566 case IDM_WINDOWTILEVERT:
567 if ( !wParam )
568 wParam = MDITILE_VERTICAL;
569 msg = WM_MDITILE;
570 wParam |= MDITILE_SKIPDISABLED;
571 break;
572
573 case IDM_WINDOWICONS:
574 msg = WM_MDIICONARRANGE;
575 break;
576
577 case IDM_WINDOWNEXT:
578 msg = WM_MDINEXT;
579 lParam = 0; // next child
580 break;
581
582 case IDM_WINDOWPREV:
583 msg = WM_MDINEXT;
584 lParam = 1; // previous child
585 break;
586
587 default:
588 msg = 0;
589 }
590
591 if ( msg )
592 {
593 ::SendMessage(GetWinHwnd(GetClientWindow()), msg, wParam, lParam);
594
595 return true;
596 }
597
598 // FIXME VZ: what does this test do??
599 if (id >= 0xF000)
600 {
601 return false; // Get WndProc to call default proc
602 }
603
604 if ( IsMdiCommandId(id) )
605 {
606 wxWindowList::compatibility_iterator node = GetChildren().GetFirst();
607 while ( node )
608 {
609 wxWindow *child = node->GetData();
610 if ( child->GetHWND() )
611 {
612 long childId = wxGetWindowId(child->GetHWND());
613 if (childId == (long)id)
614 {
615 ::SendMessage( GetWinHwnd(GetClientWindow()),
616 WM_MDIACTIVATE,
617 (WPARAM)child->GetHWND(), 0);
618 return true;
619 }
620 }
621 node = node->GetNext();
622 }
623 }
624 else if ( m_parentFrameActive )
625 {
626 return ProcessCommand(id);
627 }
628 else if ( m_currentChild )
629 {
630 return m_currentChild->HandleCommand(id, cmd, hwnd);
631 }
632 else
633 {
634 // this shouldn't happen because it means that our messages are being
635 // lost (they're not sent to the parent frame nor to the children)
636 wxFAIL_MSG(wxT("MDI parent frame is not active, yet there is no active MDI child?"));
637 }
638
639 return false;
640 }
641
642 WXLRESULT wxMDIParentFrame::MSWDefWindowProc(WXUINT message,
643 WXWPARAM wParam,
644 WXLPARAM lParam)
645 {
646 WXHWND clientWnd;
647 if ( GetClientWindow() )
648 clientWnd = GetClientWindow()->GetHWND();
649 else
650 clientWnd = 0;
651
652 return DefFrameProc(GetHwnd(), (HWND)clientWnd, message, wParam, lParam);
653 }
654
655 bool wxMDIParentFrame::MSWTranslateMessage(WXMSG* msg)
656 {
657 MSG *pMsg = (MSG *)msg;
658
659 // first let the current child get it
660 if ( m_currentChild && m_currentChild->GetHWND() &&
661 m_currentChild->MSWTranslateMessage(msg) )
662 {
663 return true;
664 }
665
666 // then try out accel table (will also check the menu accels)
667 if ( wxFrame::MSWTranslateMessage(msg) )
668 {
669 return true;
670 }
671
672 // finally, check for MDI specific built in accel keys
673 if ( pMsg->message == WM_KEYDOWN || pMsg->message == WM_SYSKEYDOWN )
674 {
675 if ( ::TranslateMDISysAccel(GetWinHwnd(GetClientWindow()), pMsg))
676 return true;
677 }
678
679 return false;
680 }
681
682 // ===========================================================================
683 // wxMDIChildFrame
684 // ===========================================================================
685
686 void wxMDIChildFrame::Init()
687 {
688 m_needsResize = true;
689 m_needsInitialShow = true;
690 }
691
692 bool wxMDIChildFrame::Create(wxMDIParentFrame *parent,
693 wxWindowID id,
694 const wxString& title,
695 const wxPoint& pos,
696 const wxSize& size,
697 long style,
698 const wxString& name)
699 {
700 SetName(name);
701
702 if ( id != wxID_ANY )
703 m_windowId = id;
704 else
705 m_windowId = (int)NewControlId();
706
707 if ( parent )
708 {
709 parent->AddChild(this);
710 }
711
712 int x = pos.x;
713 int y = pos.y;
714 int width = size.x;
715 int height = size.y;
716
717 MDICREATESTRUCT mcs;
718
719 mcs.szClass = style & wxFULL_REPAINT_ON_RESIZE
720 ? wxMDIChildFrameClassName
721 : wxMDIChildFrameClassNameNoRedraw;
722 mcs.szTitle = title;
723 mcs.hOwner = wxGetInstance();
724 if (x != wxDefaultCoord)
725 mcs.x = x;
726 else
727 mcs.x = CW_USEDEFAULT;
728
729 if (y != wxDefaultCoord)
730 mcs.y = y;
731 else
732 mcs.y = CW_USEDEFAULT;
733
734 if (width != wxDefaultCoord)
735 mcs.cx = width;
736 else
737 mcs.cx = CW_USEDEFAULT;
738
739 if (height != wxDefaultCoord)
740 mcs.cy = height;
741 else
742 mcs.cy = CW_USEDEFAULT;
743
744 DWORD msflags = WS_OVERLAPPED | WS_CLIPCHILDREN;
745 if (style & wxMINIMIZE_BOX)
746 msflags |= WS_MINIMIZEBOX;
747 if (style & wxMAXIMIZE_BOX)
748 msflags |= WS_MAXIMIZEBOX;
749 if (style & wxRESIZE_BORDER)
750 msflags |= WS_THICKFRAME;
751 if (style & wxSYSTEM_MENU)
752 msflags |= WS_SYSMENU;
753 if ((style & wxMINIMIZE) || (style & wxICONIZE))
754 msflags |= WS_MINIMIZE;
755 if (style & wxMAXIMIZE)
756 msflags |= WS_MAXIMIZE;
757 if (style & wxCAPTION)
758 msflags |= WS_CAPTION;
759
760 mcs.style = msflags;
761
762 mcs.lParam = 0;
763
764 wxWindowCreationHook hook(this);
765
766 m_hWnd = (WXHWND)::SendMessage(GetWinHwnd(parent->GetClientWindow()),
767 WM_MDICREATE, 0, (LONG)(LPSTR)&mcs);
768
769 if ( !m_hWnd )
770 {
771 wxLogLastError(_T("WM_MDICREATE"));
772 return false;
773 }
774
775 SubclassWin(m_hWnd);
776
777 return true;
778 }
779
780 wxMDIChildFrame::~wxMDIChildFrame()
781 {
782 // will be destroyed by DestroyChildren() but reset them before calling it
783 // to avoid using dangling pointers if a callback comes in the meanwhile
784 #if wxUSE_TOOLBAR
785 m_frameToolBar = NULL;
786 #endif
787 #if wxUSE_STATUSBAR
788 m_frameStatusBar = NULL;
789 #endif // wxUSE_STATUSBAR
790
791 DestroyChildren();
792
793 RemoveWindowMenu(NULL, m_hMenu);
794
795 MSWDestroyWindow();
796 }
797
798 bool wxMDIChildFrame::Show(bool show)
799 {
800 m_needsInitialShow = false;
801
802 if (!wxFrame::Show(show))
803 return false;
804
805 // KH: Without this call, new MDI children do not become active.
806 // This was added here after the same BringWindowToTop call was
807 // removed from wxTopLevelWindow::Show (November 2005)
808 if ( show )
809 ::BringWindowToTop(GetHwnd());
810
811 // we need to refresh the MDI frame window menu to include (or exclude if
812 // we've been hidden) this frame
813 wxMDIParentFrame *parent = (wxMDIParentFrame *)GetParent();
814 MDISetMenu(parent->GetClientWindow(), NULL, NULL);
815
816 return true;
817 }
818
819 // Set the client size (i.e. leave the calculation of borders etc.
820 // to wxWidgets)
821 void wxMDIChildFrame::DoSetClientSize(int width, int height)
822 {
823 HWND hWnd = GetHwnd();
824
825 RECT rect;
826 ::GetClientRect(hWnd, &rect);
827
828 RECT rect2;
829 GetWindowRect(hWnd, &rect2);
830
831 // Find the difference between the entire window (title bar and all)
832 // and the client area; add this to the new client size to move the
833 // window
834 int actual_width = rect2.right - rect2.left - rect.right + width;
835 int actual_height = rect2.bottom - rect2.top - rect.bottom + height;
836
837 #if wxUSE_STATUSBAR
838 if (GetStatusBar() && GetStatusBar()->IsShown())
839 {
840 int sx, sy;
841 GetStatusBar()->GetSize(&sx, &sy);
842 actual_height += sy;
843 }
844 #endif // wxUSE_STATUSBAR
845
846 POINT point;
847 point.x = rect2.left;
848 point.y = rect2.top;
849
850 // If there's an MDI parent, must subtract the parent's top left corner
851 // since MoveWindow moves relative to the parent
852 wxMDIParentFrame *mdiParent = (wxMDIParentFrame *)GetParent();
853 ::ScreenToClient((HWND) mdiParent->GetClientWindow()->GetHWND(), &point);
854
855 MoveWindow(hWnd, point.x, point.y, actual_width, actual_height, (BOOL)true);
856
857 wxSize size(width, height);
858 wxSizeEvent event(size, m_windowId);
859 event.SetEventObject( this );
860 GetEventHandler()->ProcessEvent(event);
861 }
862
863 void wxMDIChildFrame::DoGetPosition(int *x, int *y) const
864 {
865 RECT rect;
866 GetWindowRect(GetHwnd(), &rect);
867 POINT point;
868 point.x = rect.left;
869 point.y = rect.top;
870
871 // Since we now have the absolute screen coords,
872 // if there's a parent we must subtract its top left corner
873 wxMDIParentFrame *mdiParent = (wxMDIParentFrame *)GetParent();
874 ::ScreenToClient((HWND) mdiParent->GetClientWindow()->GetHWND(), &point);
875
876 if (x)
877 *x = point.x;
878 if (y)
879 *y = point.y;
880 }
881
882 void wxMDIChildFrame::InternalSetMenuBar()
883 {
884 wxMDIParentFrame *parent = (wxMDIParentFrame *)GetParent();
885
886 InsertWindowMenu(parent->GetClientWindow(),
887 m_hMenu, GetMDIWindowMenu(parent));
888
889 parent->m_parentFrameActive = false;
890 }
891
892 void wxMDIChildFrame::DetachMenuBar()
893 {
894 RemoveWindowMenu(NULL, m_hMenu);
895 wxFrame::DetachMenuBar();
896 }
897
898 WXHICON wxMDIChildFrame::GetDefaultIcon() const
899 {
900 // we don't have any standard icons (any more)
901 return (WXHICON)0;
902 }
903
904 // ---------------------------------------------------------------------------
905 // MDI operations
906 // ---------------------------------------------------------------------------
907
908 void wxMDIChildFrame::Maximize(bool maximize)
909 {
910 wxMDIParentFrame *parent = (wxMDIParentFrame *)GetParent();
911 if ( parent && parent->GetClientWindow() )
912 {
913 ::SendMessage(GetWinHwnd(parent->GetClientWindow()),
914 maximize ? WM_MDIMAXIMIZE : WM_MDIRESTORE,
915 (WPARAM)GetHwnd(), 0);
916 }
917 }
918
919 void wxMDIChildFrame::Restore()
920 {
921 wxMDIParentFrame *parent = (wxMDIParentFrame *)GetParent();
922 if ( parent && parent->GetClientWindow() )
923 {
924 ::SendMessage(GetWinHwnd(parent->GetClientWindow()), WM_MDIRESTORE,
925 (WPARAM) GetHwnd(), 0);
926 }
927 }
928
929 void wxMDIChildFrame::Activate()
930 {
931 wxMDIParentFrame *parent = (wxMDIParentFrame *)GetParent();
932 if ( parent && parent->GetClientWindow() )
933 {
934 ::SendMessage(GetWinHwnd(parent->GetClientWindow()), WM_MDIACTIVATE,
935 (WPARAM) GetHwnd(), 0);
936 }
937 }
938
939 // ---------------------------------------------------------------------------
940 // MDI window proc and message handlers
941 // ---------------------------------------------------------------------------
942
943 WXLRESULT wxMDIChildFrame::MSWWindowProc(WXUINT message,
944 WXWPARAM wParam,
945 WXLPARAM lParam)
946 {
947 WXLRESULT rc = 0;
948 bool processed = false;
949
950 switch ( message )
951 {
952 case WM_COMMAND:
953 {
954 WORD id, cmd;
955 WXHWND hwnd;
956 UnpackCommand((WXWPARAM)wParam, (WXLPARAM)lParam,
957 &id, &hwnd, &cmd);
958
959 processed = HandleCommand(id, cmd, (WXHWND)hwnd);
960 }
961 break;
962
963 case WM_GETMINMAXINFO:
964 processed = HandleGetMinMaxInfo((MINMAXINFO *)lParam);
965 break;
966
967 case WM_MDIACTIVATE:
968 {
969 WXWORD act;
970 WXHWND hwndAct, hwndDeact;
971 UnpackMDIActivate(wParam, lParam, &act, &hwndAct, &hwndDeact);
972
973 processed = HandleMDIActivate(act, hwndAct, hwndDeact);
974 }
975 // fall through
976
977 case WM_MOVE:
978 // must pass WM_MOVE to DefMDIChildProc() to recalculate MDI client
979 // scrollbars if necessary
980
981 // fall through
982
983 case WM_SIZE:
984 // must pass WM_SIZE to DefMDIChildProc(), otherwise many weird
985 // things happen
986 MSWDefWindowProc(message, wParam, lParam);
987 break;
988
989 case WM_SYSCOMMAND:
990 // DefMDIChildProc handles SC_{NEXT/PREV}WINDOW here, so pass it
991 // the message (the base class version does not)
992 return MSWDefWindowProc(message, wParam, lParam);
993
994 case WM_WINDOWPOSCHANGING:
995 processed = HandleWindowPosChanging((LPWINDOWPOS)lParam);
996 break;
997 }
998
999 if ( !processed )
1000 rc = wxFrame::MSWWindowProc(message, wParam, lParam);
1001
1002 return rc;
1003 }
1004
1005 bool wxMDIChildFrame::HandleCommand(WXWORD id, WXWORD cmd, WXHWND hwnd)
1006 {
1007 // In case it's e.g. a toolbar.
1008 if ( hwnd )
1009 {
1010 wxWindow *win = wxFindWinFromHandle(hwnd);
1011 if (win)
1012 return win->MSWCommand(cmd, id);
1013 }
1014
1015 if (wxCurrentPopupMenu)
1016 {
1017 wxMenu *popupMenu = wxCurrentPopupMenu;
1018 wxCurrentPopupMenu = NULL;
1019 if (popupMenu->MSWCommand(cmd, id))
1020 return true;
1021 }
1022
1023 bool processed;
1024 if (GetMenuBar() && GetMenuBar()->FindItem(id))
1025 {
1026 processed = ProcessCommand(id);
1027 }
1028 else
1029 {
1030 processed = false;
1031 }
1032
1033 return processed;
1034 }
1035
1036 bool wxMDIChildFrame::HandleMDIActivate(long WXUNUSED(activate),
1037 WXHWND hwndAct,
1038 WXHWND hwndDeact)
1039 {
1040 wxMDIParentFrame *parent = (wxMDIParentFrame *)GetParent();
1041
1042 HMENU menuToSet = 0;
1043
1044 bool activated;
1045
1046 if ( m_hWnd == hwndAct )
1047 {
1048 activated = true;
1049 parent->m_currentChild = this;
1050
1051 HMENU child_menu = (HMENU)GetWinMenu();
1052 if ( child_menu )
1053 {
1054 parent->m_parentFrameActive = false;
1055
1056 menuToSet = child_menu;
1057 }
1058 }
1059 else if ( m_hWnd == hwndDeact )
1060 {
1061 wxASSERT_MSG( parent->m_currentChild == this,
1062 wxT("can't deactivate MDI child which wasn't active!") );
1063
1064 activated = false;
1065 parent->m_currentChild = NULL;
1066
1067 HMENU parent_menu = (HMENU)parent->GetWinMenu();
1068
1069 // activate the the parent menu only when there is no other child
1070 // that has been activated
1071 if ( parent_menu && !hwndAct )
1072 {
1073 parent->m_parentFrameActive = true;
1074
1075 menuToSet = parent_menu;
1076 }
1077 }
1078 else
1079 {
1080 // we have nothing to do with it
1081 return false;
1082 }
1083
1084 if ( menuToSet )
1085 {
1086 MDISetMenu(parent->GetClientWindow(),
1087 menuToSet, GetMDIWindowMenu(parent));
1088 }
1089
1090 wxActivateEvent event(wxEVT_ACTIVATE, activated, m_windowId);
1091 event.SetEventObject( this );
1092
1093 ResetWindowStyle((void *)NULL);
1094
1095 return GetEventHandler()->ProcessEvent(event);
1096 }
1097
1098 bool wxMDIChildFrame::HandleWindowPosChanging(void *pos)
1099 {
1100 WINDOWPOS *lpPos = (WINDOWPOS *)pos;
1101
1102 if (!(lpPos->flags & SWP_NOSIZE))
1103 {
1104 RECT rectClient;
1105 DWORD dwExStyle = ::GetWindowLong(GetHwnd(), GWL_EXSTYLE);
1106 DWORD dwStyle = ::GetWindowLong(GetHwnd(), GWL_STYLE);
1107 if (ResetWindowStyle((void *) & rectClient) && (dwStyle & WS_MAXIMIZE))
1108 {
1109 ::AdjustWindowRectEx(&rectClient, dwStyle, false, dwExStyle);
1110 lpPos->x = rectClient.left;
1111 lpPos->y = rectClient.top;
1112 lpPos->cx = rectClient.right - rectClient.left;
1113 lpPos->cy = rectClient.bottom - rectClient.top;
1114 }
1115 }
1116
1117 return false;
1118 }
1119
1120 bool wxMDIChildFrame::HandleGetMinMaxInfo(void *mmInfo)
1121 {
1122 MINMAXINFO *info = (MINMAXINFO *)mmInfo;
1123
1124 // let the default window proc calculate the size of MDI children
1125 // frames because it is based on the size of the MDI client window,
1126 // not on the values specified in wxWindow m_max variables
1127 bool processed = MSWDefWindowProc(WM_GETMINMAXINFO, 0, (LPARAM)mmInfo) != 0;
1128
1129 int minWidth = GetMinWidth(),
1130 minHeight = GetMinHeight();
1131
1132 // but allow GetSizeHints() to set the min size
1133 if ( minWidth != wxDefaultCoord )
1134 {
1135 info->ptMinTrackSize.x = minWidth;
1136
1137 processed = true;
1138 }
1139
1140 if ( minHeight != wxDefaultCoord )
1141 {
1142 info->ptMinTrackSize.y = minHeight;
1143
1144 processed = true;
1145 }
1146
1147 return processed;
1148 }
1149
1150 // ---------------------------------------------------------------------------
1151 // MDI specific message translation/preprocessing
1152 // ---------------------------------------------------------------------------
1153
1154 WXLRESULT wxMDIChildFrame::MSWDefWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam)
1155 {
1156 return DefMDIChildProc(GetHwnd(),
1157 (UINT)message, (WPARAM)wParam, (LPARAM)lParam);
1158 }
1159
1160 bool wxMDIChildFrame::MSWTranslateMessage(WXMSG* msg)
1161 {
1162 // we must pass the parent frame to ::TranslateAccelerator(), otherwise it
1163 // doesn't do its job correctly for MDI child menus
1164 return MSWDoTranslateMessage((wxMDIChildFrame *)GetParent(), msg);
1165 }
1166
1167 // ---------------------------------------------------------------------------
1168 // misc
1169 // ---------------------------------------------------------------------------
1170
1171 void wxMDIChildFrame::MSWDestroyWindow()
1172 {
1173 wxMDIParentFrame *parent = (wxMDIParentFrame *)GetParent();
1174
1175 // Must make sure this handle is invalidated (set to NULL) since all sorts
1176 // of things could happen after the child client is destroyed, but before
1177 // the wxFrame is destroyed.
1178
1179 HWND oldHandle = (HWND)GetHWND();
1180 SendMessage(GetWinHwnd(parent->GetClientWindow()), WM_MDIDESTROY,
1181 (WPARAM)oldHandle, 0);
1182
1183 if (parent->GetActiveChild() == (wxMDIChildFrame*) NULL)
1184 ResetWindowStyle((void*) NULL);
1185
1186 if (m_hMenu)
1187 {
1188 ::DestroyMenu((HMENU) m_hMenu);
1189 m_hMenu = 0;
1190 }
1191 wxRemoveHandleAssociation(this);
1192 m_hWnd = 0;
1193 }
1194
1195 // Change the client window's extended style so we don't get a client edge
1196 // style when a child is maximised (a double border looks silly.)
1197 bool wxMDIChildFrame::ResetWindowStyle(void *vrect)
1198 {
1199 RECT *rect = (RECT *)vrect;
1200 wxMDIParentFrame* pFrameWnd = (wxMDIParentFrame *)GetParent();
1201 wxMDIChildFrame* pChild = pFrameWnd->GetActiveChild();
1202
1203 if (!pChild || (pChild == this))
1204 {
1205 HWND hwndClient = GetWinHwnd(pFrameWnd->GetClientWindow());
1206 DWORD dwStyle = ::GetWindowLong(hwndClient, GWL_EXSTYLE);
1207
1208 // we want to test whether there is a maximized child, so just set
1209 // dwThisStyle to 0 if there is no child at all
1210 DWORD dwThisStyle = pChild
1211 ? ::GetWindowLong(GetWinHwnd(pChild), GWL_STYLE) : 0;
1212 DWORD dwNewStyle = dwStyle;
1213 if ( dwThisStyle & WS_MAXIMIZE )
1214 dwNewStyle &= ~(WS_EX_CLIENTEDGE);
1215 else
1216 dwNewStyle |= WS_EX_CLIENTEDGE;
1217
1218 if (dwStyle != dwNewStyle)
1219 {
1220 // force update of everything
1221 ::RedrawWindow(hwndClient, NULL, NULL,
1222 RDW_INVALIDATE | RDW_ALLCHILDREN);
1223 ::SetWindowLong(hwndClient, GWL_EXSTYLE, dwNewStyle);
1224 ::SetWindowPos(hwndClient, NULL, 0, 0, 0, 0,
1225 SWP_FRAMECHANGED | SWP_NOACTIVATE |
1226 SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER |
1227 SWP_NOCOPYBITS);
1228 if (rect)
1229 ::GetClientRect(hwndClient, rect);
1230
1231 return true;
1232 }
1233 }
1234
1235 return false;
1236 }
1237
1238 // ===========================================================================
1239 // wxMDIClientWindow: the window of predefined (by Windows) class which
1240 // contains the child frames
1241 // ===========================================================================
1242
1243 bool wxMDIClientWindow::CreateClient(wxMDIParentFrame *parent, long style)
1244 {
1245 m_backgroundColour = wxSystemSettings::GetColour(wxSYS_COLOUR_APPWORKSPACE);
1246
1247 CLIENTCREATESTRUCT ccs;
1248 m_windowStyle = style;
1249 m_parent = parent;
1250
1251 ccs.hWindowMenu = GetMDIWindowMenu(parent);
1252 ccs.idFirstChild = wxFIRST_MDI_CHILD;
1253
1254 DWORD msStyle = MDIS_ALLCHILDSTYLES | WS_VISIBLE | WS_CHILD |
1255 WS_CLIPCHILDREN | WS_CLIPSIBLINGS;
1256
1257 if ( style & wxHSCROLL )
1258 msStyle |= WS_HSCROLL;
1259 if ( style & wxVSCROLL )
1260 msStyle |= WS_VSCROLL;
1261
1262 DWORD exStyle = WS_EX_CLIENTEDGE;
1263
1264 wxWindowCreationHook hook(this);
1265 m_hWnd = (WXHWND)::CreateWindowEx
1266 (
1267 exStyle,
1268 wxT("MDICLIENT"),
1269 NULL,
1270 msStyle,
1271 0, 0, 0, 0,
1272 GetWinHwnd(parent),
1273 NULL,
1274 wxGetInstance(),
1275 (LPSTR)(LPCLIENTCREATESTRUCT)&ccs);
1276 if ( !m_hWnd )
1277 {
1278 wxLogLastError(wxT("CreateWindowEx(MDI client)"));
1279
1280 return false;
1281 }
1282
1283 SubclassWin(m_hWnd);
1284
1285 return true;
1286 }
1287
1288 // Explicitly call default scroll behaviour
1289 void wxMDIClientWindow::OnScroll(wxScrollEvent& event)
1290 {
1291 // Note: for client windows, the scroll position is not set in
1292 // WM_HSCROLL, WM_VSCROLL, so we can't easily determine what
1293 // scroll position we're at.
1294 // This makes it hard to paint patterns or bitmaps in the background,
1295 // and have the client area scrollable as well.
1296
1297 if ( event.GetOrientation() == wxHORIZONTAL )
1298 m_scrollX = event.GetPosition(); // Always returns zero!
1299 else
1300 m_scrollY = event.GetPosition(); // Always returns zero!
1301
1302 event.Skip();
1303 }
1304
1305 void wxMDIClientWindow::DoSetSize(int x, int y, int width, int height, int sizeFlags)
1306 {
1307 // Try to fix a problem whereby if you show an MDI child frame, then reposition the
1308 // client area, you can end up with a non-refreshed portion in the client window
1309 // (see OGL studio sample). So check if the position is changed and if so,
1310 // redraw the MDI child frames.
1311
1312 const wxPoint oldPos = GetPosition();
1313
1314 wxWindow::DoSetSize(x, y, width, height, sizeFlags | wxSIZE_FORCE);
1315
1316 const wxPoint newPos = GetPosition();
1317
1318 if ((newPos.x != oldPos.x) || (newPos.y != oldPos.y))
1319 {
1320 if (GetParent())
1321 {
1322 wxWindowList::compatibility_iterator node = GetParent()->GetChildren().GetFirst();
1323 while (node)
1324 {
1325 wxWindow *child = node->GetData();
1326 if (child->IsKindOf(CLASSINFO(wxMDIChildFrame)))
1327 {
1328 ::RedrawWindow(GetHwndOf(child),
1329 NULL,
1330 NULL,
1331 RDW_FRAME |
1332 RDW_ALLCHILDREN |
1333 RDW_INVALIDATE);
1334 }
1335 node = node->GetNext();
1336 }
1337 }
1338 }
1339 }
1340
1341 void wxMDIChildFrame::OnIdle(wxIdleEvent& event)
1342 {
1343 // wxMSW prior to 2.5.3 created MDI child frames as visible, which resulted
1344 // in flicker e.g. when the frame contained controls with non-trivial
1345 // layout. Since 2.5.3, the frame is created hidden as all other top level
1346 // windows. In order to maintain backward compatibility, the frame is shown
1347 // in OnIdle, unless Show(false) was called by the programmer before.
1348 if ( m_needsInitialShow )
1349 {
1350 Show(true);
1351 }
1352
1353 // MDI child frames get their WM_SIZE when they're constructed but at this
1354 // moment they don't have any children yet so all child windows will be
1355 // positioned incorrectly when they are added later - to fix this, we
1356 // generate an artificial size event here
1357 if ( m_needsResize )
1358 {
1359 m_needsResize = false; // avoid any possibility of recursion
1360
1361 SendSizeEvent();
1362 }
1363
1364 event.Skip();
1365 }
1366
1367 // ---------------------------------------------------------------------------
1368 // non member functions
1369 // ---------------------------------------------------------------------------
1370
1371 static void MDISetMenu(wxWindow *win, HMENU hmenuFrame, HMENU hmenuWindow)
1372 {
1373 if ( hmenuFrame || hmenuWindow )
1374 {
1375 if ( !::SendMessage(GetWinHwnd(win),
1376 WM_MDISETMENU,
1377 (WPARAM)hmenuFrame,
1378 (LPARAM)hmenuWindow) )
1379 {
1380 wxLogLastError(_T("SendMessage(WM_MDISETMENU)"));
1381 }
1382 }
1383
1384 // update menu bar of the parent window
1385 wxWindow *parent = win->GetParent();
1386 wxCHECK_RET( parent, wxT("MDI client without parent frame? weird...") );
1387
1388 ::SendMessage(GetWinHwnd(win), WM_MDIREFRESHMENU, 0, 0L);
1389
1390 ::DrawMenuBar(GetWinHwnd(parent));
1391 }
1392
1393 static void InsertWindowMenu(wxWindow *win, WXHMENU menu, HMENU subMenu)
1394 {
1395 // Try to insert Window menu in front of Help, otherwise append it.
1396 HMENU hmenu = (HMENU)menu;
1397
1398 if (subMenu)
1399 {
1400 int N = GetMenuItemCount(hmenu);
1401 bool success = false;
1402 for ( int i = 0; i < N; i++ )
1403 {
1404 wxChar buf[256];
1405 int chars = GetMenuString(hmenu, i, buf, WXSIZEOF(buf), MF_BYPOSITION);
1406 if ( chars == 0 )
1407 {
1408 wxLogLastError(wxT("GetMenuString"));
1409
1410 continue;
1411 }
1412
1413 wxString strBuf(buf);
1414 if ( wxStripMenuCodes(strBuf) == wxGetStockLabel(wxID_HELP,false) )
1415 {
1416 success = true;
1417 ::InsertMenu(hmenu, i, MF_BYPOSITION | MF_POPUP | MF_STRING,
1418 (UINT)subMenu, _("&Window"));
1419 break;
1420 }
1421 }
1422
1423 if ( !success )
1424 {
1425 ::AppendMenu(hmenu, MF_POPUP, (UINT)subMenu, _("&Window"));
1426 }
1427 }
1428
1429 MDISetMenu(win, hmenu, subMenu);
1430 }
1431
1432 static void RemoveWindowMenu(wxWindow *win, WXHMENU menu)
1433 {
1434 HMENU hMenu = (HMENU)menu;
1435
1436 if ( hMenu )
1437 {
1438 wxChar buf[1024];
1439
1440 int N = ::GetMenuItemCount(hMenu);
1441 for ( int i = 0; i < N; i++ )
1442 {
1443 if ( !::GetMenuString(hMenu, i, buf, WXSIZEOF(buf), MF_BYPOSITION) )
1444 {
1445 // Ignore successful read of menu string with length 0 which
1446 // occurs, for example, for a maximized MDI childs system menu
1447 if ( ::GetLastError() != 0 )
1448 {
1449 wxLogLastError(wxT("GetMenuString"));
1450 }
1451
1452 continue;
1453 }
1454
1455 if ( wxStrcmp(buf, _("&Window")) == 0 )
1456 {
1457 if ( !::RemoveMenu(hMenu, i, MF_BYPOSITION) )
1458 {
1459 wxLogLastError(wxT("RemoveMenu"));
1460 }
1461
1462 break;
1463 }
1464 }
1465 }
1466
1467 if ( win )
1468 {
1469 // we don't change the windows menu, but we update the main one
1470 MDISetMenu(win, hMenu, NULL);
1471 }
1472 }
1473
1474 static void UnpackMDIActivate(WXWPARAM wParam, WXLPARAM lParam,
1475 WXWORD *activate, WXHWND *hwndAct, WXHWND *hwndDeact)
1476 {
1477 *activate = true;
1478 *hwndAct = (WXHWND)lParam;
1479 *hwndDeact = (WXHWND)wParam;
1480 }
1481
1482 #endif // wxUSE_MDI && !defined(__WXUNIVERSAL__)