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