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