1 /////////////////////////////////////////////////////////////////////////////
4 // Author: Julian Smart
8 // Copyright: (c) Julian Smart and Markus Holzem
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 // ============================================================================
14 // ============================================================================
16 // ----------------------------------------------------------------------------
18 // ----------------------------------------------------------------------------
21 #pragma implementation "frame.h"
24 // For compilers that support precompilation, includes "wx.h".
25 #include "wx/wxprec.h"
37 #include "wx/dialog.h"
38 #include "wx/settings.h"
39 #include "wx/dcclient.h"
44 #include "wx/msw/private.h"
47 #include "wx/statusbr.h"
48 #include "wx/generic/statusbr.h"
49 #endif // wxUSE_STATUSBAR
52 #include "wx/toolbar.h"
53 #endif // wxUSE_TOOLBAR
55 #include "wx/menuitem.h"
58 // ----------------------------------------------------------------------------
60 // ----------------------------------------------------------------------------
62 extern wxWindowList wxModelessWindows
;
63 extern wxList WXDLLEXPORT wxPendingDelete
;
64 extern const wxChar
*wxFrameClassName
;
65 extern wxMenu
*wxCurrentPopupMenu
;
67 // ----------------------------------------------------------------------------
69 // ----------------------------------------------------------------------------
71 BEGIN_EVENT_TABLE(wxFrame
, wxFrameBase
)
72 EVT_ACTIVATE(wxFrame::OnActivate
)
73 EVT_SYS_COLOUR_CHANGED(wxFrame::OnSysColourChanged
)
76 IMPLEMENT_DYNAMIC_CLASS(wxFrame
, wxWindow
)
78 // ============================================================================
80 // ============================================================================
82 // ----------------------------------------------------------------------------
83 // static class members
84 // ----------------------------------------------------------------------------
86 #if wxUSE_NATIVE_STATUSBAR
87 bool wxFrame::m_useNativeStatusBar
= TRUE
;
89 bool wxFrame::m_useNativeStatusBar
= FALSE
;
92 // ----------------------------------------------------------------------------
93 // creation/destruction
94 // ----------------------------------------------------------------------------
104 // Data to save/restore when calling ShowFullScreen
106 m_fsOldWindowStyle
= 0;
107 m_fsStatusBarFields
= 0;
108 m_fsStatusBarHeight
= 0;
109 m_fsToolBarHeight
= 0;
111 m_fsIsMaximized
= FALSE
;
112 m_fsIsShowing
= FALSE
;
114 m_winLastFocused
= (wxWindow
*)NULL
;
116 // unlike (almost?) all other windows, frames are created hidden
120 bool wxFrame::Create(wxWindow
*parent
,
122 const wxString
& title
,
126 const wxString
& name
)
129 m_windowStyle
= style
;
130 m_frameMenuBar
= NULL
;
131 m_frameToolBar
= NULL
;
132 m_frameStatusBar
= NULL
;
134 SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_APPWORKSPACE
));
139 m_windowId
= (int)NewControlId();
141 if (parent
) parent
->AddChild(this);
150 // we pass NULL as parent to MSWCreate because frames with parents behave
151 // very strangely under Win95 shell
152 // Alteration by JACS: keep normal Windows behaviour (float on top of parent)
154 if ((m_windowStyle
& wxFRAME_FLOAT_ON_PARENT
) == 0)
157 wxTopLevelWindows
.Append(this);
159 MSWCreate(m_windowId
, parent
, wxFrameClassName
, this, title
,
160 x
, y
, width
, height
, style
);
162 wxModelessWindows
.Append(this);
169 m_isBeingDeleted
= TRUE
;
170 wxTopLevelWindows
.DeleteObject(this);
172 // the ~wxToolBar() code relies on the previous line to be executed before
173 // this one, i.e. the frame should remove itself from wxTopLevelWindows
174 // before destorying its toolbar
177 if (wxTheApp
&& (wxTopLevelWindows
.Number() == 0))
179 wxTheApp
->SetTopWindow(NULL
);
181 if (wxTheApp
->GetExitOnFrameDelete())
187 wxModelessWindows
.DeleteObject(this);
189 // For some reason, wxWindows can activate another task altogether
190 // when a frame is destroyed after a modal dialog has been invoked.
191 // Try to bring the parent to the top.
192 // MT:Only do this if this frame is currently the active window, else weird
193 // things start to happen
194 if ( wxGetActiveWindow() == this )
195 if (GetParent() && GetParent()->GetHWND())
196 ::BringWindowToTop((HWND
) GetParent()->GetHWND());
199 // Get size *available for subwindows* i.e. excluding menu bar, toolbar etc.
200 void wxFrame::DoGetClientSize(int *x
, int *y
) const
203 ::GetClientRect(GetHwnd(), &rect
);
206 if ( GetStatusBar() && GetStatusBar()->IsShown() )
208 int statusX
, statusY
;
209 GetStatusBar()->GetClientSize(&statusX
, &statusY
);
210 rect
.bottom
-= statusY
;
212 #endif // wxUSE_STATUSBAR
214 wxPoint
pt(GetClientAreaOrigin());
224 // Set the client size (i.e. leave the calculation of borders etc.
226 void wxFrame::DoSetClientSize(int width
, int height
)
228 HWND hWnd
= GetHwnd();
231 ::GetClientRect(hWnd
, &rect
);
234 GetWindowRect(hWnd
, &rect2
);
236 // Find the difference between the entire window (title bar and all)
237 // and the client area; add this to the new client size to move the
239 int actual_width
= rect2
.right
- rect2
.left
- rect
.right
+ width
;
240 int actual_height
= rect2
.bottom
- rect2
.top
- rect
.bottom
+ height
;
243 if ( GetStatusBar() && GetStatusBar()->IsShown())
245 int statusX
, statusY
;
246 GetStatusBar()->GetClientSize(&statusX
, &statusY
);
247 actual_height
+= statusY
;
249 #endif // wxUSE_STATUSBAR
251 wxPoint
pt(GetClientAreaOrigin());
252 actual_width
+= pt
.y
;
253 actual_height
+= pt
.x
;
256 point
.x
= rect2
.left
;
259 MoveWindow(hWnd
, point
.x
, point
.y
, actual_width
, actual_height
, (BOOL
)TRUE
);
261 wxSizeEvent
event(wxSize(width
, height
), m_windowId
);
262 event
.SetEventObject( this );
263 GetEventHandler()->ProcessEvent(event
);
266 void wxFrame::DoGetSize(int *width
, int *height
) const
269 GetWindowRect(GetHwnd(), &rect
);
270 *width
= rect
.right
- rect
.left
;
271 *height
= rect
.bottom
- rect
.top
;
274 void wxFrame::DoGetPosition(int *x
, int *y
) const
277 GetWindowRect(GetHwnd(), &rect
);
286 // ----------------------------------------------------------------------------
287 // variations around ::ShowWindow()
288 // ----------------------------------------------------------------------------
290 void wxFrame::DoShowWindow(int nShowCmd
)
292 ::ShowWindow(GetHwnd(), nShowCmd
);
294 m_iconized
= nShowCmd
== SW_MINIMIZE
;
297 bool wxFrame::Show(bool show
)
299 // don't use wxWindow version as we want to call DoShowWindow()
300 if ( !wxWindowBase::Show(show
) )
303 DoShowWindow(show
? SW_SHOW
: SW_HIDE
);
307 ::BringWindowToTop(GetHwnd());
309 wxActivateEvent
event(wxEVT_ACTIVATE
, TRUE
, m_windowId
);
310 event
.SetEventObject( this );
311 GetEventHandler()->ProcessEvent(event
);
315 // Try to highlight the correct window (the parent)
318 HWND hWndParent
= GetHwndOf(GetParent());
320 ::BringWindowToTop(hWndParent
);
327 void wxFrame::Iconize(bool iconize
)
329 DoShowWindow(iconize
? SW_MINIMIZE
: SW_RESTORE
);
332 void wxFrame::Maximize(bool maximize
)
334 DoShowWindow(maximize
? SW_MAXIMIZE
: SW_RESTORE
);
337 void wxFrame::Restore()
339 DoShowWindow(SW_RESTORE
);
342 bool wxFrame::IsIconized() const
344 ((wxFrame
*)this)->m_iconized
= (::IsIconic(GetHwnd()) != 0);
349 bool wxFrame::IsMaximized() const
351 return (::IsZoomed(GetHwnd()) != 0);
354 void wxFrame::SetIcon(const wxIcon
& icon
)
356 wxFrameBase::SetIcon(icon
);
358 #if defined(__WIN95__)
361 SendMessage(GetHwnd(), WM_SETICON
,
362 (WPARAM
)TRUE
, (LPARAM
)(HICON
) m_icon
.GetHICON());
368 wxStatusBar
*wxFrame::OnCreateStatusBar(int number
,
371 const wxString
& name
)
373 wxStatusBar
*statusBar
= NULL
;
375 #if wxUSE_NATIVE_STATUSBAR
376 if ( !UsesNativeStatusBar() )
378 statusBar
= (wxStatusBar
*)new wxStatusBarGeneric(this, id
, style
);
383 statusBar
= new wxStatusBar(this, id
, style
, name
);
386 // Set the height according to the font and the border size
387 wxClientDC
dc(statusBar
);
388 dc
.SetFont(statusBar
->GetFont());
391 dc
.GetTextExtent(_T("X"), NULL
, &y
);
393 int height
= (int)( (11*y
)/10 + 2*statusBar
->GetBorderY());
395 statusBar
->SetSize(-1, -1, -1, height
);
397 statusBar
->SetFieldsCount(number
);
402 void wxFrame::PositionStatusBar()
404 if ( !m_frameStatusBar
)
408 GetClientSize(&w
, &h
);
410 m_frameStatusBar
->GetSize(&sw
, &sh
);
412 // Since we wish the status bar to be directly under the client area,
413 // we use the adjusted sizes without using wxSIZE_NO_ADJUSTMENTS.
414 m_frameStatusBar
->SetSize(0, h
, w
, sh
);
416 #endif // wxUSE_STATUSBAR
418 void wxFrame::DetachMenuBar()
420 if ( m_frameMenuBar
)
422 m_frameMenuBar
->Detach();
423 m_frameMenuBar
= NULL
;
427 void wxFrame::SetMenuBar(wxMenuBar
*menubar
)
433 // actually remove the menu from the frame
434 m_hMenu
= (WXHMENU
)0;
435 InternalSetMenuBar();
437 else // set new non NULL menu bar
439 m_frameMenuBar
= NULL
;
441 // Can set a menubar several times.
442 // TODO: how to prevent a memory leak if you have a currently-unattached
443 // menubar? wxWindows assumes that the frame will delete the menu (otherwise
444 // there are problems for MDI).
445 if ( menubar
->GetHMenu() )
447 m_hMenu
= menubar
->GetHMenu();
453 m_hMenu
= menubar
->Create();
459 InternalSetMenuBar();
461 m_frameMenuBar
= menubar
;
462 menubar
->Attach(this);
466 void wxFrame::InternalSetMenuBar()
468 if ( !::SetMenu(GetHwnd(), (HMENU
)m_hMenu
) )
470 wxLogLastError(wxT("SetMenu"));
474 // Responds to colour changes, and passes event on to children.
475 void wxFrame::OnSysColourChanged(wxSysColourChangedEvent
& event
)
477 SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_APPWORKSPACE
));
480 if ( m_frameStatusBar
)
482 wxSysColourChangedEvent event2
;
483 event2
.SetEventObject( m_frameStatusBar
);
484 m_frameStatusBar
->GetEventHandler()->ProcessEvent(event2
);
487 // Propagate the event to the non-top-level children
488 wxWindow::OnSysColourChanged(event
);
491 // Pass TRUE to show full screen, FALSE to restore.
492 bool wxFrame::ShowFullScreen(bool show
, long style
)
499 m_fsIsShowing
= TRUE
;
502 wxToolBar
*theToolBar
= GetToolBar();
503 wxStatusBar
*theStatusBar
= GetStatusBar();
508 theToolBar
->GetSize(&dummyWidth
, &m_fsToolBarHeight
);
510 theStatusBar
->GetSize(&dummyWidth
, &m_fsStatusBarHeight
);
512 // zap the toolbar, menubar, and statusbar
514 if ((style
& wxFULLSCREEN_NOTOOLBAR
) && theToolBar
)
516 theToolBar
->SetSize(-1,0);
517 theToolBar
->Show(FALSE
);
520 if (style
& wxFULLSCREEN_NOMENUBAR
)
521 SetMenu((HWND
)GetHWND(), (HMENU
) NULL
);
523 // Save the number of fields in the statusbar
524 if ((style
& wxFULLSCREEN_NOSTATUSBAR
) && theStatusBar
)
526 m_fsStatusBarFields
= theStatusBar
->GetFieldsCount();
527 SetStatusBar((wxStatusBar
*) NULL
);
531 m_fsStatusBarFields
= 0;
533 // zap the frame borders
535 // save the 'normal' window style
536 m_fsOldWindowStyle
= GetWindowLong((HWND
)GetHWND(), GWL_STYLE
);
538 // save the old position, width & height, maximize state
539 m_fsOldSize
= GetRect();
540 m_fsIsMaximized
= IsMaximized();
542 // decide which window style flags to turn off
543 LONG newStyle
= m_fsOldWindowStyle
;
546 if (style
& wxFULLSCREEN_NOBORDER
)
547 offFlags
|= WS_BORDER
;
548 if (style
& wxFULLSCREEN_NOCAPTION
)
549 offFlags
|= (WS_CAPTION
| WS_SYSMENU
);
551 newStyle
&= (~offFlags
);
553 // change our window style to be compatible with full-screen mode
554 SetWindowLong((HWND
)GetHWND(), GWL_STYLE
, newStyle
);
556 // resize to the size of the desktop
560 ::GetWindowRect(GetDesktopWindow(), &rect
);
561 width
= rect
.right
- rect
.left
;
562 height
= rect
.bottom
- rect
.top
;
564 SetSize(width
, height
);
566 // now flush the window style cache and actually go full-screen
567 SetWindowPos((HWND
)GetHWND(), HWND_TOP
, 0, 0, width
, height
, SWP_FRAMECHANGED
);
569 wxSizeEvent
event(wxSize(width
, height
), GetId());
570 GetEventHandler()->ProcessEvent(event
);
579 m_fsIsShowing
= FALSE
;
581 wxToolBar
*theToolBar
= GetToolBar();
583 // restore the toolbar, menubar, and statusbar
584 if (theToolBar
&& (m_fsStyle
& wxFULLSCREEN_NOTOOLBAR
))
586 theToolBar
->SetSize(-1, m_fsToolBarHeight
);
587 theToolBar
->Show(TRUE
);
590 if ((m_fsStyle
& wxFULLSCREEN_NOSTATUSBAR
) && (m_fsStatusBarFields
> 0))
592 CreateStatusBar(m_fsStatusBarFields
);
596 if ((m_fsStyle
& wxFULLSCREEN_NOMENUBAR
) && (m_hMenu
!= 0))
597 SetMenu((HWND
)GetHWND(), (HMENU
)m_hMenu
);
599 Maximize(m_fsIsMaximized
);
600 SetWindowLong((HWND
)GetHWND(),GWL_STYLE
, m_fsOldWindowStyle
);
601 SetWindowPos((HWND
)GetHWND(),HWND_TOP
,m_fsOldSize
.x
, m_fsOldSize
.y
,
602 m_fsOldSize
.width
, m_fsOldSize
.height
, SWP_FRAMECHANGED
);
613 bool wxFrame::MSWCreate(int id
, wxWindow
*parent
, const wxChar
*wclass
, wxWindow
*wx_win
, const wxChar
*title
,
614 int x
, int y
, int width
, int height
, long style
)
617 m_defaultIcon
= (WXHICON
) (wxSTD_FRAME_ICON
? wxSTD_FRAME_ICON
: wxDEFAULT_FRAME_ICON
);
619 // If child windows aren't properly drawn initially, WS_CLIPCHILDREN
620 // could be the culprit. But without it, you can get a lot of flicker.
623 if ( style
& wxCAPTION
)
625 if ( style
& wxFRAME_TOOL_WINDOW
)
626 msflags
|= WS_POPUPWINDOW
;
628 msflags
|= WS_OVERLAPPED
;
635 if (style
& wxMINIMIZE_BOX
)
636 msflags
|= WS_MINIMIZEBOX
;
637 if (style
& wxMAXIMIZE_BOX
)
638 msflags
|= WS_MAXIMIZEBOX
;
639 if (style
& wxTHICK_FRAME
)
640 msflags
|= WS_THICKFRAME
;
641 if (style
& wxSYSTEM_MENU
)
642 msflags
|= WS_SYSMENU
;
643 if ( style
& wxMINIMIZE
)
644 msflags
|= WS_MINIMIZE
;
645 if (style
& wxMAXIMIZE
)
646 msflags
|= WS_MAXIMIZE
;
647 if (style
& wxCAPTION
)
648 msflags
|= WS_CAPTION
;
649 if (style
& wxCLIP_CHILDREN
)
650 msflags
|= WS_CLIPCHILDREN
;
652 // Keep this in wxFrame because it saves recoding this function
654 #if wxUSE_ITSY_BITSY && !defined(__WIN32__)
655 if (style
& wxTINY_CAPTION_VERT
)
656 msflags
|= IBS_VERTCAPTION
;
657 if (style
& wxTINY_CAPTION_HORIZ
)
658 msflags
|= IBS_HORZCAPTION
;
660 if (style
& wxTINY_CAPTION_VERT
)
661 msflags
|= WS_CAPTION
;
662 if (style
& wxTINY_CAPTION_HORIZ
)
663 msflags
|= WS_CAPTION
;
665 if ((style
& wxTHICK_FRAME
) == 0)
666 msflags
|= WS_BORDER
;
668 WXDWORD extendedStyle
= MakeExtendedStyle(style
);
670 #if !defined(__WIN16__) && !defined(__SC__)
671 if (style
& wxFRAME_TOOL_WINDOW
)
672 extendedStyle
|= WS_EX_TOOLWINDOW
;
675 if (style
& wxSTAY_ON_TOP
)
676 extendedStyle
|= WS_EX_TOPMOST
;
679 if ( !wxWindow::MSWCreate(id
, parent
, wclass
, wx_win
, title
, x
, y
, width
, height
,
680 msflags
, NULL
, extendedStyle
) )
683 // Seems to be necessary if we use WS_POPUP
684 // style instead of WS_OVERLAPPED
685 if (width
> -1 && height
> -1)
686 ::PostMessage(GetHwnd(), WM_SIZE
, SIZE_RESTORED
, MAKELPARAM(width
, height
));
691 // Default activation behaviour - set the focus for the first child
693 void wxFrame::OnActivate(wxActivateEvent
& event
)
695 if ( event
.GetActive() )
697 // restore focus to the child which was last focused
698 wxLogTrace(_T("focus"), _T("wxFrame %08x activated."), m_hWnd
);
700 wxSetFocusToChild(this, &m_winLastFocused
);
704 // remember the last focused child
705 m_winLastFocused
= FindFocus();
706 while ( m_winLastFocused
)
708 if ( GetChildren().Find(m_winLastFocused
) )
711 m_winLastFocused
= m_winLastFocused
->GetParent();
714 wxLogTrace(_T("focus"),
715 _T("wxFrame %08x deactivated, last focused: %08x."),
717 m_winLastFocused
? GetHwndOf(m_winLastFocused
)
724 // ----------------------------------------------------------------------------
725 // tool/status bar stuff
726 // ----------------------------------------------------------------------------
730 wxToolBar
* wxFrame::CreateToolBar(long style
, wxWindowID id
, const wxString
& name
)
732 if ( wxFrameBase::CreateToolBar(style
, id
, name
) )
737 return m_frameToolBar
;
740 void wxFrame::PositionToolBar()
743 ::GetClientRect(GetHwnd(), &rect
);
746 if ( GetStatusBar() )
748 int statusX
, statusY
;
749 GetStatusBar()->GetClientSize(&statusX
, &statusY
);
750 rect
.bottom
-= statusY
;
752 #endif // wxUSE_STATUSBAR
754 if ( GetToolBar() && GetToolBar()->IsShown() )
757 GetToolBar()->GetSize(&tw
, &th
);
759 if ( GetToolBar()->GetWindowStyleFlag() & wxTB_VERTICAL
)
768 // Use the 'real' MSW position here
769 GetToolBar()->SetSize(0, 0, tw
, th
, wxSIZE_NO_ADJUSTMENTS
);
772 #endif // wxUSE_TOOLBAR
774 // ----------------------------------------------------------------------------
775 // frame state (iconized/maximized/...)
776 // ----------------------------------------------------------------------------
778 // propagate our state change to all child frames: this allows us to emulate X
779 // Windows behaviour where child frames float independently of the parent one
780 // on the desktop, but are iconized/restored with it
781 void wxFrame::IconizeChildFrames(bool bIconize
)
783 for ( wxWindowList::Node
*node
= GetChildren().GetFirst();
785 node
= node
->GetNext() )
787 wxWindow
*win
= node
->GetData();
789 // iconizing the frames with this style under Win95 shell puts them at
790 // the bottom of the screen (as the MDI children) instead of making
791 // them appear in the taskbar because they are, by virtue of this
792 // style, not managed by the taskbar - instead leave Windows take care
795 if ( win
->GetWindowStyle() & wxFRAME_TOOL_WINDOW
)
799 // the child MDI frames are a special case and should not be touched by
800 // the parent frame - instead, they are managed by the user
801 wxFrame
*frame
= wxDynamicCast(win
, wxFrame
);
802 if ( frame
&& !wxDynamicCast(frame
, wxMDIChildFrame
) )
804 frame
->Iconize(bIconize
);
809 // ===========================================================================
810 // message processing
811 // ===========================================================================
813 // ---------------------------------------------------------------------------
815 // ---------------------------------------------------------------------------
817 bool wxFrame::MSWTranslateMessage(WXMSG
* pMsg
)
819 if ( wxWindow::MSWTranslateMessage(pMsg
) )
822 // try the menu bar accels
823 wxMenuBar
*menuBar
= GetMenuBar();
827 const wxAcceleratorTable
& acceleratorTable
= menuBar
->GetAccelTable();
828 return acceleratorTable
.Translate(this, pMsg
);
831 // ---------------------------------------------------------------------------
832 // our private (non virtual) message handlers
833 // ---------------------------------------------------------------------------
835 bool wxFrame::HandlePaint()
838 if ( GetUpdateRect(GetHwnd(), &rect
, FALSE
) )
842 HICON hIcon
= m_icon
.Ok() ? GetHiconOf(m_icon
)
843 : (HICON
)m_defaultIcon
;
845 // Hold a pointer to the dc so long as the OnPaint() message
846 // is being processed
848 HDC hdc
= ::BeginPaint(GetHwnd(), &ps
);
850 // Erase background before painting or we get white background
851 MSWDefWindowProc(WM_ICONERASEBKGND
, (WORD
)(LONG
)ps
.hdc
, 0L);
856 ::GetClientRect(GetHwnd(), &rect
);
858 // FIXME: why hardcoded?
859 static const int icon_width
= 32;
860 static const int icon_height
= 32;
862 int icon_x
= (int)((rect
.right
- icon_width
)/2);
863 int icon_y
= (int)((rect
.bottom
- icon_height
)/2);
865 ::DrawIcon(hdc
, icon_x
, icon_y
, hIcon
);
868 ::EndPaint(GetHwnd(), &ps
);
874 return wxWindow::HandlePaint();
879 // nothing to paint - processed
884 bool wxFrame::HandleSize(int x
, int y
, WXUINT id
)
886 bool processed
= FALSE
;
891 // only do it it if we were iconized before, otherwise resizing the
892 // parent frame has a curious side effect of bringing it under it's
897 // restore all child frames too
898 IconizeChildFrames(FALSE
);
907 // iconize all child frames too
908 IconizeChildFrames(TRUE
);
919 wxSizeEvent
event(wxSize(x
, y
), m_windowId
);
920 event
.SetEventObject( this );
921 processed
= GetEventHandler()->ProcessEvent(event
);
927 bool wxFrame::HandleCommand(WXWORD id
, WXWORD cmd
, WXHWND control
)
931 // In case it's e.g. a toolbar.
932 wxWindow
*win
= wxFindWinFromHandle(control
);
934 return win
->MSWCommand(cmd
, id
);
937 // handle here commands from menus and accelerators
938 if ( cmd
== 0 || cmd
== 1 )
940 if ( wxCurrentPopupMenu
)
942 wxMenu
*popupMenu
= wxCurrentPopupMenu
;
943 wxCurrentPopupMenu
= NULL
;
945 return popupMenu
->MSWCommand(cmd
, id
);
948 if ( ProcessCommand(id
) )
957 bool wxFrame::HandleMenuSelect(WXWORD nItem
, WXWORD flags
, WXHMENU hMenu
)
960 if ( flags
== 0xFFFF && hMenu
== 0 )
962 // menu was removed from screen
965 else if ( !(flags
& MF_POPUP
) && !(flags
& MF_SEPARATOR
) )
971 // don't give hints for separators (doesn't make sense) nor for the
972 // items opening popup menus (they don't have them anyhow) but do clear
973 // the status line - otherwise, we would be left with the help message
974 // for the previous item which doesn't apply any more
975 wxStatusBar
*statbar
= GetStatusBar();
978 statbar
->SetStatusText(wxEmptyString
);
984 wxMenuEvent
event(wxEVT_MENU_HIGHLIGHT
, item
);
985 event
.SetEventObject( this );
987 return GetEventHandler()->ProcessEvent(event
);
990 // ---------------------------------------------------------------------------
991 // the window proc for wxFrame
992 // ---------------------------------------------------------------------------
994 long wxFrame::MSWWindowProc(WXUINT message
, WXWPARAM wParam
, WXLPARAM lParam
)
997 bool processed
= FALSE
;
1002 // if we can't close, tell the system that we processed the
1003 // message - otherwise it would close us
1004 processed
= !Close();
1011 UnpackCommand((WXWPARAM
)wParam
, (WXLPARAM
)lParam
,
1014 processed
= HandleCommand(id
, cmd
, (WXHWND
)hwnd
);
1022 UnpackMenuSelect(wParam
, lParam
, &item
, &flags
, &hmenu
);
1024 processed
= HandleMenuSelect(item
, flags
, hmenu
);
1029 processed
= HandlePaint();
1032 case WM_QUERYDRAGICON
:
1034 HICON hIcon
= m_icon
.Ok() ? GetHiconOf(m_icon
)
1035 : (HICON
)(m_defaultIcon
);
1037 processed
= rc
!= 0;
1042 processed
= HandleSize(LOWORD(lParam
), HIWORD(lParam
), wParam
);
1047 rc
= wxWindow::MSWWindowProc(message
, wParam
, lParam
);