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