]> git.saurik.com Git - wxWidgets.git/blame - src/msw/mdi.cpp
VisualAge C++ V4.0 configuration files
[wxWidgets.git] / src / msw / mdi.cpp
CommitLineData
2bda0e17
KB
1/////////////////////////////////////////////////////////////////////////////
2// Name: mdi.cpp
3// Purpose: MDI classes
4// Author: Julian Smart
5// Modified by:
6// Created: 04/01/98
7// RCS-ID: $Id$
8// Copyright: (c) Julian Smart and Markus Holzem
c2dcfdef 9// Licence: wxWindows license
2bda0e17
KB
10/////////////////////////////////////////////////////////////////////////////
11
a23fd0e1
VZ
12// ===========================================================================
13// declarations
14// ===========================================================================
15
16// ---------------------------------------------------------------------------
17// headers
18// ---------------------------------------------------------------------------
19
2bda0e17 20#ifdef __GNUG__
a23fd0e1 21 #pragma implementation "mdi.h"
2bda0e17
KB
22#endif
23
24// For compilers that support precompilation, includes "wx.h".
25#include "wx/wxprec.h"
26
27#ifdef __BORLANDC__
a23fd0e1 28 #pragma hdrstop
2bda0e17
KB
29#endif
30
31#ifndef WX_PRECOMP
a23fd0e1
VZ
32 #include "wx/setup.h"
33 #include "wx/frame.h"
34 #include "wx/menu.h"
35 #include "wx/app.h"
36 #include "wx/utils.h"
37 #include "wx/dialog.h"
38 #include "wx/statusbr.h"
39 #include "wx/settings.h"
0c589ad0
BM
40 #include "wx/intl.h"
41 #include "wx/log.h"
2bda0e17
KB
42#endif
43
44#include "wx/mdi.h"
45#include "wx/msw/private.h"
46
47d67540 47#if wxUSE_NATIVE_STATUSBAR
a23fd0e1 48 #include <wx/msw/statbr95.h>
2bda0e17
KB
49#endif
50
51#include <string.h>
52
a23fd0e1
VZ
53// ---------------------------------------------------------------------------
54// global variables
55// ---------------------------------------------------------------------------
56
57extern wxWindowList wxModelessWindows; // from dialog.cpp
e1a6fc11 58extern wxMenu *wxCurrentPopupMenu;
2bda0e17 59
837e5743
OK
60extern wxChar wxMDIFrameClassName[];
61extern wxChar wxMDIChildFrameClassName[];
a23fd0e1
VZ
62extern wxWindow *wxWndHook; // from window.cpp
63
c7527e3f 64extern void wxAssociateWinWithHandle(HWND hWnd, wxWindow *win);
a23fd0e1 65
42e69d6b
VZ
66static HWND invalidHandle = 0;
67
a23fd0e1
VZ
68// ---------------------------------------------------------------------------
69// constants
70// ---------------------------------------------------------------------------
71
72static const int IDM_WINDOWTILE = 4001;
42e69d6b 73static const int IDM_WINDOWTILEHOR = 4001;
a23fd0e1
VZ
74static const int IDM_WINDOWCASCADE = 4002;
75static const int IDM_WINDOWICONS = 4003;
76static const int IDM_WINDOWNEXT = 4004;
42e69d6b 77static const int IDM_WINDOWTILEVERT = 4005;
a23fd0e1
VZ
78
79// This range gives a maximum of 500 MDI children. Should be enough :-)
80static const int wxFIRST_MDI_CHILD = 4100;
81static const int wxLAST_MDI_CHILD = 4600;
2bda0e17
KB
82
83// Status border dimensions
a23fd0e1
VZ
84static const int wxTHICK_LINE_BORDER = 3;
85static const int wxTHICK_LINE_WIDTH = 1;
2bda0e17 86
42e69d6b
VZ
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)
93static 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
97static void InsertWindowMenu(wxWindow *win, WXHMENU menu, HMENU subMenu);
98
99// is this an id of an MDI child?
100inline bool IsMdiCommandId(int id)
101{
102 return (id >= wxFIRST_MDI_CHILD) && (id <= wxLAST_MDI_CHILD);
103}
104
2917e920
BM
105static void UnpackMDIActivate(WXWPARAM wParam, WXLPARAM lParam,
106 WXWORD *activate, WXHWND *hwndAct, WXHWND *hwndDeact);
42e69d6b 107
a23fd0e1
VZ
108// ===========================================================================
109// implementation
110// ===========================================================================
111
112// ---------------------------------------------------------------------------
113// wxWin macros
114// ---------------------------------------------------------------------------
2bda0e17
KB
115
116#if !USE_SHARED_LIBRARY
a23fd0e1
VZ
117 IMPLEMENT_DYNAMIC_CLASS(wxMDIParentFrame, wxFrame)
118 IMPLEMENT_DYNAMIC_CLASS(wxMDIChildFrame, wxFrame)
119 IMPLEMENT_DYNAMIC_CLASS(wxMDIClientWindow, wxWindow)
120#endif // USE_SHARED_LIBRARY
2bda0e17
KB
121
122BEGIN_EVENT_TABLE(wxMDIParentFrame, wxFrame)
a23fd0e1 123 EVT_SIZE(wxMDIParentFrame::OnSize)
a23fd0e1 124 EVT_SYS_COLOUR_CHANGED(wxMDIParentFrame::OnSysColourChanged)
2bda0e17
KB
125END_EVENT_TABLE()
126
127BEGIN_EVENT_TABLE(wxMDIClientWindow, wxWindow)
a23fd0e1 128 EVT_SCROLL(wxMDIClientWindow::OnScroll)
2bda0e17
KB
129END_EVENT_TABLE()
130
42e69d6b
VZ
131// ===========================================================================
132// wxMDIParentFrame: the frame which contains the client window which manages
133// the children
134// ===========================================================================
2bda0e17 135
c2dcfdef 136wxMDIParentFrame::wxMDIParentFrame()
2bda0e17
KB
137{
138 m_clientWindow = NULL;
139 m_currentChild = NULL;
140 m_windowMenu = 0;
141 m_parentFrameActive = TRUE;
2bda0e17
KB
142}
143
144bool wxMDIParentFrame::Create(wxWindow *parent,
a23fd0e1
VZ
145 wxWindowID id,
146 const wxString& title,
147 const wxPoint& pos,
148 const wxSize& size,
149 long style,
150 const wxString& name)
2bda0e17
KB
151{
152 m_defaultIcon = (WXHICON) (wxSTD_MDIPARENTFRAME_ICON ? wxSTD_MDIPARENTFRAME_ICON : wxDEFAULT_MDIPARENTFRAME_ICON);
153
2bda0e17
KB
154 m_clientWindow = NULL;
155 m_currentChild = NULL;
156 m_windowMenu = 0;
157 m_parentFrameActive = TRUE;
158
159 if (!parent)
160 wxTopLevelWindows.Append(this);
161
162 SetName(name);
163 m_windowStyle = style;
164
165 if (parent) parent->AddChild(this);
166
167 if ( id > -1 )
168 m_windowId = id;
169 else
170 m_windowId = (int)NewControlId();
171
172 int x = pos.x;
173 int y = pos.y;
174 int width = size.x;
175 int height = size.y;
176
837e5743 177 m_windowMenu = (WXHMENU) ::LoadMenu(wxGetInstance(), _T("wxWindowMenu"));
2bda0e17 178
42e69d6b 179 DWORD msflags = WS_OVERLAPPED;
2bda0e17
KB
180 if (style & wxMINIMIZE_BOX)
181 msflags |= WS_MINIMIZEBOX;
182 if (style & wxMAXIMIZE_BOX)
183 msflags |= WS_MAXIMIZEBOX;
184 if (style & wxTHICK_FRAME)
185 msflags |= WS_THICKFRAME;
186 if (style & wxSYSTEM_MENU)
187 msflags |= WS_SYSMENU;
188 if ((style & wxMINIMIZE) || (style & wxICONIZE))
189 msflags |= WS_MINIMIZE;
190 if (style & wxMAXIMIZE)
191 msflags |= WS_MAXIMIZE;
192 if (style & wxCAPTION)
193 msflags |= WS_CAPTION;
46851318 194
0655ad29
VZ
195 if (style & wxCLIP_CHILDREN)
196 msflags |= WS_CLIPCHILDREN;
2bda0e17
KB
197
198 wxWindow::MSWCreate(m_windowId, parent, wxMDIFrameClassName, this, title, x, y, width, height,
199 msflags);
200
201 wxModelessWindows.Append(this);
202
203 return TRUE;
204}
205
c2dcfdef 206wxMDIParentFrame::~wxMDIParentFrame()
2bda0e17 207{
42e69d6b 208 DestroyChildren();
2bda0e17 209
42e69d6b
VZ
210 ::DestroyMenu((HMENU)m_windowMenu);
211 m_windowMenu = 0;
2bda0e17 212
42e69d6b
VZ
213 if ( m_clientWindow )
214 {
215 if ( m_clientWindow->MSWGetOldWndProc() )
216 m_clientWindow->UnsubclassWin();
2bda0e17 217
42e69d6b
VZ
218 m_clientWindow->SetHWND(0);
219 delete m_clientWindow;
220 }
2bda0e17
KB
221}
222
42e69d6b 223void wxMDIParentFrame::InternalSetMenuBar()
2bda0e17 224{
42e69d6b 225 HMENU subMenu = GetSubMenu((HMENU) m_windowMenu, 0);
2bda0e17 226
42e69d6b 227 m_parentFrameActive = TRUE;
2bda0e17 228
42e69d6b 229 InsertWindowMenu(GetClientWindow(), m_hMenu, subMenu);
2bda0e17
KB
230}
231
232void wxMDIParentFrame::OnSize(wxSizeEvent& event)
233{
2bda0e17 234 if ( GetClientWindow() )
42e69d6b
VZ
235 {
236 int width, height;
237 GetClientSize(&width, &height);
2bda0e17 238
42e69d6b
VZ
239 GetClientWindow()->SetSize(0, 0, width, height);
240 }
2bda0e17
KB
241}
242
2bda0e17 243// Returns the active MDI child window
c2dcfdef 244wxMDIChildFrame *wxMDIParentFrame::GetActiveChild() const
2bda0e17 245{
a23fd0e1
VZ
246 HWND hWnd = (HWND)::SendMessage(GetWinHwnd(GetClientWindow()),
247 WM_MDIGETACTIVE, 0, 0L);
248 if ( hWnd == 0 )
249 return NULL;
250 else
251 return (wxMDIChildFrame *)wxFindWinFromHandle((WXHWND) hWnd);
2bda0e17
KB
252}
253
a23fd0e1
VZ
254// Create the client window class (don't Create the window, just return a new
255// class)
c2dcfdef 256wxMDIClientWindow *wxMDIParentFrame::OnCreateClient()
2bda0e17 257{
a23fd0e1 258 return new wxMDIClientWindow;
2bda0e17
KB
259}
260
261// Responds to colour changes, and passes event on to children.
262void wxMDIParentFrame::OnSysColourChanged(wxSysColourChangedEvent& event)
263{
264 if ( m_clientWindow )
265 {
266 m_clientWindow->SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_APPWORKSPACE));
267 m_clientWindow->Refresh();
268 }
2bda0e17 269
42e69d6b 270 event.Skip();
2bda0e17
KB
271}
272
42e69d6b 273// ---------------------------------------------------------------------------
2bda0e17 274// MDI operations
42e69d6b
VZ
275// ---------------------------------------------------------------------------
276
c2dcfdef 277void wxMDIParentFrame::Cascade()
2bda0e17 278{
a23fd0e1 279 ::SendMessage(GetWinHwnd(GetClientWindow()), WM_MDICASCADE, 0, 0);
2bda0e17
KB
280}
281
42e69d6b 282// TODO: add a direction argument (hor/vert)
c2dcfdef 283void wxMDIParentFrame::Tile()
2bda0e17 284{
a23fd0e1 285 ::SendMessage(GetWinHwnd(GetClientWindow()), WM_MDITILE, MDITILE_HORIZONTAL, 0);
2bda0e17
KB
286}
287
c2dcfdef 288void wxMDIParentFrame::ArrangeIcons()
2bda0e17 289{
a23fd0e1 290 ::SendMessage(GetWinHwnd(GetClientWindow()), WM_MDIICONARRANGE, 0, 0);
2bda0e17
KB
291}
292
c2dcfdef 293void wxMDIParentFrame::ActivateNext()
2bda0e17 294{
a23fd0e1 295 ::SendMessage(GetWinHwnd(GetClientWindow()), WM_MDINEXT, 0, 0);
2bda0e17
KB
296}
297
c2dcfdef 298void wxMDIParentFrame::ActivatePrevious()
2bda0e17 299{
a23fd0e1 300 ::SendMessage(GetWinHwnd(GetClientWindow()), WM_MDINEXT, 0, 1);
2bda0e17
KB
301}
302
42e69d6b 303// ---------------------------------------------------------------------------
a23fd0e1 304// the MDI parent frame window proc
42e69d6b
VZ
305// ---------------------------------------------------------------------------
306
a23fd0e1
VZ
307long wxMDIParentFrame::MSWWindowProc(WXUINT message,
308 WXWPARAM wParam,
309 WXLPARAM lParam)
2bda0e17 310{
a23fd0e1
VZ
311 long rc = 0;
312 bool processed = FALSE;
2bda0e17 313
a23fd0e1
VZ
314 switch ( message )
315 {
42e69d6b
VZ
316 case WM_ACTIVATE:
317 {
318 WXWORD state, minimized;
319 WXHWND hwnd;
320 UnpackActivate(wParam, lParam, &state, &minimized, &hwnd);
321
322 processed = HandleActivate(state, minimized != 0, hwnd);
323 }
324 break;
325
326 case WM_COMMAND:
327 {
328 WXWORD id, cmd;
329 WXHWND hwnd;
330 UnpackCommand(wParam, lParam, &id, &hwnd, &cmd);
331
332 (void)HandleCommand(id, cmd, hwnd);
333
334 // even if the frame didn't process it, there is no need to try it
335 // once again (i.e. call wxFrame::HandleCommand()) - we just dud it,
336 // so pretend we processed the message anyhow
337 processed = TRUE;
338 }
b3818fbe
VZ
339
340 // always pass this message DefFrameProc(), otherwise MDI menu
341 // commands (and sys commands - more surprizingly!) won't work
342 MSWDefWindowProc(message, wParam, lParam);
42e69d6b
VZ
343 break;
344
a23fd0e1
VZ
345 case WM_CREATE:
346 m_clientWindow = OnCreateClient();
347 // Uses own style for client style
348 if ( !m_clientWindow->CreateClient(this, GetWindowStyleFlag()) )
349 {
350 wxLogMessage(_("Failed to create MDI parent frame."));
2bda0e17 351
a23fd0e1
VZ
352 rc = -1;
353 }
2bda0e17 354
a23fd0e1
VZ
355 processed = TRUE;
356 break;
2bda0e17 357
a23fd0e1
VZ
358 case WM_ERASEBKGND:
359 processed = TRUE;
2bda0e17 360
a23fd0e1
VZ
361 // we erase background ourselves
362 rc = TRUE;
363 break;
364
365 case WM_MENUSELECT:
366 {
42e69d6b
VZ
367 WXWORD item, flags;
368 WXHMENU hmenu;
369 UnpackMenuSelect(wParam, lParam, &item, &flags, &hmenu);
370
a23fd0e1
VZ
371 if ( m_parentFrameActive )
372 {
42e69d6b 373 processed = HandleMenuSelect(item, flags, hmenu);
a23fd0e1
VZ
374 }
375 else if (m_currentChild)
376 {
377 processed = m_currentChild->
42e69d6b 378 HandleMenuSelect(item, flags, hmenu);
a23fd0e1
VZ
379 }
380 }
381 break;
b3818fbe
VZ
382
383 case WM_SIZE:
0655ad29
VZ
384 // as we don't (usually) resize the MDI client to exactly fit the
385 // client area (we put it below the toolbar, above statusbar &c),
386 // we should not pass this one to DefFrameProc
b3818fbe 387 break;
a23fd0e1 388 }
2bda0e17 389
a23fd0e1
VZ
390 if ( !processed )
391 rc = wxFrame::MSWWindowProc(message, wParam, lParam);
2bda0e17 392
a23fd0e1 393 return rc;
2bda0e17
KB
394}
395
42e69d6b 396bool wxMDIParentFrame::HandleActivate(int state, bool minimized, WXHWND activate)
2bda0e17 397{
a23fd0e1
VZ
398 bool processed = FALSE;
399
42e69d6b 400 if ( wxWindow::HandleActivate(state, minimized, activate) )
a23fd0e1
VZ
401 {
402 // already processed
403 processed = TRUE;
404 }
2bda0e17
KB
405
406 // If this window is an MDI parent, we must also send an OnActivate message
407 // to the current child.
42e69d6b 408 if ( (m_currentChild != NULL) &&
a23fd0e1 409 ((state == WA_ACTIVE) || (state == WA_CLICKACTIVE)) )
c2dcfdef 410 {
debe6624
JS
411 wxActivateEvent event(wxEVT_ACTIVATE, TRUE, m_currentChild->GetId());
412 event.SetEventObject( m_currentChild );
a23fd0e1
VZ
413 if ( m_currentChild->GetEventHandler()->ProcessEvent(event) )
414 processed = TRUE;
2bda0e17 415 }
a23fd0e1
VZ
416
417 return processed;
2bda0e17
KB
418}
419
42e69d6b 420bool wxMDIParentFrame::HandleCommand(WXWORD id, WXWORD cmd, WXHWND hwnd)
2bda0e17 421{
2bda0e17 422 // In case it's e.g. a toolbar.
42e69d6b 423 if ( hwnd )
e1a6fc11 424 {
42e69d6b
VZ
425 wxWindow *win = wxFindWinFromHandle(hwnd);
426 if ( win )
427 return win->MSWCommand(cmd, id);
e1a6fc11
JS
428 }
429
42e69d6b
VZ
430 // is it one of standard MDI commands?
431 WXWPARAM wParam = 0;
432 int msg;
433 switch ( id )
2bda0e17 434 {
42e69d6b
VZ
435 case IDM_WINDOWCASCADE:
436 msg = WM_MDICASCADE;
437 wParam = MDITILE_SKIPDISABLED;
438 break;
439
440 case IDM_WINDOWTILEHOR:
441 wParam |= MDITILE_HORIZONTAL;
442 // fall through
443
444 case IDM_WINDOWTILEVERT:
445 if ( !wParam )
446 wParam = MDITILE_VERTICAL;
447 msg = WM_MDITILE;
448 wParam |= MDITILE_SKIPDISABLED;
449 break;
450
451 case IDM_WINDOWICONS:
452 msg = WM_MDIICONARRANGE;
453 break;
454
455 case IDM_WINDOWNEXT:
456 msg = WM_MDINEXT;
457 break;
458
459 default:
460 msg = 0;
2bda0e17 461 }
c2dcfdef 462
42e69d6b 463 if ( msg )
2bda0e17 464 {
42e69d6b
VZ
465 ::SendMessage(GetWinHwnd(GetClientWindow()), msg, wParam, 0);
466
467 return TRUE;
2bda0e17 468 }
42e69d6b
VZ
469
470 // FIXME VZ: what does this test do??
471 if (id >= 0xF000)
2bda0e17 472 {
42e69d6b 473 return FALSE; // Get WndProc to call default proc
2bda0e17 474 }
42e69d6b
VZ
475
476 if ( IsMdiCommandId(id) )
2bda0e17 477 {
42e69d6b
VZ
478 wxWindowList::Node* node = GetChildren().GetFirst();
479 while ( node )
2bda0e17 480 {
42e69d6b
VZ
481 wxWindow* child = node->GetData();
482 if ( child->GetHWND() )
2bda0e17 483 {
42e69d6b 484 long childId = wxGetWindowId(child->GetHWND());
48c12cb1 485 if (childId == (long)id)
42e69d6b
VZ
486 {
487 ::SendMessage( GetWinHwnd(GetClientWindow()),
488 WM_MDIACTIVATE,
489 (WPARAM)child->GetHWND(), 0);
490 return TRUE;
491 }
2bda0e17 492 }
42e69d6b 493 node = node->GetNext();
2bda0e17 494 }
2bda0e17 495 }
42e69d6b 496 else if ( m_parentFrameActive )
2bda0e17 497 {
42e69d6b
VZ
498 return ProcessCommand(id);
499 }
500 else if ( m_currentChild )
501 {
502 return m_currentChild->HandleCommand(id, cmd, hwnd);
503 }
504 else
505 {
506 // this shouldn't happen because it means that our messages are being
507 // lost (they're not sent to the parent frame nor to the children)
508 wxFAIL_MSG(_T("MDI parent frame is not active, "
509 "yet there is no active MDI child?"));
2bda0e17 510 }
2bda0e17 511
42e69d6b 512 return FALSE;
2bda0e17
KB
513}
514
42e69d6b
VZ
515long wxMDIParentFrame::MSWDefWindowProc(WXUINT message,
516 WXWPARAM wParam,
517 WXLPARAM lParam)
2bda0e17 518{
c2dcfdef
VZ
519 WXHWND clientWnd;
520 if ( GetClientWindow() )
521 clientWnd = GetClientWindow()->GetHWND();
522 else
523 clientWnd = 0;
2bda0e17 524
a23fd0e1 525 return DefFrameProc(GetHwnd(), (HWND)clientWnd, message, wParam, lParam);
2bda0e17
KB
526}
527
57a7b7c1
JS
528bool wxMDIParentFrame::MSWTranslateMessage(WXMSG* msg)
529{
a23fd0e1 530 MSG *pMsg = (MSG *)msg;
2bda0e17 531
a23fd0e1
VZ
532 if ( m_currentChild && m_currentChild->GetHWND() &&
533 m_currentChild->MSWTranslateMessage(msg) )
534 {
535 return TRUE;
536 }
2bda0e17 537
c50f1fb9 538 if ( m_acceleratorTable.Translate(this, msg) )
a23fd0e1
VZ
539 {
540 return TRUE;
541 }
2bda0e17 542
a23fd0e1
VZ
543 if ( pMsg->message == WM_KEYDOWN || pMsg->message == WM_SYSKEYDOWN )
544 {
545 if ( ::TranslateMDISysAccel(GetWinHwnd(GetClientWindow()), pMsg))
546 return TRUE;
547 }
57a7b7c1 548
a23fd0e1 549 return FALSE;
2bda0e17
KB
550}
551
42e69d6b 552// ===========================================================================
a23fd0e1 553// wxMDIChildFrame
42e69d6b 554// ===========================================================================
2bda0e17 555
c2dcfdef 556wxMDIChildFrame::wxMDIChildFrame()
2bda0e17 557{
2bda0e17
KB
558}
559
560bool wxMDIChildFrame::Create(wxMDIParentFrame *parent,
a23fd0e1
VZ
561 wxWindowID id,
562 const wxString& title,
563 const wxPoint& pos,
564 const wxSize& size,
565 long style,
566 const wxString& name)
2bda0e17 567{
42e69d6b
VZ
568 m_defaultIcon = (WXHICON)(wxSTD_MDICHILDFRAME_ICON ? wxSTD_MDICHILDFRAME_ICON
569 : wxDEFAULT_MDICHILDFRAME_ICON);
2bda0e17
KB
570
571 SetName(name);
572
573 if ( id > -1 )
574 m_windowId = id;
575 else
576 m_windowId = (int)NewControlId();
577
42e69d6b
VZ
578 if ( parent )
579 {
580 parent->AddChild(this);
581 }
2bda0e17
KB
582
583 wxWndHook = this;
584
585 int x = pos.x;
586 int y = pos.y;
587 int width = size.x;
588 int height = size.y;
589
590 MDICREATESTRUCT mcs;
c2dcfdef 591
2bda0e17
KB
592 mcs.szClass = wxMDIChildFrameClassName;
593 mcs.szTitle = title;
594 mcs.hOwner = wxGetInstance();
42e69d6b
VZ
595 if (x > -1)
596 mcs.x = x;
597 else
598 mcs.x = CW_USEDEFAULT;
2bda0e17 599
42e69d6b
VZ
600 if (y > -1)
601 mcs.y = y;
602 else
603 mcs.y = CW_USEDEFAULT;
2bda0e17 604
42e69d6b
VZ
605 if (width > -1)
606 mcs.cx = width;
607 else
608 mcs.cx = CW_USEDEFAULT;
2bda0e17 609
42e69d6b
VZ
610 if (height > -1)
611 mcs.cy = height;
612 else
613 mcs.cy = CW_USEDEFAULT;
2bda0e17 614
42e69d6b 615 DWORD msflags = WS_OVERLAPPED | WS_CLIPCHILDREN;
2bda0e17
KB
616 if (style & wxMINIMIZE_BOX)
617 msflags |= WS_MINIMIZEBOX;
618 if (style & wxMAXIMIZE_BOX)
619 msflags |= WS_MAXIMIZEBOX;
620 if (style & wxTHICK_FRAME)
621 msflags |= WS_THICKFRAME;
622 if (style & wxSYSTEM_MENU)
623 msflags |= WS_SYSMENU;
624 if ((style & wxMINIMIZE) || (style & wxICONIZE))
625 msflags |= WS_MINIMIZE;
626 if (style & wxMAXIMIZE)
627 msflags |= WS_MAXIMIZE;
628 if (style & wxCAPTION)
629 msflags |= WS_CAPTION;
630
631 mcs.style = msflags;
632
633 mcs.lParam = 0;
634
b3818fbe
VZ
635 DWORD Return = SendMessage(GetWinHwnd(parent->GetClientWindow()),
636 WM_MDICREATE, 0, (LONG)(LPSTR)&mcs);
2bda0e17
KB
637
638 //handle = (HWND)LOWORD(Return);
639 // Must be the DWORRD for WIN32. And in 16 bits, HIWORD=0 (says Microsoft)
640 m_hWnd = (WXHWND)Return;
641
2bda0e17 642 wxWndHook = NULL;
c7527e3f 643 wxAssociateWinWithHandle((HWND) GetHWND(), this);
2bda0e17 644
b3818fbe
VZ
645 // VZ: what's this? an act of piracy?
646 //SetWindowLong(GetHwnd(), 0, (long)this);
2bda0e17
KB
647
648 wxModelessWindows.Append(this);
649 return TRUE;
650}
651
c2dcfdef 652wxMDIChildFrame::~wxMDIChildFrame()
2bda0e17 653{
c2dcfdef 654 MSWDestroyWindow();
2bda0e17
KB
655}
656
657// Set the client size (i.e. leave the calculation of borders etc.
658// to wxWindows)
cc2b7472 659void wxMDIChildFrame::DoSetClientSize(int width, int height)
2bda0e17 660{
b3818fbe 661 HWND hWnd = GetHwnd();
2bda0e17
KB
662
663 RECT rect;
2de8030d 664 ::GetClientRect(hWnd, &rect);
2bda0e17
KB
665
666 RECT rect2;
667 GetWindowRect(hWnd, &rect2);
668
669 // Find the difference between the entire window (title bar and all)
670 // and the client area; add this to the new client size to move the
671 // window
672 int actual_width = rect2.right - rect2.left - rect.right + width;
673 int actual_height = rect2.bottom - rect2.top - rect.bottom + height;
674
675 if (GetStatusBar())
676 {
c2dcfdef
VZ
677 int sx, sy;
678 GetStatusBar()->GetSize(&sx, &sy);
2bda0e17
KB
679 actual_height += sy;
680 }
681
682 POINT point;
683 point.x = rect2.left;
684 point.y = rect2.top;
685
686 // If there's an MDI parent, must subtract the parent's top left corner
687 // since MoveWindow moves relative to the parent
688 wxMDIParentFrame *mdiParent = (wxMDIParentFrame *)GetParent();
689 ::ScreenToClient((HWND) mdiParent->GetClientWindow()->GetHWND(), &point);
690
691 MoveWindow(hWnd, point.x, point.y, actual_width, actual_height, (BOOL)TRUE);
debe6624 692
2bda0e17 693 wxSizeEvent event(wxSize(width, height), m_windowId);
debe6624 694 event.SetEventObject( this );
2bda0e17 695 GetEventHandler()->ProcessEvent(event);
2bda0e17
KB
696}
697
cc2b7472 698void wxMDIChildFrame::DoGetPosition(int *x, int *y) const
2bda0e17
KB
699{
700 RECT rect;
b3818fbe 701 GetWindowRect(GetHwnd(), &rect);
2bda0e17
KB
702 POINT point;
703 point.x = rect.left;
704 point.y = rect.top;
705
706 // Since we now have the absolute screen coords,
707 // if there's a parent we must subtract its top left corner
708 wxMDIParentFrame *mdiParent = (wxMDIParentFrame *)GetParent();
709 ::ScreenToClient((HWND) mdiParent->GetClientWindow()->GetHWND(), &point);
710
711 *x = point.x;
712 *y = point.y;
713}
714
42e69d6b 715void wxMDIChildFrame::InternalSetMenuBar()
2bda0e17 716{
42e69d6b 717 wxMDIParentFrame *parent = (wxMDIParentFrame *)GetParent();
2bda0e17 718
42e69d6b 719 HMENU subMenu = GetSubMenu((HMENU)parent->GetWindowMenu(), 0);
2bda0e17 720
42e69d6b 721 InsertWindowMenu(parent->GetClientWindow(), m_hMenu, subMenu);
2bda0e17 722
42e69d6b 723 parent->m_parentFrameActive = FALSE;
2bda0e17
KB
724}
725
42e69d6b 726// ---------------------------------------------------------------------------
2bda0e17 727// MDI operations
42e69d6b
VZ
728// ---------------------------------------------------------------------------
729
9b73db3c 730void wxMDIChildFrame::Maximize(bool maximize)
2bda0e17
KB
731{
732 wxMDIParentFrame *parent = (wxMDIParentFrame *)GetParent();
733 if ( parent && parent->GetClientWindow() )
9b73db3c
VZ
734 {
735 ::SendMessage(GetWinHwnd(parent->GetClientWindow()),
736 maximize ? WM_MDIMAXIMIZE : WM_MDIRESTORE,
737 (WPARAM)GetHwnd(), 0);
738 }
2bda0e17
KB
739}
740
c2dcfdef 741void wxMDIChildFrame::Restore()
2bda0e17
KB
742{
743 wxMDIParentFrame *parent = (wxMDIParentFrame *)GetParent();
744 if ( parent && parent->GetClientWindow() )
9b73db3c
VZ
745 {
746 ::SendMessage(GetWinHwnd(parent->GetClientWindow()), WM_MDIRESTORE,
747 (WPARAM) GetHwnd(), 0);
748 }
2bda0e17
KB
749}
750
c2dcfdef 751void wxMDIChildFrame::Activate()
2bda0e17
KB
752{
753 wxMDIParentFrame *parent = (wxMDIParentFrame *)GetParent();
754 if ( parent && parent->GetClientWindow() )
9b73db3c
VZ
755 {
756 ::SendMessage(GetWinHwnd(parent->GetClientWindow()), WM_MDIACTIVATE,
757 (WPARAM) GetHwnd(), 0);
758 }
2bda0e17
KB
759}
760
42e69d6b
VZ
761// ---------------------------------------------------------------------------
762// MDI window proc and message handlers
763// ---------------------------------------------------------------------------
764
765long wxMDIChildFrame::MSWWindowProc(WXUINT message,
766 WXWPARAM wParam,
767 WXLPARAM lParam)
768{
769 long rc = 0;
770 bool processed = FALSE;
771
772 switch ( message )
773 {
774 case WM_COMMAND:
775 {
776 WORD id, cmd;
777 WXHWND hwnd;
778 UnpackCommand((WXWPARAM)wParam, (WXLPARAM)lParam,
779 &id, &hwnd, &cmd);
780
781 processed = HandleCommand(id, cmd, (WXHWND)hwnd);
782 }
783 break;
784
42e69d6b
VZ
785 case WM_GETMINMAXINFO:
786 // let the default window proc calculate the size of MDI children
787 // frames because it is based on the size of the MDI client window,
788 // not on the values specified in wxWindow m_min/max variables
789 return MSWDefWindowProc(message, wParam, lParam);
790
791 case WM_MDIACTIVATE:
792 {
793 WXWORD act;
794 WXHWND hwndAct, hwndDeact;
795 UnpackMDIActivate(wParam, lParam, &act, &hwndAct, &hwndDeact);
796
797 processed = HandleMDIActivate(act, hwndAct, hwndDeact);
798 }
b3818fbe
VZ
799 // fall through
800
801 case WM_MOVE:
802 // must pass WM_MOVE to DefMDIChildProc() to recalculate MDI client
803 // scrollbars if necessary
804
805 // fall through
806
807 case WM_SIZE:
808 // must pass WM_SIZE to DefMDIChildProc(), otherwise many weird
809 // things happen
810 MSWDefWindowProc(message, wParam, lParam);
42e69d6b
VZ
811 break;
812
b3818fbe
VZ
813 case WM_SYSCOMMAND:
814 // DefMDIChildProc handles SC_{NEXT/PREV}WINDOW here, so pass it
815 // the message (the base class version does not)
816 return MSWDefWindowProc(message, wParam, lParam);
817
42e69d6b
VZ
818 case WM_WINDOWPOSCHANGING:
819 processed = HandleWindowPosChanging((LPWINDOWPOS)lParam);
820 break;
821 }
822
823 if ( !processed )
824 rc = wxFrame::MSWWindowProc(message, wParam, lParam);
825
826 return rc;
827}
828
829bool wxMDIChildFrame::HandleSize(int x, int y, WXUINT id)
2bda0e17 830{
a23fd0e1 831 HWND hwnd = GetHwnd();
42e69d6b 832
a23fd0e1 833 if ( !hwnd || hwnd == invalidHandle )
2bda0e17 834 {
a23fd0e1
VZ
835 return FALSE;
836 }
42e69d6b 837
a23fd0e1
VZ
838 switch (id)
839 {
840 case SIZEFULLSCREEN:
841 case SIZENORMAL:
842 m_iconized = FALSE;
843 break;
844
845 case SIZEICONIC:
846 m_iconized = TRUE;
847 break;
2bda0e17 848 }
42e69d6b
VZ
849
850 if ( !m_iconized )
a23fd0e1
VZ
851 {
852 // forward WM_SIZE to status bar control
853#if wxUSE_NATIVE_STATUSBAR
854 if (m_frameStatusBar && m_frameStatusBar->IsKindOf(CLASSINFO(wxStatusBar95)))
855 {
856 wxSizeEvent event(wxSize(x, y), m_frameStatusBar->GetId());
857 event.SetEventObject( m_frameStatusBar );
42e69d6b 858
a23fd0e1
VZ
859 ((wxStatusBar95 *)m_frameStatusBar)->OnSize(event);
860 }
42e69d6b
VZ
861#endif // wxUSE_NATIVE_STATUSBAR
862
a23fd0e1
VZ
863 PositionStatusBar();
864 PositionToolBar();
42e69d6b
VZ
865
866 return wxWindow::HandleSize(x, y, id);
a23fd0e1
VZ
867 }
868 else
869 {
870 return FALSE;
871 }
2bda0e17
KB
872}
873
42e69d6b 874bool wxMDIChildFrame::HandleCommand(WXWORD id, WXWORD cmd, WXHWND hwnd)
2bda0e17 875{
2bda0e17 876 // In case it's e.g. a toolbar.
42e69d6b
VZ
877 if ( hwnd )
878 {
879 wxWindow *win = wxFindWinFromHandle(hwnd);
880 if (win)
881 return win->MSWCommand(cmd, id);
882 }
2bda0e17 883
e1a6fc11
JS
884 if (wxCurrentPopupMenu)
885 {
886 wxMenu *popupMenu = wxCurrentPopupMenu;
887 wxCurrentPopupMenu = NULL;
888 if (popupMenu->MSWCommand(cmd, id))
889 return TRUE;
890 }
891
2bda0e17
KB
892 if (GetMenuBar() && GetMenuBar()->FindItemForId(id))
893 {
42e69d6b
VZ
894 ProcessCommand(id);
895 return TRUE;
2bda0e17
KB
896 }
897 else
42e69d6b
VZ
898 return FALSE;
899
2bda0e17 900 return TRUE;
2bda0e17
KB
901}
902
42e69d6b
VZ
903bool wxMDIChildFrame::HandleMDIActivate(long WXUNUSED(activate),
904 WXHWND hwndAct,
905 WXHWND hwndDeact)
2bda0e17 906{
42e69d6b 907 wxMDIParentFrame *parent = (wxMDIParentFrame *)GetParent();
2bda0e17 908
42e69d6b 909 HMENU menuToSet = 0;
57a7b7c1 910
42e69d6b 911 bool activated;
57a7b7c1 912
42e69d6b
VZ
913 if ( m_hWnd == hwndAct )
914 {
915 activated = TRUE;
916 parent->m_currentChild = this;
2bda0e17 917
42e69d6b
VZ
918 HMENU child_menu = (HMENU)GetWinMenu();
919 if ( child_menu )
920 {
921 parent->m_parentFrameActive = FALSE;
2bda0e17 922
42e69d6b
VZ
923 menuToSet = child_menu;
924 }
925 }
926 else if ( m_hWnd == hwndDeact )
2bda0e17 927 {
42e69d6b
VZ
928 wxASSERT_MSG( parent->m_currentChild == this,
929 _T("can't deactivate MDI child which wasn't active!") );
930
931 activated = FALSE;
932 parent->m_currentChild = NULL;
2bda0e17 933
42e69d6b
VZ
934 HMENU parent_menu = (HMENU)parent->GetWinMenu();
935 if ( parent_menu )
936 {
937 parent->m_parentFrameActive = TRUE;
938
939 menuToSet = parent_menu;
940 }
941 }
942 else
943 {
944 // we have nothing to with it
945 return FALSE;
2bda0e17 946 }
debe6624 947
42e69d6b
VZ
948 if ( menuToSet )
949 {
950 HMENU subMenu = GetSubMenu((HMENU) parent->GetWindowMenu(), 0);
951
952 MDISetMenu(parent->GetClientWindow(), menuToSet, subMenu);
953 }
954
955 wxActivateEvent event(wxEVT_ACTIVATE, activated, m_windowId);
debe6624 956 event.SetEventObject( this );
2bda0e17 957
42e69d6b
VZ
958 return GetEventHandler()->ProcessEvent(event);
959}
960
961bool wxMDIChildFrame::HandleWindowPosChanging(void *pos)
962{
963 WINDOWPOS *lpPos = (WINDOWPOS *)pos;
964#if defined(__WIN95__)
965 if (!(lpPos->flags & SWP_NOSIZE))
2bda0e17 966 {
42e69d6b 967 RECT rectClient;
b3818fbe
VZ
968 DWORD dwExStyle = ::GetWindowLong(GetHwnd(), GWL_EXSTYLE);
969 DWORD dwStyle = ::GetWindowLong(GetHwnd(), GWL_STYLE);
42e69d6b
VZ
970 if (ResetWindowStyle((void *) & rectClient) && (dwStyle & WS_MAXIMIZE))
971 {
972 ::AdjustWindowRectEx(&rectClient, dwStyle, FALSE, dwExStyle);
973 lpPos->x = rectClient.left;
974 lpPos->y = rectClient.top;
975 lpPos->cx = rectClient.right - rectClient.left;
976 lpPos->cy = rectClient.bottom - rectClient.top;
977 }
978 wxMDIParentFrame* pFrameWnd = (wxMDIParentFrame *)GetParent();
979 if (pFrameWnd && pFrameWnd->GetToolBar())
980 {
981 pFrameWnd->GetToolBar()->Refresh();
982 }
983 }
984#endif // Win95
985
986 return FALSE;
987}
988
989// ---------------------------------------------------------------------------
990// MDI specific message translation/preprocessing
991// ---------------------------------------------------------------------------
2bda0e17 992
42e69d6b
VZ
993long wxMDIChildFrame::MSWDefWindowProc(WXUINT message, WXUINT wParam, WXLPARAM lParam)
994{
995 return DefMDIChildProc(GetHwnd(),
996 (UINT)message, (WPARAM)wParam, (LPARAM)lParam);
997}
998
999bool wxMDIChildFrame::MSWTranslateMessage(WXMSG* msg)
1000{
c50f1fb9 1001 return m_acceleratorTable.Translate(GetParent(), msg);
2bda0e17
KB
1002}
1003
42e69d6b
VZ
1004// ---------------------------------------------------------------------------
1005// misc
1006// ---------------------------------------------------------------------------
1007
c2dcfdef 1008void wxMDIChildFrame::MSWDestroyWindow()
2bda0e17 1009{
42e69d6b 1010 MSWDetachWindowMenu();
b3818fbe 1011 invalidHandle = GetHwnd();
2bda0e17 1012
42e69d6b 1013 wxMDIParentFrame *parent = (wxMDIParentFrame *)GetParent();
2bda0e17 1014
42e69d6b
VZ
1015 // Must make sure this handle is invalidated (set to NULL) since all sorts
1016 // of things could happen after the child client is destroyed, but before
1017 // the wxFrame is destroyed.
2bda0e17 1018
42e69d6b 1019 HWND oldHandle = (HWND)GetHWND();
b3818fbe
VZ
1020 SendMessage(GetWinHwnd(parent->GetClientWindow()), WM_MDIDESTROY,
1021 (WPARAM)oldHandle, 0);
42e69d6b 1022 invalidHandle = 0;
2bda0e17 1023
42e69d6b
VZ
1024 if (m_hMenu)
1025 {
1026 ::DestroyMenu((HMENU) m_hMenu);
1027 m_hMenu = 0;
1028 }
1029 m_hWnd = 0;
2bda0e17
KB
1030}
1031
42e69d6b
VZ
1032// Change the client window's extended style so we don't get a client edge
1033// style when a child is maximised (a double border looks silly.)
2bda0e17
KB
1034bool wxMDIChildFrame::ResetWindowStyle(void *vrect)
1035{
1036#if defined(__WIN95__)
1037 RECT *rect = (RECT *)vrect;
c2dcfdef
VZ
1038 wxMDIParentFrame* pFrameWnd = (wxMDIParentFrame *)GetParent();
1039 wxMDIChildFrame* pChild = pFrameWnd->GetActiveChild();
1040 if (!pChild || (pChild == this))
1041 {
b3818fbe
VZ
1042 DWORD dwStyle = ::GetWindowLong(GetWinHwnd(pFrameWnd->GetClientWindow()), GWL_EXSTYLE);
1043 DWORD dwThisStyle = ::GetWindowLong(GetHwnd(), GWL_STYLE);
c2dcfdef
VZ
1044 DWORD dwNewStyle = dwStyle;
1045 if (pChild != NULL && (dwThisStyle & WS_MAXIMIZE))
1046 dwNewStyle &= ~(WS_EX_CLIENTEDGE);
1047 else
1048 dwNewStyle |= WS_EX_CLIENTEDGE;
1049
1050 if (dwStyle != dwNewStyle)
1051 {
42e69d6b
VZ
1052 HWND hwnd = GetWinHwnd(pFrameWnd->GetClientWindow());
1053 ::RedrawWindow(hwnd, NULL, NULL, RDW_INVALIDATE | RDW_ALLCHILDREN);
1054 ::SetWindowLong(hwnd, GWL_EXSTYLE, dwNewStyle);
1055 ::SetWindowPos(hwnd, NULL, 0, 0, 0, 0,
1056 SWP_FRAMECHANGED | SWP_NOACTIVATE |
1057 SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER |
1058 SWP_NOCOPYBITS);
c2dcfdef 1059 if (rect)
42e69d6b 1060 ::GetClientRect(hwnd, rect);
2bda0e17 1061
42e69d6b 1062 return TRUE;
2bda0e17 1063 }
c2dcfdef 1064 }
42e69d6b 1065#endif // Win95
a23fd0e1
VZ
1066
1067 return FALSE;
2bda0e17
KB
1068}
1069
42e69d6b
VZ
1070// ===========================================================================
1071// wxMDIClientWindow: the window of predefined (by Windows) class which
1072// contains the child frames
1073// ===========================================================================
2bda0e17 1074
debe6624 1075bool wxMDIClientWindow::CreateClient(wxMDIParentFrame *parent, long style)
2bda0e17 1076{
42e69d6b 1077 m_backgroundColour = wxSystemSettings::GetSystemColour(wxSYS_COLOUR_APPWORKSPACE);
2bda0e17 1078
42e69d6b
VZ
1079 CLIENTCREATESTRUCT ccs;
1080 m_windowStyle = style;
1081 m_parent = parent;
c2dcfdef 1082
42e69d6b
VZ
1083 ccs.hWindowMenu = (HMENU)parent->GetWindowMenu();
1084 ccs.idFirstChild = wxFIRST_MDI_CHILD;
2bda0e17 1085
42e69d6b
VZ
1086 DWORD msStyle = WS_VISIBLE | WS_CHILD | WS_CLIPCHILDREN;
1087 if ( style & wxHSCROLL )
1088 msStyle |= WS_HSCROLL;
1089 if ( style & wxVSCROLL )
1090 msStyle |= WS_VSCROLL;
2bda0e17
KB
1091
1092#if defined(__WIN95__)
42e69d6b 1093 DWORD exStyle = WS_EX_CLIENTEDGE;
2bda0e17 1094#else
42e69d6b 1095 DWORD exStyle = 0;
2bda0e17
KB
1096#endif
1097
42e69d6b
VZ
1098 wxWndHook = this;
1099 m_hWnd = (WXHWND)::CreateWindowEx
1100 (
1101 exStyle,
837e5743 1102 _T("MDICLIENT"),
42e69d6b
VZ
1103 NULL,
1104 msStyle,
1105 0, 0, 0, 0,
1106 GetWinHwnd(parent),
1107 NULL,
1108 wxGetInstance(),
1109 (LPSTR)(LPCLIENTCREATESTRUCT)&ccs);
1110 if ( !m_hWnd )
1111 {
1112 wxLogLastError("CreateWindowEx(MDI client)");
2bda0e17 1113
42e69d6b
VZ
1114 return FALSE;
1115 }
2bda0e17 1116
42e69d6b
VZ
1117 SubclassWin(m_hWnd);
1118 wxWndHook = NULL;
2bda0e17 1119
42e69d6b 1120 return TRUE;
2bda0e17
KB
1121}
1122
1123// Explicitly call default scroll behaviour
1124void wxMDIClientWindow::OnScroll(wxScrollEvent& event)
1125{
1126 // Note: for client windows, the scroll position is not set in
1127 // WM_HSCROLL, WM_VSCROLL, so we can't easily determine what
1128 // scroll position we're at.
1129 // This makes it hard to paint patterns or bitmaps in the background,
1130 // and have the client area scrollable as well.
1131
1132 if ( event.GetOrientation() == wxHORIZONTAL )
1133 m_scrollX = event.GetPosition(); // Always returns zero!
1134 else
1135 m_scrollY = event.GetPosition(); // Always returns zero!
1136
42e69d6b
VZ
1137 event.Skip();
1138}
1139
1140// ---------------------------------------------------------------------------
1141// non member functions
1142// ---------------------------------------------------------------------------
1143
1144static void MDISetMenu(wxWindow *win, HMENU hmenuFrame, HMENU hmenuWindow)
1145{
1146 ::SendMessage(GetWinHwnd(win), WM_MDISETMENU,
1147#ifdef __WIN32__
1148 (WPARAM)hmenuFrame, (LPARAM)hmenuWindow);
1149#else
1150 0, MAKELPARAM(hmenuFrame, hmenuWindow));
1151#endif
1152
1153 // update menu bar of the parent window
1154 wxWindow *parent = win->GetParent();
837e5743 1155 wxCHECK_RET( parent, _T("MDI client without parent frame? weird...") );
42e69d6b
VZ
1156
1157 ::DrawMenuBar(GetWinHwnd(parent));
1158}
1159
1160static void InsertWindowMenu(wxWindow *win, WXHMENU menu, HMENU subMenu)
1161{
1162 // Try to insert Window menu in front of Help, otherwise append it.
1163 HMENU hmenu = (HMENU)menu;
1164 int N = GetMenuItemCount(hmenu);
1165 bool success = FALSE;
1166 for ( int i = 0; i < N; i++ )
1167 {
837e5743 1168 wxChar buf[256];
42e69d6b
VZ
1169 int chars = GetMenuString(hmenu, i, buf, WXSIZEOF(buf), MF_BYPOSITION);
1170 if ( chars == 0 )
1171 {
837e5743 1172 wxLogLastError(_T("GetMenuString"));
42e69d6b
VZ
1173
1174 continue;
1175 }
1176
b3818fbe 1177 if ( wxStripMenuCodes(wxString(buf)).IsSameAs(_T("Help")) )
42e69d6b
VZ
1178 {
1179 success = TRUE;
1180 ::InsertMenu(hmenu, i, MF_BYPOSITION | MF_POPUP | MF_STRING,
837e5743 1181 (UINT)subMenu, _T("&Window"));
42e69d6b
VZ
1182 break;
1183 }
1184 }
1185
1186 if ( !success )
1187 {
b3818fbe 1188 ::AppendMenu(hmenu, MF_POPUP, (UINT)subMenu, _T("&Window"));
42e69d6b
VZ
1189 }
1190
1191 MDISetMenu(win, hmenu, subMenu);
1192}
1193
2917e920
BM
1194static void UnpackMDIActivate(WXWPARAM wParam, WXLPARAM lParam,
1195 WXWORD *activate, WXHWND *hwndAct, WXHWND *hwndDeact)
42e69d6b
VZ
1196{
1197#ifdef __WIN32__
1198 *activate = TRUE;
1199 *hwndAct = (WXHWND)lParam;
1200 *hwndDeact = (WXHWND)wParam;
1201#else // Win16
1202 *activate = (WXWORD)wParam;
1203 *hwndAct = (WXHWND)LOWORD(lParam);
1204 *hwndDeact = (WXHWND)HIWORD(lParam);
1205#endif // Win32/Win16
2bda0e17 1206}