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());
360 // generate an artificial resize event
361 void wxFrame::SendSizeEvent()
365 ::GetWindowRect(GetHwnd(), &r
);
367 if ( !::GetWindowRect(GetHwnd(), &r
) )
369 wxLogLastError(_T("GetWindowRect"));
375 (void)::PostMessage(GetHwnd(), WM_SIZE
,
376 IsMaximized() ? SIZE_MAXIMIZED
: SIZE_RESTORED
,
377 MAKELPARAM(r
.right
- r
.left
, r
.bottom
- r
.top
));
382 wxStatusBar
*wxFrame::OnCreateStatusBar(int number
,
385 const wxString
& name
)
387 wxStatusBar
*statusBar
= NULL
;
389 #if wxUSE_NATIVE_STATUSBAR
390 if ( !UsesNativeStatusBar() )
392 statusBar
= (wxStatusBar
*)new wxStatusBarGeneric(this, id
, style
);
397 statusBar
= new wxStatusBar(this, id
, style
, name
);
400 // Set the height according to the font and the border size
401 wxClientDC
dc(statusBar
);
402 dc
.SetFont(statusBar
->GetFont());
405 dc
.GetTextExtent(_T("X"), NULL
, &y
);
407 int height
= (int)( (11*y
)/10 + 2*statusBar
->GetBorderY());
409 statusBar
->SetSize(-1, -1, -1, height
);
411 statusBar
->SetFieldsCount(number
);
416 void wxFrame::PositionStatusBar()
418 if ( !m_frameStatusBar
)
422 GetClientSize(&w
, &h
);
424 m_frameStatusBar
->GetSize(&sw
, &sh
);
426 // Since we wish the status bar to be directly under the client area,
427 // we use the adjusted sizes without using wxSIZE_NO_ADJUSTMENTS.
428 m_frameStatusBar
->SetSize(0, h
, w
, sh
);
430 #endif // wxUSE_STATUSBAR
432 void wxFrame::DetachMenuBar()
434 if ( m_frameMenuBar
)
436 m_frameMenuBar
->Detach();
437 m_frameMenuBar
= NULL
;
441 void wxFrame::SetMenuBar(wxMenuBar
*menubar
)
447 // actually remove the menu from the frame
448 m_hMenu
= (WXHMENU
)0;
449 InternalSetMenuBar();
451 else // set new non NULL menu bar
453 m_frameMenuBar
= NULL
;
455 // Can set a menubar several times.
456 // TODO: how to prevent a memory leak if you have a currently-unattached
457 // menubar? wxWindows assumes that the frame will delete the menu (otherwise
458 // there are problems for MDI).
459 if ( menubar
->GetHMenu() )
461 m_hMenu
= menubar
->GetHMenu();
467 m_hMenu
= menubar
->Create();
473 InternalSetMenuBar();
475 m_frameMenuBar
= menubar
;
476 menubar
->Attach(this);
480 void wxFrame::InternalSetMenuBar()
482 if ( !::SetMenu(GetHwnd(), (HMENU
)m_hMenu
) )
484 wxLogLastError(wxT("SetMenu"));
488 // Responds to colour changes, and passes event on to children.
489 void wxFrame::OnSysColourChanged(wxSysColourChangedEvent
& event
)
491 SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_APPWORKSPACE
));
494 if ( m_frameStatusBar
)
496 wxSysColourChangedEvent event2
;
497 event2
.SetEventObject( m_frameStatusBar
);
498 m_frameStatusBar
->GetEventHandler()->ProcessEvent(event2
);
501 // Propagate the event to the non-top-level children
502 wxWindow::OnSysColourChanged(event
);
505 // Pass TRUE to show full screen, FALSE to restore.
506 bool wxFrame::ShowFullScreen(bool show
, long style
)
513 m_fsIsShowing
= TRUE
;
516 wxToolBar
*theToolBar
= GetToolBar();
517 wxStatusBar
*theStatusBar
= GetStatusBar();
522 theToolBar
->GetSize(&dummyWidth
, &m_fsToolBarHeight
);
524 theStatusBar
->GetSize(&dummyWidth
, &m_fsStatusBarHeight
);
526 // zap the toolbar, menubar, and statusbar
528 if ((style
& wxFULLSCREEN_NOTOOLBAR
) && theToolBar
)
530 theToolBar
->SetSize(-1,0);
531 theToolBar
->Show(FALSE
);
534 if (style
& wxFULLSCREEN_NOMENUBAR
)
535 SetMenu((HWND
)GetHWND(), (HMENU
) NULL
);
537 // Save the number of fields in the statusbar
538 if ((style
& wxFULLSCREEN_NOSTATUSBAR
) && theStatusBar
)
540 //m_fsStatusBarFields = theStatusBar->GetFieldsCount();
541 //SetStatusBar((wxStatusBar*) NULL);
542 //delete theStatusBar;
543 theStatusBar
->Show(FALSE
);
546 m_fsStatusBarFields
= 0;
548 // zap the frame borders
550 // save the 'normal' window style
551 m_fsOldWindowStyle
= GetWindowLong((HWND
)GetHWND(), GWL_STYLE
);
553 // save the old position, width & height, maximize state
554 m_fsOldSize
= GetRect();
555 m_fsIsMaximized
= IsMaximized();
557 // decide which window style flags to turn off
558 LONG newStyle
= m_fsOldWindowStyle
;
561 if (style
& wxFULLSCREEN_NOBORDER
)
562 offFlags
|= WS_BORDER
;
563 if (style
& wxFULLSCREEN_NOCAPTION
)
564 offFlags
|= (WS_CAPTION
| WS_SYSMENU
);
566 newStyle
&= (~offFlags
);
568 // change our window style to be compatible with full-screen mode
569 SetWindowLong((HWND
)GetHWND(), GWL_STYLE
, newStyle
);
571 // resize to the size of the desktop
575 ::GetWindowRect(GetDesktopWindow(), &rect
);
576 width
= rect
.right
- rect
.left
;
577 height
= rect
.bottom
- rect
.top
;
579 SetSize(width
, height
);
581 // now flush the window style cache and actually go full-screen
582 SetWindowPos((HWND
)GetHWND(), HWND_TOP
, 0, 0, width
, height
, SWP_FRAMECHANGED
);
584 wxSizeEvent
event(wxSize(width
, height
), GetId());
585 GetEventHandler()->ProcessEvent(event
);
594 m_fsIsShowing
= FALSE
;
596 wxToolBar
*theToolBar
= GetToolBar();
598 // restore the toolbar, menubar, and statusbar
599 if (theToolBar
&& (m_fsStyle
& wxFULLSCREEN_NOTOOLBAR
))
601 theToolBar
->SetSize(-1, m_fsToolBarHeight
);
602 theToolBar
->Show(TRUE
);
605 if ((m_fsStyle
& wxFULLSCREEN_NOSTATUSBAR
)) // && (m_fsStatusBarFields > 0))
607 //CreateStatusBar(m_fsStatusBarFields);
610 GetStatusBar()->Show(TRUE
);
615 if ((m_fsStyle
& wxFULLSCREEN_NOMENUBAR
) && (m_hMenu
!= 0))
616 SetMenu((HWND
)GetHWND(), (HMENU
)m_hMenu
);
618 Maximize(m_fsIsMaximized
);
619 SetWindowLong((HWND
)GetHWND(),GWL_STYLE
, m_fsOldWindowStyle
);
620 SetWindowPos((HWND
)GetHWND(),HWND_TOP
,m_fsOldSize
.x
, m_fsOldSize
.y
,
621 m_fsOldSize
.width
, m_fsOldSize
.height
, SWP_FRAMECHANGED
);
632 bool wxFrame::MSWCreate(int id
, wxWindow
*parent
, const wxChar
*wclass
, wxWindow
*wx_win
, const wxChar
*title
,
633 int x
, int y
, int width
, int height
, long style
)
636 m_defaultIcon
= (WXHICON
) (wxSTD_FRAME_ICON
? wxSTD_FRAME_ICON
: wxDEFAULT_FRAME_ICON
);
638 // If child windows aren't properly drawn initially, WS_CLIPCHILDREN
639 // could be the culprit. But without it, you can get a lot of flicker.
642 if ( style
& wxCAPTION
)
644 if ( style
& wxFRAME_TOOL_WINDOW
)
645 msflags
|= WS_POPUPWINDOW
;
647 msflags
|= WS_OVERLAPPED
;
654 if (style
& wxMINIMIZE_BOX
)
655 msflags
|= WS_MINIMIZEBOX
;
656 if (style
& wxMAXIMIZE_BOX
)
657 msflags
|= WS_MAXIMIZEBOX
;
658 if (style
& wxTHICK_FRAME
)
659 msflags
|= WS_THICKFRAME
;
660 if (style
& wxSYSTEM_MENU
)
661 msflags
|= WS_SYSMENU
;
662 if ( style
& wxMINIMIZE
)
663 msflags
|= WS_MINIMIZE
;
664 if (style
& wxMAXIMIZE
)
665 msflags
|= WS_MAXIMIZE
;
666 if (style
& wxCAPTION
)
667 msflags
|= WS_CAPTION
;
668 if (style
& wxCLIP_CHILDREN
)
669 msflags
|= WS_CLIPCHILDREN
;
671 // Keep this in wxFrame because it saves recoding this function
673 #if wxUSE_ITSY_BITSY && !defined(__WIN32__)
674 if (style
& wxTINY_CAPTION_VERT
)
675 msflags
|= IBS_VERTCAPTION
;
676 if (style
& wxTINY_CAPTION_HORIZ
)
677 msflags
|= IBS_HORZCAPTION
;
679 if (style
& wxTINY_CAPTION_VERT
)
680 msflags
|= WS_CAPTION
;
681 if (style
& wxTINY_CAPTION_HORIZ
)
682 msflags
|= WS_CAPTION
;
684 if ((style
& wxTHICK_FRAME
) == 0)
685 msflags
|= WS_BORDER
;
687 WXDWORD extendedStyle
= MakeExtendedStyle(style
);
689 // make all frames appear in the win9x shell taskbar unless
690 // wxFRAME_TOOL_WINDOW or wxFRAME_NO_TASKBAR is given - without giving them
691 // WS_EX_APPWINDOW style, the child (i.e. owned) frames wouldn't appear in it
692 #if !defined(__WIN16__) && !defined(__SC__)
693 if ( (style
& wxFRAME_TOOL_WINDOW
) ||
694 (style
& wxFRAME_NO_TASKBAR
) )
695 extendedStyle
|= WS_EX_TOOLWINDOW
;
696 else if ( !(style
& wxFRAME_NO_TASKBAR
) )
697 extendedStyle
|= WS_EX_APPWINDOW
;
700 if (style
& wxSTAY_ON_TOP
)
701 extendedStyle
|= WS_EX_TOPMOST
;
704 if (m_exStyle
& wxFRAME_EX_CONTEXTHELP
)
705 extendedStyle
|= WS_EX_CONTEXTHELP
;
709 if ( !wxWindow::MSWCreate(id
, parent
, wclass
, wx_win
, title
, x
, y
, width
, height
,
710 msflags
, NULL
, extendedStyle
) )
713 // Seems to be necessary if we use WS_POPUP
714 // style instead of WS_OVERLAPPED
715 if (width
> -1 && height
> -1)
716 ::PostMessage(GetHwnd(), WM_SIZE
, SIZE_RESTORED
, MAKELPARAM(width
, height
));
721 // Default activation behaviour - set the focus for the first child
723 void wxFrame::OnActivate(wxActivateEvent
& event
)
725 if ( event
.GetActive() )
727 // restore focus to the child which was last focused
728 wxLogTrace(_T("focus"), _T("wxFrame %08x activated."), m_hWnd
);
730 wxWindow
*parent
= m_winLastFocused
? m_winLastFocused
->GetParent()
737 wxSetFocusToChild(parent
, &m_winLastFocused
);
741 // remember the last focused child if it is our child
742 m_winLastFocused
= FindFocus();
744 // so we NULL it out if it's a child from some other frame
745 wxWindow
*win
= m_winLastFocused
;
748 if ( win
->IsTopLevel() )
752 m_winLastFocused
= NULL
;
758 win
= win
->GetParent();
761 wxLogTrace(_T("focus"),
762 _T("wxFrame %08x deactivated, last focused: %08x."),
764 m_winLastFocused
? GetHwndOf(m_winLastFocused
)
771 // ----------------------------------------------------------------------------
772 // tool/status bar stuff
773 // ----------------------------------------------------------------------------
777 wxToolBar
* wxFrame::CreateToolBar(long style
, wxWindowID id
, const wxString
& name
)
779 if ( wxFrameBase::CreateToolBar(style
, id
, name
) )
784 return m_frameToolBar
;
787 void wxFrame::PositionToolBar()
790 ::GetClientRect(GetHwnd(), &rect
);
793 if ( GetStatusBar() )
795 int statusX
, statusY
;
796 GetStatusBar()->GetClientSize(&statusX
, &statusY
);
797 rect
.bottom
-= statusY
;
799 #endif // wxUSE_STATUSBAR
801 if ( GetToolBar() && GetToolBar()->IsShown() )
804 GetToolBar()->GetSize(&tw
, &th
);
806 if ( GetToolBar()->GetWindowStyleFlag() & wxTB_VERTICAL
)
815 // Use the 'real' MSW position here
816 GetToolBar()->SetSize(0, 0, tw
, th
, wxSIZE_NO_ADJUSTMENTS
);
819 #endif // wxUSE_TOOLBAR
821 // ----------------------------------------------------------------------------
822 // frame state (iconized/maximized/...)
823 // ----------------------------------------------------------------------------
825 // propagate our state change to all child frames: this allows us to emulate X
826 // Windows behaviour where child frames float independently of the parent one
827 // on the desktop, but are iconized/restored with it
828 void wxFrame::IconizeChildFrames(bool bIconize
)
830 for ( wxWindowList::Node
*node
= GetChildren().GetFirst();
832 node
= node
->GetNext() )
834 wxWindow
*win
= node
->GetData();
836 // iconizing the frames with this style under Win95 shell puts them at
837 // the bottom of the screen (as the MDI children) instead of making
838 // them appear in the taskbar because they are, by virtue of this
839 // style, not managed by the taskbar - instead leave Windows take care
842 if ( win
->GetWindowStyle() & wxFRAME_TOOL_WINDOW
)
846 // the child MDI frames are a special case and should not be touched by
847 // the parent frame - instead, they are managed by the user
848 wxFrame
*frame
= wxDynamicCast(win
, wxFrame
);
849 if ( frame
&& !frame
->IsMDIChild() )
851 frame
->Iconize(bIconize
);
856 // ===========================================================================
857 // message processing
858 // ===========================================================================
860 // ---------------------------------------------------------------------------
862 // ---------------------------------------------------------------------------
864 bool wxFrame::MSWTranslateMessage(WXMSG
* pMsg
)
866 if ( wxWindow::MSWTranslateMessage(pMsg
) )
869 // try the menu bar accels
870 wxMenuBar
*menuBar
= GetMenuBar();
874 const wxAcceleratorTable
& acceleratorTable
= menuBar
->GetAccelTable();
875 return acceleratorTable
.Translate(this, pMsg
);
878 // ---------------------------------------------------------------------------
879 // our private (non virtual) message handlers
880 // ---------------------------------------------------------------------------
882 bool wxFrame::HandlePaint()
885 if ( GetUpdateRect(GetHwnd(), &rect
, FALSE
) )
889 HICON hIcon
= m_icon
.Ok() ? GetHiconOf(m_icon
)
890 : (HICON
)m_defaultIcon
;
892 // Hold a pointer to the dc so long as the OnPaint() message
893 // is being processed
895 HDC hdc
= ::BeginPaint(GetHwnd(), &ps
);
897 // Erase background before painting or we get white background
898 MSWDefWindowProc(WM_ICONERASEBKGND
, (WORD
)(LONG
)ps
.hdc
, 0L);
903 ::GetClientRect(GetHwnd(), &rect
);
905 // FIXME: why hardcoded?
906 static const int icon_width
= 32;
907 static const int icon_height
= 32;
909 int icon_x
= (int)((rect
.right
- icon_width
)/2);
910 int icon_y
= (int)((rect
.bottom
- icon_height
)/2);
912 ::DrawIcon(hdc
, icon_x
, icon_y
, hIcon
);
915 ::EndPaint(GetHwnd(), &ps
);
921 return wxWindow::HandlePaint();
926 // nothing to paint - processed
931 bool wxFrame::HandleSize(int x
, int y
, WXUINT id
)
933 bool processed
= FALSE
;
938 // only do it it if we were iconized before, otherwise resizing the
939 // parent frame has a curious side effect of bringing it under it's
944 // restore all child frames too
945 IconizeChildFrames(FALSE
);
954 // iconize all child frames too
955 IconizeChildFrames(TRUE
);
966 wxSizeEvent
event(wxSize(x
, y
), m_windowId
);
967 event
.SetEventObject( this );
968 processed
= GetEventHandler()->ProcessEvent(event
);
974 bool wxFrame::HandleCommand(WXWORD id
, WXWORD cmd
, WXHWND control
)
978 // In case it's e.g. a toolbar.
979 wxWindow
*win
= wxFindWinFromHandle(control
);
981 return win
->MSWCommand(cmd
, id
);
984 // handle here commands from menus and accelerators
985 if ( cmd
== 0 || cmd
== 1 )
987 if ( wxCurrentPopupMenu
)
989 wxMenu
*popupMenu
= wxCurrentPopupMenu
;
990 wxCurrentPopupMenu
= NULL
;
992 return popupMenu
->MSWCommand(cmd
, id
);
995 if ( ProcessCommand(id
) )
1004 bool wxFrame::HandleMenuSelect(WXWORD nItem
, WXWORD flags
, WXHMENU hMenu
)
1007 if ( flags
== 0xFFFF && hMenu
== 0 )
1009 // menu was removed from screen
1012 else if ( !(flags
& MF_POPUP
) && !(flags
& MF_SEPARATOR
) )
1018 // don't give hints for separators (doesn't make sense) nor for the
1019 // items opening popup menus (they don't have them anyhow) but do clear
1020 // the status line - otherwise, we would be left with the help message
1021 // for the previous item which doesn't apply any more
1022 wxStatusBar
*statbar
= GetStatusBar();
1025 statbar
->SetStatusText(wxEmptyString
);
1031 wxMenuEvent
event(wxEVT_MENU_HIGHLIGHT
, item
);
1032 event
.SetEventObject( this );
1034 return GetEventHandler()->ProcessEvent(event
);
1037 // ---------------------------------------------------------------------------
1038 // the window proc for wxFrame
1039 // ---------------------------------------------------------------------------
1041 long wxFrame::MSWWindowProc(WXUINT message
, WXWPARAM wParam
, WXLPARAM lParam
)
1044 bool processed
= FALSE
;
1049 // if we can't close, tell the system that we processed the
1050 // message - otherwise it would close us
1051 processed
= !Close();
1058 UnpackCommand((WXWPARAM
)wParam
, (WXLPARAM
)lParam
,
1061 processed
= HandleCommand(id
, cmd
, (WXHWND
)hwnd
);
1069 UnpackMenuSelect(wParam
, lParam
, &item
, &flags
, &hmenu
);
1071 processed
= HandleMenuSelect(item
, flags
, hmenu
);
1076 processed
= HandlePaint();
1079 case WM_QUERYDRAGICON
:
1081 HICON hIcon
= m_icon
.Ok() ? GetHiconOf(m_icon
)
1082 : (HICON
)(m_defaultIcon
);
1084 processed
= rc
!= 0;
1089 processed
= HandleSize(LOWORD(lParam
), HIWORD(lParam
), wParam
);
1094 rc
= wxWindow::MSWWindowProc(message
, wParam
, lParam
);