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