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 wxTopLevelWindows
.Append(this);
152 MSWCreate(m_windowId
, parent
, wxFrameClassName
, this, title
,
153 x
, y
, width
, height
, style
);
155 wxModelessWindows
.Append(this);
162 m_isBeingDeleted
= TRUE
;
163 wxTopLevelWindows
.DeleteObject(this);
165 // the ~wxToolBar() code relies on the previous line to be executed before
166 // this one, i.e. the frame should remove itself from wxTopLevelWindows
167 // before destorying its toolbar
170 if (wxTheApp
&& (wxTopLevelWindows
.Number() == 0))
172 wxTheApp
->SetTopWindow(NULL
);
174 if (wxTheApp
->GetExitOnFrameDelete())
180 wxModelessWindows
.DeleteObject(this);
182 // For some reason, wxWindows can activate another task altogether
183 // when a frame is destroyed after a modal dialog has been invoked.
184 // Try to bring the parent to the top.
185 // MT:Only do this if this frame is currently the active window, else weird
186 // things start to happen
187 if ( wxGetActiveWindow() == this )
188 if (GetParent() && GetParent()->GetHWND())
189 ::BringWindowToTop((HWND
) GetParent()->GetHWND());
192 // Get size *available for subwindows* i.e. excluding menu bar, toolbar etc.
193 void wxFrame::DoGetClientSize(int *x
, int *y
) const
196 ::GetClientRect(GetHwnd(), &rect
);
199 if ( GetStatusBar() && GetStatusBar()->IsShown() )
201 int statusX
, statusY
;
202 GetStatusBar()->GetClientSize(&statusX
, &statusY
);
203 rect
.bottom
-= statusY
;
205 #endif // wxUSE_STATUSBAR
207 wxPoint
pt(GetClientAreaOrigin());
217 // Set the client size (i.e. leave the calculation of borders etc.
219 void wxFrame::DoSetClientSize(int width
, int height
)
221 HWND hWnd
= GetHwnd();
224 ::GetClientRect(hWnd
, &rect
);
227 GetWindowRect(hWnd
, &rect2
);
229 // Find the difference between the entire window (title bar and all)
230 // and the client area; add this to the new client size to move the
232 int actual_width
= rect2
.right
- rect2
.left
- rect
.right
+ width
;
233 int actual_height
= rect2
.bottom
- rect2
.top
- rect
.bottom
+ height
;
236 if ( GetStatusBar() && GetStatusBar()->IsShown())
238 int statusX
, statusY
;
239 GetStatusBar()->GetClientSize(&statusX
, &statusY
);
240 actual_height
+= statusY
;
242 #endif // wxUSE_STATUSBAR
244 wxPoint
pt(GetClientAreaOrigin());
245 actual_width
+= pt
.y
;
246 actual_height
+= pt
.x
;
249 point
.x
= rect2
.left
;
252 MoveWindow(hWnd
, point
.x
, point
.y
, actual_width
, actual_height
, (BOOL
)TRUE
);
254 wxSizeEvent
event(wxSize(width
, height
), m_windowId
);
255 event
.SetEventObject( this );
256 GetEventHandler()->ProcessEvent(event
);
259 void wxFrame::DoGetSize(int *width
, int *height
) const
262 GetWindowRect(GetHwnd(), &rect
);
263 *width
= rect
.right
- rect
.left
;
264 *height
= rect
.bottom
- rect
.top
;
267 void wxFrame::DoGetPosition(int *x
, int *y
) const
270 GetWindowRect(GetHwnd(), &rect
);
279 // ----------------------------------------------------------------------------
280 // variations around ::ShowWindow()
281 // ----------------------------------------------------------------------------
283 void wxFrame::DoShowWindow(int nShowCmd
)
285 ::ShowWindow(GetHwnd(), nShowCmd
);
287 m_iconized
= nShowCmd
== SW_MINIMIZE
;
290 bool wxFrame::Show(bool show
)
292 // don't use wxWindow version as we want to call DoShowWindow()
293 if ( !wxWindowBase::Show(show
) )
296 DoShowWindow(show
? SW_SHOW
: SW_HIDE
);
300 ::BringWindowToTop(GetHwnd());
302 wxActivateEvent
event(wxEVT_ACTIVATE
, TRUE
, m_windowId
);
303 event
.SetEventObject( this );
304 GetEventHandler()->ProcessEvent(event
);
308 // Try to highlight the correct window (the parent)
311 HWND hWndParent
= GetHwndOf(GetParent());
313 ::BringWindowToTop(hWndParent
);
320 void wxFrame::Iconize(bool iconize
)
322 DoShowWindow(iconize
? SW_MINIMIZE
: SW_RESTORE
);
325 void wxFrame::Maximize(bool maximize
)
327 DoShowWindow(maximize
? SW_MAXIMIZE
: SW_RESTORE
);
330 void wxFrame::Restore()
332 DoShowWindow(SW_RESTORE
);
335 bool wxFrame::IsIconized() const
337 ((wxFrame
*)this)->m_iconized
= (::IsIconic(GetHwnd()) != 0);
342 bool wxFrame::IsMaximized() const
344 return (::IsZoomed(GetHwnd()) != 0);
347 void wxFrame::SetIcon(const wxIcon
& icon
)
349 wxFrameBase::SetIcon(icon
);
351 #if defined(__WIN95__)
354 SendMessage(GetHwnd(), WM_SETICON
,
355 (WPARAM
)TRUE
, (LPARAM
)(HICON
) m_icon
.GetHICON());
361 wxStatusBar
*wxFrame::OnCreateStatusBar(int number
,
364 const wxString
& name
)
366 wxStatusBar
*statusBar
= NULL
;
368 #if wxUSE_NATIVE_STATUSBAR
369 if ( !UsesNativeStatusBar() )
371 statusBar
= (wxStatusBar
*)new wxStatusBarGeneric(this, id
, style
);
376 statusBar
= new wxStatusBar(this, id
, style
, name
);
379 // Set the height according to the font and the border size
380 wxClientDC
dc(statusBar
);
381 dc
.SetFont(statusBar
->GetFont());
384 dc
.GetTextExtent(_T("X"), NULL
, &y
);
386 int height
= (int)( (11*y
)/10 + 2*statusBar
->GetBorderY());
388 statusBar
->SetSize(-1, -1, -1, height
);
390 statusBar
->SetFieldsCount(number
);
395 void wxFrame::PositionStatusBar()
397 if ( !m_frameStatusBar
)
401 GetClientSize(&w
, &h
);
403 m_frameStatusBar
->GetSize(&sw
, &sh
);
405 // Since we wish the status bar to be directly under the client area,
406 // we use the adjusted sizes without using wxSIZE_NO_ADJUSTMENTS.
407 m_frameStatusBar
->SetSize(0, h
, w
, sh
);
409 #endif // wxUSE_STATUSBAR
411 void wxFrame::DetachMenuBar()
413 if ( m_frameMenuBar
)
415 m_frameMenuBar
->Detach();
416 m_frameMenuBar
= NULL
;
420 void wxFrame::SetMenuBar(wxMenuBar
*menubar
)
426 // actually remove the menu from the frame
427 m_hMenu
= (WXHMENU
)0;
428 InternalSetMenuBar();
430 else // set new non NULL menu bar
432 m_frameMenuBar
= NULL
;
434 // Can set a menubar several times.
435 // TODO: how to prevent a memory leak if you have a currently-unattached
436 // menubar? wxWindows assumes that the frame will delete the menu (otherwise
437 // there are problems for MDI).
438 if ( menubar
->GetHMenu() )
440 m_hMenu
= menubar
->GetHMenu();
446 m_hMenu
= menubar
->Create();
452 InternalSetMenuBar();
454 m_frameMenuBar
= menubar
;
455 menubar
->Attach(this);
459 void wxFrame::InternalSetMenuBar()
461 if ( !::SetMenu(GetHwnd(), (HMENU
)m_hMenu
) )
463 wxLogLastError(wxT("SetMenu"));
467 // Responds to colour changes, and passes event on to children.
468 void wxFrame::OnSysColourChanged(wxSysColourChangedEvent
& event
)
470 SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_APPWORKSPACE
));
473 if ( m_frameStatusBar
)
475 wxSysColourChangedEvent event2
;
476 event2
.SetEventObject( m_frameStatusBar
);
477 m_frameStatusBar
->GetEventHandler()->ProcessEvent(event2
);
480 // Propagate the event to the non-top-level children
481 wxWindow::OnSysColourChanged(event
);
484 // Pass TRUE to show full screen, FALSE to restore.
485 bool wxFrame::ShowFullScreen(bool show
, long style
)
492 m_fsIsShowing
= TRUE
;
495 wxToolBar
*theToolBar
= GetToolBar();
496 wxStatusBar
*theStatusBar
= GetStatusBar();
501 theToolBar
->GetSize(&dummyWidth
, &m_fsToolBarHeight
);
503 theStatusBar
->GetSize(&dummyWidth
, &m_fsStatusBarHeight
);
505 // zap the toolbar, menubar, and statusbar
507 if ((style
& wxFULLSCREEN_NOTOOLBAR
) && theToolBar
)
509 theToolBar
->SetSize(-1,0);
510 theToolBar
->Show(FALSE
);
513 if (style
& wxFULLSCREEN_NOMENUBAR
)
514 SetMenu((HWND
)GetHWND(), (HMENU
) NULL
);
516 // Save the number of fields in the statusbar
517 if ((style
& wxFULLSCREEN_NOSTATUSBAR
) && theStatusBar
)
519 //m_fsStatusBarFields = theStatusBar->GetFieldsCount();
520 //SetStatusBar((wxStatusBar*) NULL);
521 //delete theStatusBar;
522 theStatusBar
->Show(FALSE
);
525 m_fsStatusBarFields
= 0;
527 // zap the frame borders
529 // save the 'normal' window style
530 m_fsOldWindowStyle
= GetWindowLong((HWND
)GetHWND(), GWL_STYLE
);
532 // save the old position, width & height, maximize state
533 m_fsOldSize
= GetRect();
534 m_fsIsMaximized
= IsMaximized();
536 // decide which window style flags to turn off
537 LONG newStyle
= m_fsOldWindowStyle
;
540 if (style
& wxFULLSCREEN_NOBORDER
)
541 offFlags
|= WS_BORDER
;
542 if (style
& wxFULLSCREEN_NOCAPTION
)
543 offFlags
|= (WS_CAPTION
| WS_SYSMENU
);
545 newStyle
&= (~offFlags
);
547 // change our window style to be compatible with full-screen mode
548 SetWindowLong((HWND
)GetHWND(), GWL_STYLE
, newStyle
);
550 // resize to the size of the desktop
554 ::GetWindowRect(GetDesktopWindow(), &rect
);
555 width
= rect
.right
- rect
.left
;
556 height
= rect
.bottom
- rect
.top
;
558 SetSize(width
, height
);
560 // now flush the window style cache and actually go full-screen
561 SetWindowPos((HWND
)GetHWND(), HWND_TOP
, 0, 0, width
, height
, SWP_FRAMECHANGED
);
563 wxSizeEvent
event(wxSize(width
, height
), GetId());
564 GetEventHandler()->ProcessEvent(event
);
573 m_fsIsShowing
= FALSE
;
575 wxToolBar
*theToolBar
= GetToolBar();
577 // restore the toolbar, menubar, and statusbar
578 if (theToolBar
&& (m_fsStyle
& wxFULLSCREEN_NOTOOLBAR
))
580 theToolBar
->SetSize(-1, m_fsToolBarHeight
);
581 theToolBar
->Show(TRUE
);
584 if ((m_fsStyle
& wxFULLSCREEN_NOSTATUSBAR
)) // && (m_fsStatusBarFields > 0))
586 //CreateStatusBar(m_fsStatusBarFields);
589 GetStatusBar()->Show(TRUE
);
594 if ((m_fsStyle
& wxFULLSCREEN_NOMENUBAR
) && (m_hMenu
!= 0))
595 SetMenu((HWND
)GetHWND(), (HMENU
)m_hMenu
);
597 Maximize(m_fsIsMaximized
);
598 SetWindowLong((HWND
)GetHWND(),GWL_STYLE
, m_fsOldWindowStyle
);
599 SetWindowPos((HWND
)GetHWND(),HWND_TOP
,m_fsOldSize
.x
, m_fsOldSize
.y
,
600 m_fsOldSize
.width
, m_fsOldSize
.height
, SWP_FRAMECHANGED
);
611 bool wxFrame::MSWCreate(int id
, wxWindow
*parent
, const wxChar
*wclass
, wxWindow
*wx_win
, const wxChar
*title
,
612 int x
, int y
, int width
, int height
, long style
)
615 m_defaultIcon
= (WXHICON
) (wxSTD_FRAME_ICON
? wxSTD_FRAME_ICON
: wxDEFAULT_FRAME_ICON
);
617 // If child windows aren't properly drawn initially, WS_CLIPCHILDREN
618 // could be the culprit. But without it, you can get a lot of flicker.
621 if ( style
& wxCAPTION
)
623 if ( style
& wxFRAME_TOOL_WINDOW
)
624 msflags
|= WS_POPUPWINDOW
;
626 msflags
|= WS_OVERLAPPED
;
633 if (style
& wxMINIMIZE_BOX
)
634 msflags
|= WS_MINIMIZEBOX
;
635 if (style
& wxMAXIMIZE_BOX
)
636 msflags
|= WS_MAXIMIZEBOX
;
637 if (style
& wxTHICK_FRAME
)
638 msflags
|= WS_THICKFRAME
;
639 if (style
& wxSYSTEM_MENU
)
640 msflags
|= WS_SYSMENU
;
641 if ( style
& wxMINIMIZE
)
642 msflags
|= WS_MINIMIZE
;
643 if (style
& wxMAXIMIZE
)
644 msflags
|= WS_MAXIMIZE
;
645 if (style
& wxCAPTION
)
646 msflags
|= WS_CAPTION
;
647 if (style
& wxCLIP_CHILDREN
)
648 msflags
|= WS_CLIPCHILDREN
;
650 // Keep this in wxFrame because it saves recoding this function
652 #if wxUSE_ITSY_BITSY && !defined(__WIN32__)
653 if (style
& wxTINY_CAPTION_VERT
)
654 msflags
|= IBS_VERTCAPTION
;
655 if (style
& wxTINY_CAPTION_HORIZ
)
656 msflags
|= IBS_HORZCAPTION
;
658 if (style
& wxTINY_CAPTION_VERT
)
659 msflags
|= WS_CAPTION
;
660 if (style
& wxTINY_CAPTION_HORIZ
)
661 msflags
|= WS_CAPTION
;
663 if ((style
& wxTHICK_FRAME
) == 0)
664 msflags
|= WS_BORDER
;
666 WXDWORD extendedStyle
= MakeExtendedStyle(style
);
668 // make all frames appear in the win9x shell taskbar unless
669 // wxFRAME_TOOL_WINDOW or wxFRAME_NO_TASKBAR is given - without giving them
670 // WS_EX_APPWINDOW style, the child (i.e. owned) frames wouldn't appear in it
671 #if !defined(__WIN16__) && !defined(__SC__)
672 if ( (style
& wxFRAME_TOOL_WINDOW
) ||
673 (style
& wxFRAME_NO_TASKBAR
) )
674 extendedStyle
|= WS_EX_TOOLWINDOW
;
675 else if ( !(style
& wxFRAME_NO_TASKBAR
) )
676 extendedStyle
|= WS_EX_APPWINDOW
;
679 if (style
& wxSTAY_ON_TOP
)
680 extendedStyle
|= WS_EX_TOPMOST
;
683 if (m_exStyle
& wxFRAME_EX_CONTEXTHELP
)
684 extendedStyle
|= WS_EX_CONTEXTHELP
;
688 if ( !wxWindow::MSWCreate(id
, parent
, wclass
, wx_win
, title
, x
, y
, width
, height
,
689 msflags
, NULL
, extendedStyle
) )
692 // Seems to be necessary if we use WS_POPUP
693 // style instead of WS_OVERLAPPED
694 if (width
> -1 && height
> -1)
695 ::PostMessage(GetHwnd(), WM_SIZE
, SIZE_RESTORED
, MAKELPARAM(width
, height
));
700 // Default activation behaviour - set the focus for the first child
702 void wxFrame::OnActivate(wxActivateEvent
& event
)
704 if ( event
.GetActive() )
706 // restore focus to the child which was last focused
707 wxLogTrace(_T("focus"), _T("wxFrame %08x activated."), m_hWnd
);
709 wxSetFocusToChild(this, &m_winLastFocused
);
713 // remember the last focused child
714 m_winLastFocused
= FindFocus();
715 while ( m_winLastFocused
)
717 if ( GetChildren().Find(m_winLastFocused
) )
720 m_winLastFocused
= m_winLastFocused
->GetParent();
723 wxLogTrace(_T("focus"),
724 _T("wxFrame %08x deactivated, last focused: %08x."),
726 m_winLastFocused
? GetHwndOf(m_winLastFocused
)
733 // ----------------------------------------------------------------------------
734 // tool/status bar stuff
735 // ----------------------------------------------------------------------------
739 wxToolBar
* wxFrame::CreateToolBar(long style
, wxWindowID id
, const wxString
& name
)
741 if ( wxFrameBase::CreateToolBar(style
, id
, name
) )
746 return m_frameToolBar
;
749 void wxFrame::PositionToolBar()
752 ::GetClientRect(GetHwnd(), &rect
);
755 if ( GetStatusBar() )
757 int statusX
, statusY
;
758 GetStatusBar()->GetClientSize(&statusX
, &statusY
);
759 rect
.bottom
-= statusY
;
761 #endif // wxUSE_STATUSBAR
763 if ( GetToolBar() && GetToolBar()->IsShown() )
766 GetToolBar()->GetSize(&tw
, &th
);
768 if ( GetToolBar()->GetWindowStyleFlag() & wxTB_VERTICAL
)
777 // Use the 'real' MSW position here
778 GetToolBar()->SetSize(0, 0, tw
, th
, wxSIZE_NO_ADJUSTMENTS
);
781 #endif // wxUSE_TOOLBAR
783 // ----------------------------------------------------------------------------
784 // frame state (iconized/maximized/...)
785 // ----------------------------------------------------------------------------
787 // propagate our state change to all child frames: this allows us to emulate X
788 // Windows behaviour where child frames float independently of the parent one
789 // on the desktop, but are iconized/restored with it
790 void wxFrame::IconizeChildFrames(bool bIconize
)
792 for ( wxWindowList::Node
*node
= GetChildren().GetFirst();
794 node
= node
->GetNext() )
796 wxWindow
*win
= node
->GetData();
798 // iconizing the frames with this style under Win95 shell puts them at
799 // the bottom of the screen (as the MDI children) instead of making
800 // them appear in the taskbar because they are, by virtue of this
801 // style, not managed by the taskbar - instead leave Windows take care
804 if ( win
->GetWindowStyle() & wxFRAME_TOOL_WINDOW
)
808 // the child MDI frames are a special case and should not be touched by
809 // the parent frame - instead, they are managed by the user
810 wxFrame
*frame
= wxDynamicCast(win
, wxFrame
);
811 if ( frame
&& !frame
->IsMDIChild() )
813 frame
->Iconize(bIconize
);
818 // ===========================================================================
819 // message processing
820 // ===========================================================================
822 // ---------------------------------------------------------------------------
824 // ---------------------------------------------------------------------------
826 bool wxFrame::MSWTranslateMessage(WXMSG
* pMsg
)
828 if ( wxWindow::MSWTranslateMessage(pMsg
) )
831 // try the menu bar accels
832 wxMenuBar
*menuBar
= GetMenuBar();
836 const wxAcceleratorTable
& acceleratorTable
= menuBar
->GetAccelTable();
837 return acceleratorTable
.Translate(this, pMsg
);
840 // ---------------------------------------------------------------------------
841 // our private (non virtual) message handlers
842 // ---------------------------------------------------------------------------
844 bool wxFrame::HandlePaint()
847 if ( GetUpdateRect(GetHwnd(), &rect
, FALSE
) )
851 HICON hIcon
= m_icon
.Ok() ? GetHiconOf(m_icon
)
852 : (HICON
)m_defaultIcon
;
854 // Hold a pointer to the dc so long as the OnPaint() message
855 // is being processed
857 HDC hdc
= ::BeginPaint(GetHwnd(), &ps
);
859 // Erase background before painting or we get white background
860 MSWDefWindowProc(WM_ICONERASEBKGND
, (WORD
)(LONG
)ps
.hdc
, 0L);
865 ::GetClientRect(GetHwnd(), &rect
);
867 // FIXME: why hardcoded?
868 static const int icon_width
= 32;
869 static const int icon_height
= 32;
871 int icon_x
= (int)((rect
.right
- icon_width
)/2);
872 int icon_y
= (int)((rect
.bottom
- icon_height
)/2);
874 ::DrawIcon(hdc
, icon_x
, icon_y
, hIcon
);
877 ::EndPaint(GetHwnd(), &ps
);
883 return wxWindow::HandlePaint();
888 // nothing to paint - processed
893 bool wxFrame::HandleSize(int x
, int y
, WXUINT id
)
895 bool processed
= FALSE
;
900 // only do it it if we were iconized before, otherwise resizing the
901 // parent frame has a curious side effect of bringing it under it's
906 // restore all child frames too
907 IconizeChildFrames(FALSE
);
916 // iconize all child frames too
917 IconizeChildFrames(TRUE
);
928 wxSizeEvent
event(wxSize(x
, y
), m_windowId
);
929 event
.SetEventObject( this );
930 processed
= GetEventHandler()->ProcessEvent(event
);
936 bool wxFrame::HandleCommand(WXWORD id
, WXWORD cmd
, WXHWND control
)
940 // In case it's e.g. a toolbar.
941 wxWindow
*win
= wxFindWinFromHandle(control
);
943 return win
->MSWCommand(cmd
, id
);
946 // handle here commands from menus and accelerators
947 if ( cmd
== 0 || cmd
== 1 )
949 if ( wxCurrentPopupMenu
)
951 wxMenu
*popupMenu
= wxCurrentPopupMenu
;
952 wxCurrentPopupMenu
= NULL
;
954 return popupMenu
->MSWCommand(cmd
, id
);
957 if ( ProcessCommand(id
) )
966 bool wxFrame::HandleMenuSelect(WXWORD nItem
, WXWORD flags
, WXHMENU hMenu
)
969 if ( flags
== 0xFFFF && hMenu
== 0 )
971 // menu was removed from screen
974 else if ( !(flags
& MF_POPUP
) && !(flags
& MF_SEPARATOR
) )
980 // don't give hints for separators (doesn't make sense) nor for the
981 // items opening popup menus (they don't have them anyhow) but do clear
982 // the status line - otherwise, we would be left with the help message
983 // for the previous item which doesn't apply any more
984 wxStatusBar
*statbar
= GetStatusBar();
987 statbar
->SetStatusText(wxEmptyString
);
993 wxMenuEvent
event(wxEVT_MENU_HIGHLIGHT
, item
);
994 event
.SetEventObject( this );
996 return GetEventHandler()->ProcessEvent(event
);
999 // ---------------------------------------------------------------------------
1000 // the window proc for wxFrame
1001 // ---------------------------------------------------------------------------
1003 long wxFrame::MSWWindowProc(WXUINT message
, WXWPARAM wParam
, WXLPARAM lParam
)
1006 bool processed
= FALSE
;
1011 // if we can't close, tell the system that we processed the
1012 // message - otherwise it would close us
1013 processed
= !Close();
1020 UnpackCommand((WXWPARAM
)wParam
, (WXLPARAM
)lParam
,
1023 processed
= HandleCommand(id
, cmd
, (WXHWND
)hwnd
);
1031 UnpackMenuSelect(wParam
, lParam
, &item
, &flags
, &hmenu
);
1033 processed
= HandleMenuSelect(item
, flags
, hmenu
);
1038 processed
= HandlePaint();
1041 case WM_QUERYDRAGICON
:
1043 HICON hIcon
= m_icon
.Ok() ? GetHiconOf(m_icon
)
1044 : (HICON
)(m_defaultIcon
);
1046 processed
= rc
!= 0;
1051 processed
= HandleSize(LOWORD(lParam
), HIWORD(lParam
), wParam
);
1056 rc
= wxWindow::MSWWindowProc(message
, wParam
, lParam
);