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 // ----------------------------------------------------------------------------
99 m_maximizeOnShow
= FALSE
;
105 // Data to save/restore when calling ShowFullScreen
107 m_fsOldWindowStyle
= 0;
108 m_fsStatusBarFields
= 0;
109 m_fsStatusBarHeight
= 0;
110 m_fsToolBarHeight
= 0;
112 m_fsIsMaximized
= FALSE
;
113 m_fsIsShowing
= FALSE
;
115 m_winLastFocused
= (wxWindow
*)NULL
;
117 // unlike (almost?) all other windows, frames are created hidden
121 bool wxFrame::Create(wxWindow
*parent
,
123 const wxString
& title
,
127 const wxString
& name
)
130 m_windowStyle
= style
;
131 m_frameMenuBar
= NULL
;
132 m_frameToolBar
= NULL
;
133 m_frameStatusBar
= NULL
;
135 SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_APPWORKSPACE
));
140 m_windowId
= (int)NewControlId();
142 if (parent
) parent
->AddChild(this);
151 wxTopLevelWindows
.Append(this);
153 MSWCreate(m_windowId
, parent
, wxFrameClassName
, this, title
,
154 x
, y
, width
, height
, style
);
156 wxModelessWindows
.Append(this);
163 m_isBeingDeleted
= TRUE
;
164 wxTopLevelWindows
.DeleteObject(this);
166 // the ~wxToolBar() code relies on the previous line to be executed before
167 // this one, i.e. the frame should remove itself from wxTopLevelWindows
168 // before destorying its toolbar
171 if (wxTheApp
&& (wxTopLevelWindows
.Number() == 0))
173 wxTheApp
->SetTopWindow(NULL
);
175 if (wxTheApp
->GetExitOnFrameDelete())
181 wxModelessWindows
.DeleteObject(this);
183 // For some reason, wxWindows can activate another task altogether
184 // when a frame is destroyed after a modal dialog has been invoked.
185 // Try to bring the parent to the top.
186 // MT:Only do this if this frame is currently the active window, else weird
187 // things start to happen
188 if ( wxGetActiveWindow() == this )
189 if (GetParent() && GetParent()->GetHWND())
190 ::BringWindowToTop((HWND
) GetParent()->GetHWND());
193 // Get size *available for subwindows* i.e. excluding menu bar, toolbar etc.
194 void wxFrame::DoGetClientSize(int *x
, int *y
) const
197 ::GetClientRect(GetHwnd(), &rect
);
200 if ( GetStatusBar() && GetStatusBar()->IsShown() )
202 int statusX
, statusY
;
203 GetStatusBar()->GetClientSize(&statusX
, &statusY
);
204 rect
.bottom
-= statusY
;
206 #endif // wxUSE_STATUSBAR
208 wxPoint
pt(GetClientAreaOrigin());
218 // Set the client size (i.e. leave the calculation of borders etc.
220 void wxFrame::DoSetClientSize(int width
, int height
)
222 HWND hWnd
= GetHwnd();
225 ::GetClientRect(hWnd
, &rectClient
);
228 ::GetWindowRect(hWnd
, &rectTotal
);
230 // Find the difference between the entire window (title bar and all)
231 // and the client area; add this to the new client size to move the
233 width
+= rectTotal
.right
- rectTotal
.left
- rectClient
.right
;
234 height
+= rectTotal
.bottom
- rectTotal
.top
- rectClient
.bottom
;
237 wxStatusBar
*statbar
= GetStatusBar();
238 if ( statbar
&& statbar
->IsShown() )
240 // leave enough space for the status bar
241 height
+= statbar
->GetSize().y
;
243 #endif // wxUSE_STATUSBAR
245 // note that this takes the toolbar into account
246 wxPoint pt
= GetClientAreaOrigin();
250 if ( !::MoveWindow(hWnd
, rectTotal
.left
, rectTotal
.top
,
251 width
, height
, TRUE
/* redraw */) )
253 wxLogLastError(_T("MoveWindow"));
256 wxSizeEvent
event(wxSize(width
, height
), m_windowId
);
257 event
.SetEventObject(this);
258 GetEventHandler()->ProcessEvent(event
);
261 void wxFrame::DoGetSize(int *width
, int *height
) const
264 ::GetWindowRect(GetHwnd(), &rect
);
266 *width
= rect
.right
- rect
.left
;
267 *height
= rect
.bottom
- rect
.top
;
270 void wxFrame::DoGetPosition(int *x
, int *y
) const
273 ::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
) )
299 if ( m_maximizeOnShow
)
302 nShowCmd
= SW_MAXIMIZE
;
304 m_maximizeOnShow
= FALSE
;
316 DoShowWindow(nShowCmd
);
320 ::BringWindowToTop(GetHwnd());
322 wxActivateEvent
event(wxEVT_ACTIVATE
, TRUE
, m_windowId
);
323 event
.SetEventObject( this );
324 GetEventHandler()->ProcessEvent(event
);
328 // Try to highlight the correct window (the parent)
331 HWND hWndParent
= GetHwndOf(GetParent());
333 ::BringWindowToTop(hWndParent
);
340 void wxFrame::Iconize(bool iconize
)
342 DoShowWindow(iconize
? SW_MINIMIZE
: SW_RESTORE
);
345 void wxFrame::Maximize(bool maximize
)
349 // just maximize it directly
350 DoShowWindow(maximize
? SW_MAXIMIZE
: SW_RESTORE
);
354 // we can't maximize the hidden frame because it shows it as well, so
355 // just remember that we should do it later in this case
356 m_maximizeOnShow
= TRUE
;
360 void wxFrame::Restore()
362 DoShowWindow(SW_RESTORE
);
365 bool wxFrame::IsIconized() const
367 ((wxFrame
*)this)->m_iconized
= (::IsIconic(GetHwnd()) != 0);
372 bool wxFrame::IsMaximized() const
374 return (::IsZoomed(GetHwnd()) != 0);
377 void wxFrame::SetIcon(const wxIcon
& icon
)
379 wxFrameBase::SetIcon(icon
);
381 #if defined(__WIN95__)
384 SendMessage(GetHwnd(), WM_SETICON
,
385 (WPARAM
)TRUE
, (LPARAM
)(HICON
) m_icon
.GetHICON());
390 // generate an artificial resize event
391 void wxFrame::SendSizeEvent()
395 ::GetWindowRect(GetHwnd(), &r
);
397 if ( !::GetWindowRect(GetHwnd(), &r
) )
399 wxLogLastError(_T("GetWindowRect"));
405 (void)::PostMessage(GetHwnd(), WM_SIZE
,
406 IsMaximized() ? SIZE_MAXIMIZED
: SIZE_RESTORED
,
407 MAKELPARAM(r
.right
- r
.left
, r
.bottom
- r
.top
));
412 wxStatusBar
*wxFrame::OnCreateStatusBar(int number
,
415 const wxString
& name
)
417 wxStatusBar
*statusBar
= NULL
;
419 #if wxUSE_NATIVE_STATUSBAR
420 if ( !UsesNativeStatusBar() )
422 statusBar
= (wxStatusBar
*)new wxStatusBarGeneric(this, id
, style
);
427 statusBar
= new wxStatusBar(this, id
, style
, name
);
430 // Set the height according to the font and the border size
431 wxClientDC
dc(statusBar
);
432 dc
.SetFont(statusBar
->GetFont());
435 dc
.GetTextExtent(_T("X"), NULL
, &y
);
437 int height
= (int)( (11*y
)/10 + 2*statusBar
->GetBorderY());
439 statusBar
->SetSize(-1, -1, -1, height
);
441 statusBar
->SetFieldsCount(number
);
446 void wxFrame::PositionStatusBar()
448 if ( !m_frameStatusBar
)
452 GetClientSize(&w
, &h
);
454 m_frameStatusBar
->GetSize(&sw
, &sh
);
456 // Since we wish the status bar to be directly under the client area,
457 // we use the adjusted sizes without using wxSIZE_NO_ADJUSTMENTS.
458 m_frameStatusBar
->SetSize(0, h
, w
, sh
);
460 #endif // wxUSE_STATUSBAR
462 void wxFrame::DetachMenuBar()
464 if ( m_frameMenuBar
)
466 m_frameMenuBar
->Detach();
467 m_frameMenuBar
= NULL
;
471 void wxFrame::SetMenuBar(wxMenuBar
*menubar
)
477 // actually remove the menu from the frame
478 m_hMenu
= (WXHMENU
)0;
479 InternalSetMenuBar();
481 else // set new non NULL menu bar
483 m_frameMenuBar
= NULL
;
485 // Can set a menubar several times.
486 // TODO: how to prevent a memory leak if you have a currently-unattached
487 // menubar? wxWindows assumes that the frame will delete the menu (otherwise
488 // there are problems for MDI).
489 if ( menubar
->GetHMenu() )
491 m_hMenu
= menubar
->GetHMenu();
497 m_hMenu
= menubar
->Create();
503 InternalSetMenuBar();
505 m_frameMenuBar
= menubar
;
506 menubar
->Attach(this);
510 void wxFrame::InternalSetMenuBar()
512 if ( !::SetMenu(GetHwnd(), (HMENU
)m_hMenu
) )
514 wxLogLastError(wxT("SetMenu"));
518 // Responds to colour changes, and passes event on to children.
519 void wxFrame::OnSysColourChanged(wxSysColourChangedEvent
& event
)
521 SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_APPWORKSPACE
));
524 if ( m_frameStatusBar
)
526 wxSysColourChangedEvent event2
;
527 event2
.SetEventObject( m_frameStatusBar
);
528 m_frameStatusBar
->GetEventHandler()->ProcessEvent(event2
);
531 // Propagate the event to the non-top-level children
532 wxWindow::OnSysColourChanged(event
);
535 // Pass TRUE to show full screen, FALSE to restore.
536 bool wxFrame::ShowFullScreen(bool show
, long style
)
543 m_fsIsShowing
= TRUE
;
546 wxToolBar
*theToolBar
= GetToolBar();
547 wxStatusBar
*theStatusBar
= GetStatusBar();
552 theToolBar
->GetSize(&dummyWidth
, &m_fsToolBarHeight
);
554 theStatusBar
->GetSize(&dummyWidth
, &m_fsStatusBarHeight
);
556 // zap the toolbar, menubar, and statusbar
558 if ((style
& wxFULLSCREEN_NOTOOLBAR
) && theToolBar
)
560 theToolBar
->SetSize(-1,0);
561 theToolBar
->Show(FALSE
);
564 if (style
& wxFULLSCREEN_NOMENUBAR
)
565 SetMenu((HWND
)GetHWND(), (HMENU
) NULL
);
567 // Save the number of fields in the statusbar
568 if ((style
& wxFULLSCREEN_NOSTATUSBAR
) && theStatusBar
)
570 //m_fsStatusBarFields = theStatusBar->GetFieldsCount();
571 //SetStatusBar((wxStatusBar*) NULL);
572 //delete theStatusBar;
573 theStatusBar
->Show(FALSE
);
576 m_fsStatusBarFields
= 0;
578 // zap the frame borders
580 // save the 'normal' window style
581 m_fsOldWindowStyle
= GetWindowLong((HWND
)GetHWND(), GWL_STYLE
);
583 // save the old position, width & height, maximize state
584 m_fsOldSize
= GetRect();
585 m_fsIsMaximized
= IsMaximized();
587 // decide which window style flags to turn off
588 LONG newStyle
= m_fsOldWindowStyle
;
591 if (style
& wxFULLSCREEN_NOBORDER
)
592 offFlags
|= WS_BORDER
;
593 if (style
& wxFULLSCREEN_NOCAPTION
)
594 offFlags
|= (WS_CAPTION
| WS_SYSMENU
);
596 newStyle
&= (~offFlags
);
598 // change our window style to be compatible with full-screen mode
599 SetWindowLong((HWND
)GetHWND(), GWL_STYLE
, newStyle
);
601 // resize to the size of the desktop
605 ::GetWindowRect(GetDesktopWindow(), &rect
);
606 width
= rect
.right
- rect
.left
;
607 height
= rect
.bottom
- rect
.top
;
609 SetSize(width
, height
);
611 // now flush the window style cache and actually go full-screen
612 SetWindowPos((HWND
)GetHWND(), HWND_TOP
, 0, 0, width
, height
, SWP_FRAMECHANGED
);
614 wxSizeEvent
event(wxSize(width
, height
), GetId());
615 GetEventHandler()->ProcessEvent(event
);
624 m_fsIsShowing
= FALSE
;
626 wxToolBar
*theToolBar
= GetToolBar();
628 // restore the toolbar, menubar, and statusbar
629 if (theToolBar
&& (m_fsStyle
& wxFULLSCREEN_NOTOOLBAR
))
631 theToolBar
->SetSize(-1, m_fsToolBarHeight
);
632 theToolBar
->Show(TRUE
);
635 if ((m_fsStyle
& wxFULLSCREEN_NOSTATUSBAR
)) // && (m_fsStatusBarFields > 0))
637 //CreateStatusBar(m_fsStatusBarFields);
640 GetStatusBar()->Show(TRUE
);
645 if ((m_fsStyle
& wxFULLSCREEN_NOMENUBAR
) && (m_hMenu
!= 0))
646 SetMenu((HWND
)GetHWND(), (HMENU
)m_hMenu
);
648 Maximize(m_fsIsMaximized
);
649 SetWindowLong((HWND
)GetHWND(),GWL_STYLE
, m_fsOldWindowStyle
);
650 SetWindowPos((HWND
)GetHWND(),HWND_TOP
,m_fsOldSize
.x
, m_fsOldSize
.y
,
651 m_fsOldSize
.width
, m_fsOldSize
.height
, SWP_FRAMECHANGED
);
662 bool wxFrame::MSWCreate(int id
, wxWindow
*parent
, const wxChar
*wclass
, wxWindow
*wx_win
, const wxChar
*title
,
663 int x
, int y
, int width
, int height
, long style
)
666 m_defaultIcon
= (WXHICON
) (wxSTD_FRAME_ICON
? wxSTD_FRAME_ICON
: wxDEFAULT_FRAME_ICON
);
668 // If child windows aren't properly drawn initially, WS_CLIPCHILDREN
669 // could be the culprit. But without it, you can get a lot of flicker.
672 if ( style
& wxCAPTION
)
674 if ( style
& wxFRAME_TOOL_WINDOW
)
675 msflags
|= WS_POPUPWINDOW
;
677 msflags
|= WS_OVERLAPPED
;
684 if (style
& wxMINIMIZE_BOX
)
685 msflags
|= WS_MINIMIZEBOX
;
686 if (style
& wxMAXIMIZE_BOX
)
687 msflags
|= WS_MAXIMIZEBOX
;
688 if (style
& wxTHICK_FRAME
)
689 msflags
|= WS_THICKFRAME
;
690 if (style
& wxSYSTEM_MENU
)
691 msflags
|= WS_SYSMENU
;
692 if ( style
& wxMINIMIZE
)
693 msflags
|= WS_MINIMIZE
;
694 if (style
& wxMAXIMIZE
)
695 msflags
|= WS_MAXIMIZE
;
696 if (style
& wxCAPTION
)
697 msflags
|= WS_CAPTION
;
698 if (style
& wxCLIP_CHILDREN
)
699 msflags
|= WS_CLIPCHILDREN
;
701 // Keep this in wxFrame because it saves recoding this function
703 #if wxUSE_ITSY_BITSY && !defined(__WIN32__)
704 if (style
& wxTINY_CAPTION_VERT
)
705 msflags
|= IBS_VERTCAPTION
;
706 if (style
& wxTINY_CAPTION_HORIZ
)
707 msflags
|= IBS_HORZCAPTION
;
709 if (style
& wxTINY_CAPTION_VERT
)
710 msflags
|= WS_CAPTION
;
711 if (style
& wxTINY_CAPTION_HORIZ
)
712 msflags
|= WS_CAPTION
;
714 if ((style
& wxTHICK_FRAME
) == 0)
715 msflags
|= WS_BORDER
;
717 WXDWORD extendedStyle
= MakeExtendedStyle(style
);
719 // make all frames appear in the win9x shell taskbar unless
720 // wxFRAME_TOOL_WINDOW or wxFRAME_NO_TASKBAR is given - without giving them
721 // WS_EX_APPWINDOW style, the child (i.e. owned) frames wouldn't appear in it
722 #if !defined(__WIN16__) && !defined(__SC__)
723 if ( (style
& wxFRAME_TOOL_WINDOW
) ||
724 (style
& wxFRAME_NO_TASKBAR
) )
725 extendedStyle
|= WS_EX_TOOLWINDOW
;
726 else if ( !(style
& wxFRAME_NO_TASKBAR
) )
727 extendedStyle
|= WS_EX_APPWINDOW
;
730 if (style
& wxSTAY_ON_TOP
)
731 extendedStyle
|= WS_EX_TOPMOST
;
734 if (m_exStyle
& wxFRAME_EX_CONTEXTHELP
)
735 extendedStyle
|= WS_EX_CONTEXTHELP
;
739 if ( !wxWindow::MSWCreate(id
, parent
, wclass
, wx_win
, title
, x
, y
, width
, height
,
740 msflags
, NULL
, extendedStyle
) )
743 // Seems to be necessary if we use WS_POPUP
744 // style instead of WS_OVERLAPPED
745 if (width
> -1 && height
> -1)
746 ::PostMessage(GetHwnd(), WM_SIZE
, SIZE_RESTORED
, MAKELPARAM(width
, height
));
751 // Default activation behaviour - set the focus for the first child
753 void wxFrame::OnActivate(wxActivateEvent
& event
)
755 if ( event
.GetActive() )
757 // restore focus to the child which was last focused
758 wxLogTrace(_T("focus"), _T("wxFrame %08x activated."), m_hWnd
);
760 wxWindow
*parent
= m_winLastFocused
? m_winLastFocused
->GetParent()
767 wxSetFocusToChild(parent
, &m_winLastFocused
);
771 // remember the last focused child if it is our child
772 m_winLastFocused
= FindFocus();
774 // so we NULL it out if it's a child from some other frame
775 wxWindow
*win
= m_winLastFocused
;
778 if ( win
->IsTopLevel() )
782 m_winLastFocused
= NULL
;
788 win
= win
->GetParent();
791 wxLogTrace(_T("focus"),
792 _T("wxFrame %08x deactivated, last focused: %08x."),
794 m_winLastFocused
? GetHwndOf(m_winLastFocused
)
801 // ----------------------------------------------------------------------------
802 // tool/status bar stuff
803 // ----------------------------------------------------------------------------
807 wxToolBar
* wxFrame::CreateToolBar(long style
, wxWindowID id
, const wxString
& name
)
809 if ( wxFrameBase::CreateToolBar(style
, id
, name
) )
814 return m_frameToolBar
;
817 void wxFrame::PositionToolBar()
820 ::GetClientRect(GetHwnd(), &rect
);
823 if ( GetStatusBar() )
825 int statusX
, statusY
;
826 GetStatusBar()->GetClientSize(&statusX
, &statusY
);
827 rect
.bottom
-= statusY
;
829 #endif // wxUSE_STATUSBAR
831 if ( GetToolBar() && GetToolBar()->IsShown() )
834 GetToolBar()->GetSize(&tw
, &th
);
836 if ( GetToolBar()->GetWindowStyleFlag() & wxTB_VERTICAL
)
845 // Use the 'real' MSW position here
846 GetToolBar()->SetSize(0, 0, tw
, th
, wxSIZE_NO_ADJUSTMENTS
);
849 #endif // wxUSE_TOOLBAR
851 // ----------------------------------------------------------------------------
852 // frame state (iconized/maximized/...)
853 // ----------------------------------------------------------------------------
855 // propagate our state change to all child frames: this allows us to emulate X
856 // Windows behaviour where child frames float independently of the parent one
857 // on the desktop, but are iconized/restored with it
858 void wxFrame::IconizeChildFrames(bool bIconize
)
860 for ( wxWindowList::Node
*node
= GetChildren().GetFirst();
862 node
= node
->GetNext() )
864 wxWindow
*win
= node
->GetData();
866 // iconizing the frames with this style under Win95 shell puts them at
867 // the bottom of the screen (as the MDI children) instead of making
868 // them appear in the taskbar because they are, by virtue of this
869 // style, not managed by the taskbar - instead leave Windows take care
872 if ( win
->GetWindowStyle() & wxFRAME_TOOL_WINDOW
)
876 // the child MDI frames are a special case and should not be touched by
877 // the parent frame - instead, they are managed by the user
878 wxFrame
*frame
= wxDynamicCast(win
, wxFrame
);
879 if ( frame
&& !frame
->IsMDIChild() )
881 frame
->Iconize(bIconize
);
886 // ===========================================================================
887 // message processing
888 // ===========================================================================
890 // ---------------------------------------------------------------------------
892 // ---------------------------------------------------------------------------
894 bool wxFrame::MSWTranslateMessage(WXMSG
* pMsg
)
896 if ( wxWindow::MSWTranslateMessage(pMsg
) )
899 // try the menu bar accels
900 wxMenuBar
*menuBar
= GetMenuBar();
904 const wxAcceleratorTable
& acceleratorTable
= menuBar
->GetAccelTable();
905 return acceleratorTable
.Translate(this, pMsg
);
908 // ---------------------------------------------------------------------------
909 // our private (non virtual) message handlers
910 // ---------------------------------------------------------------------------
912 bool wxFrame::HandlePaint()
915 if ( GetUpdateRect(GetHwnd(), &rect
, FALSE
) )
919 HICON hIcon
= m_icon
.Ok() ? GetHiconOf(m_icon
)
920 : (HICON
)m_defaultIcon
;
922 // Hold a pointer to the dc so long as the OnPaint() message
923 // is being processed
925 HDC hdc
= ::BeginPaint(GetHwnd(), &ps
);
927 // Erase background before painting or we get white background
928 MSWDefWindowProc(WM_ICONERASEBKGND
, (WORD
)(LONG
)ps
.hdc
, 0L);
933 ::GetClientRect(GetHwnd(), &rect
);
935 // FIXME: why hardcoded?
936 static const int icon_width
= 32;
937 static const int icon_height
= 32;
939 int icon_x
= (int)((rect
.right
- icon_width
)/2);
940 int icon_y
= (int)((rect
.bottom
- icon_height
)/2);
942 ::DrawIcon(hdc
, icon_x
, icon_y
, hIcon
);
945 ::EndPaint(GetHwnd(), &ps
);
951 return wxWindow::HandlePaint();
956 // nothing to paint - processed
961 bool wxFrame::HandleSize(int x
, int y
, WXUINT id
)
963 bool processed
= FALSE
;
968 // only do it it if we were iconized before, otherwise resizing the
969 // parent frame has a curious side effect of bringing it under it's
974 // restore all child frames too
975 IconizeChildFrames(FALSE
);
977 (void)SendIconizeEvent(FALSE
);
986 // iconize all child frames too
987 IconizeChildFrames(TRUE
);
989 (void)SendIconizeEvent();
1000 wxSizeEvent
event(wxSize(x
, y
), m_windowId
);
1001 event
.SetEventObject( this );
1002 processed
= GetEventHandler()->ProcessEvent(event
);
1008 bool wxFrame::HandleCommand(WXWORD id
, WXWORD cmd
, WXHWND control
)
1012 // In case it's e.g. a toolbar.
1013 wxWindow
*win
= wxFindWinFromHandle(control
);
1015 return win
->MSWCommand(cmd
, id
);
1018 // handle here commands from menus and accelerators
1019 if ( cmd
== 0 || cmd
== 1 )
1021 if ( wxCurrentPopupMenu
)
1023 wxMenu
*popupMenu
= wxCurrentPopupMenu
;
1024 wxCurrentPopupMenu
= NULL
;
1026 return popupMenu
->MSWCommand(cmd
, id
);
1029 if ( ProcessCommand(id
) )
1038 bool wxFrame::HandleMenuSelect(WXWORD nItem
, WXWORD flags
, WXHMENU hMenu
)
1041 if ( flags
== 0xFFFF && hMenu
== 0 )
1043 // menu was removed from screen
1046 else if ( !(flags
& MF_POPUP
) && !(flags
& MF_SEPARATOR
) )
1052 // don't give hints for separators (doesn't make sense) nor for the
1053 // items opening popup menus (they don't have them anyhow) but do clear
1054 // the status line - otherwise, we would be left with the help message
1055 // for the previous item which doesn't apply any more
1056 wxStatusBar
*statbar
= GetStatusBar();
1059 statbar
->SetStatusText(wxEmptyString
);
1065 wxMenuEvent
event(wxEVT_MENU_HIGHLIGHT
, item
);
1066 event
.SetEventObject( this );
1068 return GetEventHandler()->ProcessEvent(event
);
1071 // ---------------------------------------------------------------------------
1072 // the window proc for wxFrame
1073 // ---------------------------------------------------------------------------
1075 long wxFrame::MSWWindowProc(WXUINT message
, WXWPARAM wParam
, WXLPARAM lParam
)
1078 bool processed
= FALSE
;
1083 // if we can't close, tell the system that we processed the
1084 // message - otherwise it would close us
1085 processed
= !Close();
1092 UnpackCommand((WXWPARAM
)wParam
, (WXLPARAM
)lParam
,
1095 processed
= HandleCommand(id
, cmd
, (WXHWND
)hwnd
);
1103 UnpackMenuSelect(wParam
, lParam
, &item
, &flags
, &hmenu
);
1105 processed
= HandleMenuSelect(item
, flags
, hmenu
);
1110 processed
= HandlePaint();
1113 case WM_QUERYDRAGICON
:
1115 HICON hIcon
= m_icon
.Ok() ? GetHiconOf(m_icon
)
1116 : (HICON
)(m_defaultIcon
);
1118 processed
= rc
!= 0;
1123 processed
= HandleSize(LOWORD(lParam
), HIWORD(lParam
), wParam
);
1128 rc
= wxWindow::MSWWindowProc(message
, wParam
, lParam
);