]> git.saurik.com Git - wxWidgets.git/blob - src/msw/frame.cpp
89e9716b0b692443529b4428e94b4ab0124986ed
[wxWidgets.git] / src / msw / frame.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: msw/frame.cpp
3 // Purpose: wxFrame
4 // Author: Julian Smart
5 // Modified by:
6 // Created: 01/02/97
7 // RCS-ID: $Id$
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 // ============================================================================
13 // declarations
14 // ============================================================================
15
16 // ----------------------------------------------------------------------------
17 // headers
18 // ----------------------------------------------------------------------------
19
20 #ifdef __GNUG__
21 #pragma implementation "frame.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/frame.h"
33 #include "wx/app.h"
34 #include "wx/menu.h"
35 #include "wx/utils.h"
36 #include "wx/dialog.h"
37 #include "wx/settings.h"
38 #include "wx/dcclient.h"
39 #include "wx/mdi.h"
40 #include "wx/panel.h"
41 #endif // WX_PRECOMP
42
43 #include "wx/msw/private.h"
44
45 #ifdef __WXWINCE__
46 #include <commctrl.h>
47 #endif
48
49 #if wxUSE_STATUSBAR
50 #include "wx/statusbr.h"
51 #include "wx/generic/statusbr.h"
52 #endif // wxUSE_STATUSBAR
53
54 #if wxUSE_TOOLBAR
55 #include "wx/toolbar.h"
56 #endif // wxUSE_TOOLBAR
57
58 #include "wx/menuitem.h"
59 #include "wx/log.h"
60
61 #ifdef __WXUNIVERSAL__
62 #include "wx/univ/theme.h"
63 #include "wx/univ/colschem.h"
64 #endif // __WXUNIVERSAL__
65
66 // ----------------------------------------------------------------------------
67 // globals
68 // ----------------------------------------------------------------------------
69
70 #if wxUSE_MENUS_NATIVE
71 extern wxMenu *wxCurrentPopupMenu;
72 #endif // wxUSE_MENUS_NATIVE
73
74 // ----------------------------------------------------------------------------
75 // event tables
76 // ----------------------------------------------------------------------------
77
78 BEGIN_EVENT_TABLE(wxFrame, wxFrameBase)
79 EVT_SYS_COLOUR_CHANGED(wxFrame::OnSysColourChanged)
80 END_EVENT_TABLE()
81
82 IMPLEMENT_DYNAMIC_CLASS(wxFrame, wxTopLevelWindow)
83
84 // ============================================================================
85 // implementation
86 // ============================================================================
87
88 // ----------------------------------------------------------------------------
89 // static class members
90 // ----------------------------------------------------------------------------
91
92 #if wxUSE_STATUSBAR
93 #if wxUSE_NATIVE_STATUSBAR
94 bool wxFrame::m_useNativeStatusBar = TRUE;
95 #else
96 bool wxFrame::m_useNativeStatusBar = FALSE;
97 #endif
98 #endif // wxUSE_NATIVE_STATUSBAR
99
100 // ----------------------------------------------------------------------------
101 // creation/destruction
102 // ----------------------------------------------------------------------------
103
104 void wxFrame::Init()
105 {
106 #if wxUSE_TOOLTIPS
107 m_hwndToolTip = 0;
108 #endif
109 #ifdef __WXWINCE__
110 m_commandBar = 0;
111 #endif
112
113 // Data to save/restore when calling ShowFullScreen
114 m_fsStatusBarFields = 0;
115 m_fsStatusBarHeight = 0;
116 m_fsToolBarHeight = 0;
117
118 m_wasMinimized = FALSE;
119 }
120
121 bool wxFrame::Create(wxWindow *parent,
122 wxWindowID id,
123 const wxString& title,
124 const wxPoint& pos,
125 const wxSize& size,
126 long style,
127 const wxString& name)
128 {
129 if ( !wxTopLevelWindow::Create(parent, id, title, pos, size, style, name) )
130 return FALSE;
131
132 SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_APPWORKSPACE));
133
134 wxModelessWindows.Append(this);
135
136 return TRUE;
137 }
138
139 wxFrame::~wxFrame()
140 {
141 m_isBeingDeleted = TRUE;
142 DeleteAllBars();
143 #ifdef __WXWINCE__
144 if (m_commandBar)
145 {
146 ::DestroyWindow((HWND) m_commandBar);
147 m_commandBar = NULL;
148 }
149 #endif
150
151 }
152
153 // ----------------------------------------------------------------------------
154 // wxFrame client size calculations
155 // ----------------------------------------------------------------------------
156
157 void wxFrame::DoSetClientSize(int width, int height)
158 {
159 // leave enough space for the status bar if we have (and show) it
160 #if wxUSE_STATUSBAR
161 wxStatusBar *statbar = GetStatusBar();
162 if ( statbar && statbar->IsShown() )
163 {
164 height += statbar->GetSize().y;
165 }
166 #endif // wxUSE_STATUSBAR
167
168 // call GetClientAreaOrigin() to take the toolbar into account
169 wxPoint pt = GetClientAreaOrigin();
170 width += pt.x;
171 height += pt.y;
172
173 wxTopLevelWindow::DoSetClientSize(width, height);
174 }
175
176 // Get size *available for subwindows* i.e. excluding menu bar, toolbar etc.
177 void wxFrame::DoGetClientSize(int *x, int *y) const
178 {
179 wxTopLevelWindow::DoGetClientSize(x, y);
180
181 // account for the possible toolbar
182 wxPoint pt = GetClientAreaOrigin();
183 if ( x )
184 *x -= pt.x;
185
186 if ( y )
187 *y -= pt.y;
188
189 #if wxUSE_STATUSBAR
190 // adjust client area height to take the status bar into account
191 if ( y )
192 {
193 wxStatusBar *statbar = GetStatusBar();
194 if ( statbar && statbar->IsShown() )
195 {
196 *y -= statbar->GetClientSize().y;
197 }
198 }
199 #endif // wxUSE_STATUSBAR
200 }
201
202 // ----------------------------------------------------------------------------
203 // wxFrame: various geometry-related functions
204 // ----------------------------------------------------------------------------
205
206 void wxFrame::Raise()
207 {
208 ::SetForegroundWindow(GetHwnd());
209 }
210
211 // generate an artificial resize event
212 void wxFrame::SendSizeEvent()
213 {
214 if ( !m_iconized )
215 {
216 RECT r = wxGetWindowRect(GetHwnd());
217
218 (void)::PostMessage(GetHwnd(), WM_SIZE,
219 IsMaximized() ? SIZE_MAXIMIZED : SIZE_RESTORED,
220 MAKELPARAM(r.right - r.left, r.bottom - r.top));
221 }
222 }
223
224 #if wxUSE_STATUSBAR
225 wxStatusBar *wxFrame::OnCreateStatusBar(int number,
226 long style,
227 wxWindowID id,
228 const wxString& name)
229 {
230 wxStatusBar *statusBar = NULL;
231
232 #if wxUSE_NATIVE_STATUSBAR
233 if ( !UsesNativeStatusBar() )
234 {
235 statusBar = (wxStatusBar *)new wxStatusBarGeneric(this, id, style);
236 }
237 else
238 #endif
239 {
240 statusBar = new wxStatusBar(this, id, style, name);
241 }
242
243 statusBar->SetFieldsCount(number);
244
245 return statusBar;
246 }
247
248 void wxFrame::PositionStatusBar()
249 {
250 if ( !m_frameStatusBar || !m_frameStatusBar->IsShown() )
251 return;
252
253 int w, h;
254 GetClientSize(&w, &h);
255 int sw, sh;
256 m_frameStatusBar->GetSize(&sw, &sh);
257
258 // Since we wish the status bar to be directly under the client area,
259 // we use the adjusted sizes without using wxSIZE_NO_ADJUSTMENTS.
260 m_frameStatusBar->SetSize(0, h, w, sh);
261 }
262 #endif // wxUSE_STATUSBAR
263
264 #if wxUSE_MENUS_NATIVE
265
266 void wxFrame::AttachMenuBar(wxMenuBar *menubar)
267 {
268 wxFrameBase::AttachMenuBar(menubar);
269
270 if ( !menubar )
271 {
272 // actually remove the menu from the frame
273 m_hMenu = (WXHMENU)0;
274 InternalSetMenuBar();
275 }
276 else // set new non NULL menu bar
277 {
278 // Can set a menubar several times.
279 if ( menubar->GetHMenu() )
280 {
281 m_hMenu = menubar->GetHMenu();
282 }
283 else // no HMENU yet
284 {
285 m_hMenu = menubar->Create();
286
287 if ( !m_hMenu )
288 {
289 wxFAIL_MSG( _T("failed to create menu bar") );
290 return;
291 }
292 }
293
294 InternalSetMenuBar();
295 }
296 }
297
298 void wxFrame::InternalSetMenuBar()
299 {
300 #ifdef __WXMICROWIN__
301 // Nothing
302 #elif defined(__WXWINCE__)
303 if (!m_commandBar)
304 {
305 // TODO: eventually have a wxCommandBar class
306 m_commandBar = (WXHWND) CommandBar_Create(wxGetInstance(), GetHwnd(), NewControlId());
307 if (!m_commandBar)
308 {
309 wxFAIL_MSG( _T("failed to create commandbar") );
310 return;
311 }
312 }
313 if (m_commandBar)
314 {
315 if (!CommandBar_InsertMenubarEx((HWND) m_commandBar, NULL,
316 (LPTSTR) (HMENU) m_hMenu, 0))
317 {
318 wxFAIL_MSG( _T("failed to set menubar") );
319 return;
320 }
321 CommandBar_DrawMenuBar((HWND) m_commandBar, 0);
322 }
323 #else
324 if ( !::SetMenu(GetHwnd(), (HMENU)m_hMenu) )
325 {
326 wxLogLastError(wxT("SetMenu"));
327 }
328 #endif
329 }
330
331 #endif // wxUSE_MENUS_NATIVE
332
333 // Responds to colour changes, and passes event on to children.
334 void wxFrame::OnSysColourChanged(wxSysColourChangedEvent& event)
335 {
336 SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_APPWORKSPACE));
337 Refresh();
338
339 #if wxUSE_STATUSBAR
340 if ( m_frameStatusBar )
341 {
342 wxSysColourChangedEvent event2;
343 event2.SetEventObject( m_frameStatusBar );
344 m_frameStatusBar->GetEventHandler()->ProcessEvent(event2);
345 }
346 #endif // wxUSE_STATUSBAR
347
348 // Propagate the event to the non-top-level children
349 wxWindow::OnSysColourChanged(event);
350 }
351
352 // Pass TRUE to show full screen, FALSE to restore.
353 bool wxFrame::ShowFullScreen(bool show, long style)
354 {
355 if ( IsFullScreen() == show )
356 return FALSE;
357
358 if (show)
359 {
360 #if wxUSE_TOOLBAR
361 #ifdef __WXWINCE__
362 // TODO: hide commandbar
363 #else
364 wxToolBar *theToolBar = GetToolBar();
365 if (theToolBar)
366 theToolBar->GetSize(NULL, &m_fsToolBarHeight);
367
368 // zap the toolbar, menubar, and statusbar
369
370 if ((style & wxFULLSCREEN_NOTOOLBAR) && theToolBar)
371 {
372 theToolBar->SetSize(-1,0);
373 theToolBar->Show(FALSE);
374 }
375 #endif // __WXWINCE__
376 #endif // wxUSE_TOOLBAR
377
378 // TODO: make it work for WinCE
379 #if !defined(__WXMICROWIN__) && !defined(__WXWINCE__)
380 if (style & wxFULLSCREEN_NOMENUBAR)
381 SetMenu((HWND)GetHWND(), (HMENU) NULL);
382 #endif
383
384 #if wxUSE_STATUSBAR
385 wxStatusBar *theStatusBar = GetStatusBar();
386 if (theStatusBar)
387 theStatusBar->GetSize(NULL, &m_fsStatusBarHeight);
388
389 // Save the number of fields in the statusbar
390 if ((style & wxFULLSCREEN_NOSTATUSBAR) && theStatusBar)
391 {
392 //m_fsStatusBarFields = theStatusBar->GetFieldsCount();
393 //SetStatusBar((wxStatusBar*) NULL);
394 //delete theStatusBar;
395 theStatusBar->Show(FALSE);
396 }
397 else
398 m_fsStatusBarFields = 0;
399 #endif // wxUSE_STATUSBAR
400 }
401 else
402 {
403 #if wxUSE_TOOLBAR
404 #ifdef __WXWINCE__
405 // TODO: show commandbar
406 #else
407 wxToolBar *theToolBar = GetToolBar();
408
409 // restore the toolbar, menubar, and statusbar
410 if (theToolBar && (m_fsStyle & wxFULLSCREEN_NOTOOLBAR))
411 {
412 theToolBar->SetSize(-1, m_fsToolBarHeight);
413 theToolBar->Show(TRUE);
414 }
415 #endif // __WXWINCE__
416 #endif // wxUSE_TOOLBAR
417
418 #if wxUSE_STATUSBAR
419 if ( m_fsStyle & wxFULLSCREEN_NOSTATUSBAR )
420 {
421 //CreateStatusBar(m_fsStatusBarFields);
422 if (GetStatusBar())
423 {
424 GetStatusBar()->Show(TRUE);
425 PositionStatusBar();
426 }
427 }
428 #endif // wxUSE_STATUSBAR
429
430 // TODO: make it work for WinCE
431 #if !defined(__WXMICROWIN__) && !defined(__WXWINCE__)
432 if ((m_fsStyle & wxFULLSCREEN_NOMENUBAR) && (m_hMenu != 0))
433 SetMenu((HWND)GetHWND(), (HMENU)m_hMenu);
434 #endif
435 }
436
437 return wxFrameBase::ShowFullScreen(show, style);
438 }
439
440 // ----------------------------------------------------------------------------
441 // tool/status bar stuff
442 // ----------------------------------------------------------------------------
443
444 #if wxUSE_TOOLBAR
445
446 wxToolBar* wxFrame::CreateToolBar(long style, wxWindowID id, const wxString& name)
447 {
448 if ( wxFrameBase::CreateToolBar(style, id, name) )
449 {
450 PositionToolBar();
451 }
452
453 return m_frameToolBar;
454 }
455
456 void wxFrame::PositionToolBar()
457 {
458 wxToolBar *toolbar = GetToolBar();
459 if ( toolbar && toolbar->IsShown() )
460 {
461 #ifdef __WXWINCE__
462 // We want to do something different in WinCE, because
463 // the toolbar should be associated with the commandbar,
464 // and not an independent window.
465 // TODO
466 #else
467 // don't call our (or even wxTopLevelWindow) version because we want
468 // the real (full) client area size, not excluding the tool/status bar
469 int width, height;
470 wxWindow::DoGetClientSize(&width, &height);
471
472 #if wxUSE_STATUSBAR
473 wxStatusBar *statbar = GetStatusBar();
474 if ( statbar && statbar->IsShown() )
475 {
476 height -= statbar->GetClientSize().y;
477 }
478 #endif // wxUSE_STATUSBAR
479
480 int tw, th;
481 toolbar->GetSize(&tw, &th);
482
483 if ( toolbar->GetWindowStyleFlag() & wxTB_VERTICAL )
484 {
485 th = height;
486 }
487 else
488 {
489 tw = width;
490 if ( toolbar->GetWindowStyleFlag() & wxTB_FLAT )
491 th -= 3;
492 }
493
494 // use the 'real' MSW position here, don't offset relativly to the
495 // client area origin
496 toolbar->SetSize(0, 0, tw, th, wxSIZE_NO_ADJUSTMENTS);
497 #endif // __WXWINCE__
498 }
499 }
500
501 #endif // wxUSE_TOOLBAR
502
503 // ----------------------------------------------------------------------------
504 // frame state (iconized/maximized/...)
505 // ----------------------------------------------------------------------------
506
507 // propagate our state change to all child frames: this allows us to emulate X
508 // Windows behaviour where child frames float independently of the parent one
509 // on the desktop, but are iconized/restored with it
510 void wxFrame::IconizeChildFrames(bool bIconize)
511 {
512 for ( wxWindowList::compatibility_iterator node = GetChildren().GetFirst();
513 node;
514 node = node->GetNext() )
515 {
516 wxWindow *win = node->GetData();
517
518 // iconizing the frames with this style under Win95 shell puts them at
519 // the bottom of the screen (as the MDI children) instead of making
520 // them appear in the taskbar because they are, by virtue of this
521 // style, not managed by the taskbar - instead leave Windows take care
522 // of them
523 #ifdef __WIN95__
524 if ( win->GetWindowStyle() & wxFRAME_TOOL_WINDOW )
525 continue;
526 #endif // Win95
527
528 // the child MDI frames are a special case and should not be touched by
529 // the parent frame - instead, they are managed by the user
530 wxFrame *frame = wxDynamicCast(win, wxFrame);
531 if ( frame
532 #if wxUSE_MDI_ARCHITECTURE
533 && !wxDynamicCast(frame, wxMDIChildFrame)
534 #endif // wxUSE_MDI_ARCHITECTURE
535 )
536 {
537 // we don't want to restore the child frames which had been
538 // iconized even before we were iconized, so save the child frame
539 // status when iconizing the parent frame and check it when
540 // restoring it
541 if ( bIconize )
542 {
543 // note that we shouldn't touch the hidden frames neither
544 // because iconizing/restoring them would show them as a side
545 // effect
546 frame->m_wasMinimized = frame->IsIconized() || !frame->IsShown();
547 }
548
549 // this test works for both iconizing and restoring
550 if ( !frame->m_wasMinimized )
551 frame->Iconize(bIconize);
552 }
553 }
554 }
555
556 WXHICON wxFrame::GetDefaultIcon() const
557 {
558 // we don't have any standard icons (any more)
559 return (WXHICON)0;
560 }
561
562 // ===========================================================================
563 // message processing
564 // ===========================================================================
565
566 // ---------------------------------------------------------------------------
567 // preprocessing
568 // ---------------------------------------------------------------------------
569
570 bool wxFrame::MSWTranslateMessage(WXMSG* pMsg)
571 {
572 if ( wxWindow::MSWTranslateMessage(pMsg) )
573 return TRUE;
574
575 #if wxUSE_MENUS && wxUSE_ACCEL && !defined(__WXUNIVERSAL__)
576 // try the menu bar accels
577 wxMenuBar *menuBar = GetMenuBar();
578 if ( !menuBar )
579 return FALSE;
580
581 const wxAcceleratorTable& acceleratorTable = menuBar->GetAccelTable();
582 return acceleratorTable.Translate(this, pMsg);
583 #else
584 return FALSE;
585 #endif // wxUSE_MENUS && wxUSE_ACCEL
586 }
587
588 // ---------------------------------------------------------------------------
589 // our private (non virtual) message handlers
590 // ---------------------------------------------------------------------------
591
592 bool wxFrame::HandlePaint()
593 {
594 RECT rect;
595 if ( GetUpdateRect(GetHwnd(), &rect, FALSE) )
596 {
597 #if !defined(__WXMICROWIN__) && !defined(__WXWINCE__)
598 if ( m_iconized )
599 {
600 const wxIcon& icon = GetIcon();
601 HICON hIcon = icon.Ok() ? GetHiconOf(icon)
602 : (HICON)GetDefaultIcon();
603
604 // Hold a pointer to the dc so long as the OnPaint() message
605 // is being processed
606 PAINTSTRUCT ps;
607 HDC hdc = ::BeginPaint(GetHwnd(), &ps);
608
609 // Erase background before painting or we get white background
610 MSWDefWindowProc(WM_ICONERASEBKGND, (WORD)(LONG)ps.hdc, 0L);
611
612 if ( hIcon )
613 {
614 RECT rect;
615 ::GetClientRect(GetHwnd(), &rect);
616
617 // FIXME: why hardcoded?
618 static const int icon_width = 32;
619 static const int icon_height = 32;
620
621 int icon_x = (int)((rect.right - icon_width)/2);
622 int icon_y = (int)((rect.bottom - icon_height)/2);
623
624 ::DrawIcon(hdc, icon_x, icon_y, hIcon);
625 }
626
627 ::EndPaint(GetHwnd(), &ps);
628
629 return TRUE;
630 }
631 else
632 #endif
633 {
634 return wxWindow::HandlePaint();
635 }
636 }
637 else
638 {
639 // nothing to paint - processed
640 return TRUE;
641 }
642 }
643
644 bool wxFrame::HandleSize(int x, int y, WXUINT id)
645 {
646 bool processed = FALSE;
647 #if !defined(__WXMICROWIN__) && !defined(__WXWINCE__)
648
649 switch ( id )
650 {
651 case SIZENORMAL:
652 // only do it it if we were iconized before, otherwise resizing the
653 // parent frame has a curious side effect of bringing it under it's
654 // children
655 if ( !m_iconized )
656 break;
657
658 // restore all child frames too
659 IconizeChildFrames(FALSE);
660
661 (void)SendIconizeEvent(FALSE);
662
663 // fall through
664
665 case SIZEFULLSCREEN:
666 m_iconized = FALSE;
667 break;
668
669 case SIZEICONIC:
670 // iconize all child frames too
671 IconizeChildFrames(TRUE);
672
673 (void)SendIconizeEvent();
674
675 m_iconized = TRUE;
676 break;
677 }
678 #endif
679
680 if ( !m_iconized )
681 {
682 #if wxUSE_STATUSBAR
683 PositionStatusBar();
684 #endif // wxUSE_STATUSBAR
685
686 #if wxUSE_TOOLBAR
687 PositionToolBar();
688 #endif // wxUSE_TOOLBAR
689
690 processed = wxWindow::HandleSize(x, y, id);
691 }
692
693 return processed;
694 }
695
696 bool wxFrame::HandleCommand(WXWORD id, WXWORD cmd, WXHWND control)
697 {
698 if ( control )
699 {
700 // In case it's e.g. a toolbar.
701 wxWindow *win = wxFindWinFromHandle(control);
702 if ( win )
703 return win->MSWCommand(cmd, id);
704 }
705
706 // handle here commands from menus and accelerators
707 if ( cmd == 0 || cmd == 1 )
708 {
709 #if wxUSE_MENUS_NATIVE
710 if ( wxCurrentPopupMenu )
711 {
712 wxMenu *popupMenu = wxCurrentPopupMenu;
713 wxCurrentPopupMenu = NULL;
714
715 return popupMenu->MSWCommand(cmd, id);
716 }
717 #endif // wxUSE_MENUS_NATIVE
718
719 if ( ProcessCommand(id) )
720 {
721 return TRUE;
722 }
723 }
724
725 return FALSE;
726 }
727
728 bool wxFrame::HandleMenuSelect(WXWORD nItem, WXWORD flags, WXHMENU hMenu)
729 {
730 int item;
731 if ( flags == 0xFFFF && hMenu == 0 )
732 {
733 // menu was removed from screen
734 item = -1;
735 }
736 #ifndef __WXMICROWIN__
737 else if ( !(flags & MF_POPUP) && !(flags & MF_SEPARATOR) )
738 {
739 item = nItem;
740 }
741 #endif
742 else
743 {
744 // don't give hints for separators (doesn't make sense) nor for the
745 // items opening popup menus (they don't have them anyhow) but do clear
746 // the status line - otherwise, we would be left with the help message
747 // for the previous item which doesn't apply any more
748 DoGiveHelp(wxEmptyString, FALSE);
749
750 return FALSE;
751 }
752
753 wxMenuEvent event(wxEVT_MENU_HIGHLIGHT, item);
754 event.SetEventObject(this);
755
756 return GetEventHandler()->ProcessEvent(event);
757 }
758
759 bool wxFrame::HandleMenuLoop(const wxEventType& evtType, WXWORD isPopup)
760 {
761 // we don't have the menu id here, so we use the id to specify if the event
762 // was from a popup menu or a normal one
763 wxMenuEvent event(evtType, isPopup ? -1 : 0);
764 event.SetEventObject(this);
765
766 return GetEventHandler()->ProcessEvent(event);
767 }
768
769 // ---------------------------------------------------------------------------
770 // the window proc for wxFrame
771 // ---------------------------------------------------------------------------
772
773 long wxFrame::MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam)
774 {
775 long rc = 0;
776 bool processed = FALSE;
777
778 switch ( message )
779 {
780 case WM_CLOSE:
781 // if we can't close, tell the system that we processed the
782 // message - otherwise it would close us
783 processed = !Close();
784 break;
785
786 case WM_SIZE:
787 processed = HandleSize(LOWORD(lParam), HIWORD(lParam), wParam);
788 break;
789
790 case WM_COMMAND:
791 {
792 WORD id, cmd;
793 WXHWND hwnd;
794 UnpackCommand((WXWPARAM)wParam, (WXLPARAM)lParam,
795 &id, &hwnd, &cmd);
796
797 processed = HandleCommand(id, cmd, (WXHWND)hwnd);
798 }
799 break;
800
801 case WM_PAINT:
802 processed = HandlePaint();
803 break;
804
805 #if !defined(__WXMICROWIN__) && !defined(__WXWINCE__)
806 case WM_MENUSELECT:
807 {
808 WXWORD item, flags;
809 WXHMENU hmenu;
810 UnpackMenuSelect(wParam, lParam, &item, &flags, &hmenu);
811
812 processed = HandleMenuSelect(item, flags, hmenu);
813 }
814 break;
815
816 case WM_INITMENU:
817 processed = HandleInitMenu();
818 break;
819
820 case WM_EXITMENULOOP:
821 processed = HandleMenuLoop(wxEVT_MENU_CLOSE, wParam);
822 break;
823
824 case WM_QUERYDRAGICON:
825 {
826 const wxIcon& icon = GetIcon();
827 HICON hIcon = icon.Ok() ? GetHiconOf(icon)
828 : (HICON)GetDefaultIcon();
829 rc = (long)hIcon;
830 processed = rc != 0;
831 }
832 break;
833 #endif // !__WXMICROWIN__
834 }
835
836 if ( !processed )
837 rc = wxFrameBase::MSWWindowProc(message, wParam, lParam);
838
839 return rc;
840 }
841
842 // handle WM_INITMENU message
843 bool wxFrame::HandleInitMenu()
844 {
845 wxMenuEvent event(wxEVT_MENU_OPEN, 0);
846 event.SetEventObject(this);
847
848 return GetEventHandler()->ProcessEvent(event);
849 }
850
851