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