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