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