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