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"
36 #include "wx/dialog.h"
37 #include "wx/settings.h"
38 #include "wx/dcclient.h"
43 #include "wx/msw/private.h"
46 #include "wx/statusbr.h"
47 #include "wx/generic/statusbr.h"
48 #endif // wxUSE_STATUSBAR
51 #include "wx/toolbar.h"
52 #endif // wxUSE_TOOLBAR
54 #include "wx/menuitem.h"
57 #ifdef __WXUNIVERSAL__
58 #include "wx/univ/theme.h"
59 #include "wx/univ/colschem.h"
60 #endif // __WXUNIVERSAL__
62 // ----------------------------------------------------------------------------
64 // ----------------------------------------------------------------------------
66 extern wxWindowList wxModelessWindows
;
67 extern const wxChar
*wxFrameClassName
;
69 #if wxUSE_MENUS_NATIVE
70 extern wxMenu
*wxCurrentPopupMenu
;
71 #endif // wxUSE_MENUS_NATIVE
73 // ----------------------------------------------------------------------------
75 // ----------------------------------------------------------------------------
77 BEGIN_EVENT_TABLE(wxFrameMSW
, wxFrameBase
)
78 EVT_ACTIVATE(wxFrameMSW::OnActivate
)
79 EVT_SYS_COLOUR_CHANGED(wxFrameMSW::OnSysColourChanged
)
82 #ifndef __WXUNIVERSAL__
83 IMPLEMENT_DYNAMIC_CLASS(wxFrame
, wxWindow
)
86 // ============================================================================
88 // ============================================================================
90 // ----------------------------------------------------------------------------
91 // static class members
92 // ----------------------------------------------------------------------------
95 #if wxUSE_NATIVE_STATUSBAR
96 bool wxFrameMSW::m_useNativeStatusBar
= TRUE
;
98 bool wxFrameMSW::m_useNativeStatusBar
= FALSE
;
100 #endif // wxUSE_NATIVE_STATUSBAR
102 // ----------------------------------------------------------------------------
103 // creation/destruction
104 // ----------------------------------------------------------------------------
106 void wxFrameMSW::Init()
109 m_maximizeOnShow
= FALSE
;
115 // Data to save/restore when calling ShowFullScreen
117 m_fsOldWindowStyle
= 0;
118 m_fsStatusBarFields
= 0;
119 m_fsStatusBarHeight
= 0;
120 m_fsToolBarHeight
= 0;
122 m_fsIsMaximized
= FALSE
;
123 m_fsIsShowing
= FALSE
;
125 m_winLastFocused
= (wxWindow
*)NULL
;
127 // unlike (almost?) all other windows, frames are created hidden
131 bool wxFrameMSW::Create(wxWindow
*parent
,
133 const wxString
& title
,
137 const wxString
& name
)
140 m_windowStyle
= style
;
142 SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_APPWORKSPACE
));
147 m_windowId
= (int)NewControlId();
149 if (parent
) parent
->AddChild(this);
158 wxTopLevelWindows
.Append(this);
160 // the frame must have NULL parent HWND or it would be always on top of its
161 // parent which is not what we usually want (in fact, we only want it for
162 // frames with the special wxFRAME_TOOL_WINDOW style handled elsewhere)
163 MSWCreate(m_windowId
, NULL
, wxFrameClassName
, this, title
,
164 x
, y
, width
, height
, style
);
166 wxModelessWindows
.Append(this);
171 wxFrameMSW::~wxFrameMSW()
173 m_isBeingDeleted
= TRUE
;
174 wxTopLevelWindows
.DeleteObject(this);
176 // the ~wxToolBar() code relies on the previous line to be executed before
177 // this one, i.e. the frame should remove itself from wxTopLevelWindows
178 // before destorying its toolbar
181 if (wxTheApp
&& (wxTopLevelWindows
.Number() == 0))
183 wxTheApp
->SetTopWindow(NULL
);
185 if (wxTheApp
->GetExitOnFrameDelete())
191 wxModelessWindows
.DeleteObject(this);
193 // For some reason, wxWindows can activate another task altogether
194 // when a frame is destroyed after a modal dialog has been invoked.
195 // Try to bring the parent to the top.
196 // MT:Only do this if this frame is currently the active window, else weird
197 // things start to happen
198 if ( wxGetActiveWindow() == this )
199 if (GetParent() && GetParent()->GetHWND())
200 ::BringWindowToTop((HWND
) GetParent()->GetHWND());
203 // Get size *available for subwindows* i.e. excluding menu bar, toolbar etc.
204 void wxFrameMSW::DoGetClientSize(int *x
, int *y
) const
207 ::GetClientRect(GetHwnd(), &rect
);
210 if ( GetStatusBar() && GetStatusBar()->IsShown() )
212 int statusX
, statusY
;
213 GetStatusBar()->GetClientSize(&statusX
, &statusY
);
214 rect
.bottom
-= statusY
;
216 #endif // wxUSE_STATUSBAR
218 wxPoint
pt(GetClientAreaOrigin());
228 // Set the client size (i.e. leave the calculation of borders etc.
230 void wxFrameMSW::DoSetClientSize(int width
, int height
)
232 HWND hWnd
= GetHwnd();
235 ::GetClientRect(hWnd
, &rectClient
);
238 ::GetWindowRect(hWnd
, &rectTotal
);
240 // Find the difference between the entire window (title bar and all)
241 // and the client area; add this to the new client size to move the
243 width
+= rectTotal
.right
- rectTotal
.left
- rectClient
.right
;
244 height
+= rectTotal
.bottom
- rectTotal
.top
- rectClient
.bottom
;
247 wxStatusBar
*statbar
= GetStatusBar();
248 if ( statbar
&& statbar
->IsShown() )
250 // leave enough space for the status bar
251 height
+= statbar
->GetSize().y
;
253 #endif // wxUSE_STATUSBAR
255 // note that this takes the toolbar into account
256 wxPoint pt
= GetClientAreaOrigin();
260 if ( !::MoveWindow(hWnd
, rectTotal
.left
, rectTotal
.top
,
261 width
, height
, TRUE
/* redraw */) )
263 wxLogLastError(_T("MoveWindow"));
266 wxSizeEvent
event(wxSize(width
, height
), m_windowId
);
267 event
.SetEventObject(this);
268 GetEventHandler()->ProcessEvent(event
);
271 void wxFrameMSW::DoGetSize(int *width
, int *height
) const
274 ::GetWindowRect(GetHwnd(), &rect
);
276 *width
= rect
.right
- rect
.left
;
277 *height
= rect
.bottom
- rect
.top
;
280 void wxFrameMSW::DoGetPosition(int *x
, int *y
) const
283 ::GetWindowRect(GetHwnd(), &rect
);
289 // ----------------------------------------------------------------------------
290 // variations around ::ShowWindow()
291 // ----------------------------------------------------------------------------
293 void wxFrameMSW::DoShowWindow(int nShowCmd
)
295 ::ShowWindow(GetHwnd(), nShowCmd
);
297 m_iconized
= nShowCmd
== SW_MINIMIZE
;
300 bool wxFrameMSW::Show(bool show
)
302 // don't use wxWindow version as we want to call DoShowWindow()
303 if ( !wxWindowBase::Show(show
) )
309 if ( m_maximizeOnShow
)
312 nShowCmd
= SW_MAXIMIZE
;
314 m_maximizeOnShow
= FALSE
;
326 DoShowWindow(nShowCmd
);
330 ::BringWindowToTop(GetHwnd());
332 wxActivateEvent
event(wxEVT_ACTIVATE
, TRUE
, m_windowId
);
333 event
.SetEventObject( this );
334 GetEventHandler()->ProcessEvent(event
);
338 // Try to highlight the correct window (the parent)
341 HWND hWndParent
= GetHwndOf(GetParent());
343 ::BringWindowToTop(hWndParent
);
350 void wxFrameMSW::Iconize(bool iconize
)
352 DoShowWindow(iconize
? SW_MINIMIZE
: SW_RESTORE
);
355 void wxFrameMSW::Maximize(bool maximize
)
359 // just maximize it directly
360 DoShowWindow(maximize
? SW_MAXIMIZE
: SW_RESTORE
);
364 // we can't maximize the hidden frame because it shows it as well, so
365 // just remember that we should do it later in this case
366 m_maximizeOnShow
= TRUE
;
370 void wxFrameMSW::Restore()
372 DoShowWindow(SW_RESTORE
);
375 bool wxFrameMSW::IsIconized() const
377 #ifdef __WXMICROWIN__
381 ((wxFrameMSW
*)this)->m_iconized
= (::IsIconic(GetHwnd()) != 0);
387 bool wxFrameMSW::IsMaximized() const
389 #ifdef __WXMICROWIN__
393 return (::IsZoomed(GetHwnd()) != 0);
397 void wxFrameMSW::SetIcon(const wxIcon
& icon
)
399 wxFrameBase::SetIcon(icon
);
401 #if defined(__WIN95__) && !defined(__WXMICROWIN__)
404 SendMessage(GetHwnd(), WM_SETICON
,
405 (WPARAM
)TRUE
, (LPARAM
)(HICON
) m_icon
.GetHICON());
410 // generate an artificial resize event
411 void wxFrameMSW::SendSizeEvent()
415 ::GetWindowRect(GetHwnd(), &r
);
417 if ( !::GetWindowRect(GetHwnd(), &r
) )
419 wxLogLastError(_T("GetWindowRect"));
425 (void)::PostMessage(GetHwnd(), WM_SIZE
,
426 IsMaximized() ? SIZE_MAXIMIZED
: SIZE_RESTORED
,
427 MAKELPARAM(r
.right
- r
.left
, r
.bottom
- r
.top
));
432 wxStatusBar
*wxFrameMSW::OnCreateStatusBar(int number
,
435 const wxString
& name
)
437 wxStatusBar
*statusBar
= NULL
;
439 #if wxUSE_NATIVE_STATUSBAR
440 if ( !UsesNativeStatusBar() )
442 statusBar
= (wxStatusBar
*)new wxStatusBarGeneric(this, id
, style
);
447 statusBar
= new wxStatusBar(this, id
, style
, name
);
450 // Set the height according to the font and the border size
451 wxClientDC
dc(statusBar
);
452 dc
.SetFont(statusBar
->GetFont());
455 dc
.GetTextExtent(_T("X"), NULL
, &y
);
457 int height
= (int)( (11*y
)/10 + 2*statusBar
->GetBorderY());
459 statusBar
->SetSize(-1, -1, -1, height
);
461 statusBar
->SetFieldsCount(number
);
466 void wxFrameMSW::PositionStatusBar()
468 if ( !m_frameStatusBar
)
472 GetClientSize(&w
, &h
);
474 m_frameStatusBar
->GetSize(&sw
, &sh
);
476 // Since we wish the status bar to be directly under the client area,
477 // we use the adjusted sizes without using wxSIZE_NO_ADJUSTMENTS.
478 m_frameStatusBar
->SetSize(0, h
, w
, sh
);
480 #endif // wxUSE_STATUSBAR
482 #if wxUSE_MENUS_NATIVE
484 void wxFrameMSW::AttachMenuBar(wxMenuBar
*menubar
)
486 wxFrameBase::AttachMenuBar(menubar
);
490 // actually remove the menu from the frame
491 m_hMenu
= (WXHMENU
)0;
492 InternalSetMenuBar();
494 else // set new non NULL menu bar
496 // Can set a menubar several times.
497 if ( menubar
->GetHMenu() )
499 m_hMenu
= menubar
->GetHMenu();
503 m_hMenu
= menubar
->Create();
507 wxFAIL_MSG( _T("failed to create menu bar") );
512 InternalSetMenuBar();
516 void wxFrameMSW::InternalSetMenuBar()
518 #ifndef __WXMICROWIN__
519 if ( !::SetMenu(GetHwnd(), (HMENU
)m_hMenu
) )
521 wxLogLastError(wxT("SetMenu"));
526 #endif // wxUSE_MENUS_NATIVE
528 // Responds to colour changes, and passes event on to children.
529 void wxFrameMSW::OnSysColourChanged(wxSysColourChangedEvent
& event
)
531 SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_APPWORKSPACE
));
535 if ( m_frameStatusBar
)
537 wxSysColourChangedEvent event2
;
538 event2
.SetEventObject( m_frameStatusBar
);
539 m_frameStatusBar
->GetEventHandler()->ProcessEvent(event2
);
541 #endif // wxUSE_STATUSBAR
543 // Propagate the event to the non-top-level children
544 wxWindow::OnSysColourChanged(event
);
547 // Pass TRUE to show full screen, FALSE to restore.
548 bool wxFrameMSW::ShowFullScreen(bool show
, long style
)
555 m_fsIsShowing
= TRUE
;
559 wxToolBar
*theToolBar
= GetToolBar();
561 theToolBar
->GetSize(NULL
, &m_fsToolBarHeight
);
563 // zap the toolbar, menubar, and statusbar
565 if ((style
& wxFULLSCREEN_NOTOOLBAR
) && theToolBar
)
567 theToolBar
->SetSize(-1,0);
568 theToolBar
->Show(FALSE
);
570 #endif // wxUSE_TOOLBAR
572 #ifndef __WXMICROWIN__
573 if (style
& wxFULLSCREEN_NOMENUBAR
)
574 SetMenu((HWND
)GetHWND(), (HMENU
) NULL
);
578 wxStatusBar
*theStatusBar
= GetStatusBar();
580 theStatusBar
->GetSize(NULL
, &m_fsStatusBarHeight
);
582 // Save the number of fields in the statusbar
583 if ((style
& wxFULLSCREEN_NOSTATUSBAR
) && theStatusBar
)
585 //m_fsStatusBarFields = theStatusBar->GetFieldsCount();
586 //SetStatusBar((wxStatusBar*) NULL);
587 //delete theStatusBar;
588 theStatusBar
->Show(FALSE
);
591 m_fsStatusBarFields
= 0;
592 #endif // wxUSE_STATUSBAR
594 // zap the frame borders
596 // save the 'normal' window style
597 m_fsOldWindowStyle
= GetWindowLong((HWND
)GetHWND(), GWL_STYLE
);
599 // save the old position, width & height, maximize state
600 m_fsOldSize
= GetRect();
601 m_fsIsMaximized
= IsMaximized();
603 // decide which window style flags to turn off
604 LONG newStyle
= m_fsOldWindowStyle
;
607 if (style
& wxFULLSCREEN_NOBORDER
)
608 offFlags
|= WS_BORDER
;
609 if (style
& wxFULLSCREEN_NOCAPTION
)
610 offFlags
|= (WS_CAPTION
| WS_SYSMENU
);
612 newStyle
&= (~offFlags
);
614 // change our window style to be compatible with full-screen mode
615 SetWindowLong((HWND
)GetHWND(), GWL_STYLE
, newStyle
);
617 // resize to the size of the desktop
621 ::GetWindowRect(GetDesktopWindow(), &rect
);
622 width
= rect
.right
- rect
.left
;
623 height
= rect
.bottom
- rect
.top
;
625 SetSize(width
, height
);
627 // now flush the window style cache and actually go full-screen
628 SetWindowPos((HWND
)GetHWND(), HWND_TOP
, 0, 0, width
, height
, SWP_FRAMECHANGED
);
630 wxSizeEvent
event(wxSize(width
, height
), GetId());
631 GetEventHandler()->ProcessEvent(event
);
640 m_fsIsShowing
= FALSE
;
643 wxToolBar
*theToolBar
= GetToolBar();
645 // restore the toolbar, menubar, and statusbar
646 if (theToolBar
&& (m_fsStyle
& wxFULLSCREEN_NOTOOLBAR
))
648 theToolBar
->SetSize(-1, m_fsToolBarHeight
);
649 theToolBar
->Show(TRUE
);
651 #endif // wxUSE_TOOLBAR
654 if ( m_fsStyle
& wxFULLSCREEN_NOSTATUSBAR
)
656 //CreateStatusBar(m_fsStatusBarFields);
659 GetStatusBar()->Show(TRUE
);
663 #endif // wxUSE_STATUSBAR
665 #ifndef __WXMICROWIN__
666 if ((m_fsStyle
& wxFULLSCREEN_NOMENUBAR
) && (m_hMenu
!= 0))
667 SetMenu((HWND
)GetHWND(), (HMENU
)m_hMenu
);
670 Maximize(m_fsIsMaximized
);
671 SetWindowLong((HWND
)GetHWND(),GWL_STYLE
, m_fsOldWindowStyle
);
672 SetWindowPos((HWND
)GetHWND(),HWND_TOP
,m_fsOldSize
.x
, m_fsOldSize
.y
,
673 m_fsOldSize
.width
, m_fsOldSize
.height
, SWP_FRAMECHANGED
);
684 bool wxFrameMSW::MSWCreate(int id
, wxWindow
*parent
, const wxChar
*wclass
, wxWindow
*wx_win
, const wxChar
*title
,
685 int x
, int y
, int width
, int height
, long style
)
688 m_defaultIcon
= (WXHICON
) (wxSTD_FRAME_ICON
? wxSTD_FRAME_ICON
: wxDEFAULT_FRAME_ICON
);
690 // If child windows aren't properly drawn initially, WS_CLIPCHILDREN
691 // could be the culprit. But without it, you can get a lot of flicker.
694 if ( style
& wxCAPTION
)
696 if ( style
& wxFRAME_TOOL_WINDOW
)
697 msflags
|= WS_POPUPWINDOW
;
699 msflags
|= WS_OVERLAPPED
;
706 if (style
& wxMINIMIZE_BOX
)
707 msflags
|= WS_MINIMIZEBOX
;
708 if (style
& wxMAXIMIZE_BOX
)
709 msflags
|= WS_MAXIMIZEBOX
;
710 if (style
& wxTHICK_FRAME
)
711 msflags
|= WS_THICKFRAME
;
712 if (style
& wxSYSTEM_MENU
)
713 msflags
|= WS_SYSMENU
;
714 if ( style
& wxMINIMIZE
)
715 msflags
|= WS_MINIMIZE
;
716 if (style
& wxMAXIMIZE
)
717 msflags
|= WS_MAXIMIZE
;
718 if (style
& wxCAPTION
)
719 msflags
|= WS_CAPTION
;
720 if (style
& wxCLIP_CHILDREN
)
721 msflags
|= WS_CLIPCHILDREN
;
723 // Keep this in wxFrameMSW because it saves recoding this function
725 #if wxUSE_ITSY_BITSY && !defined(__WIN32__)
726 if (style
& wxTINY_CAPTION_VERT
)
727 msflags
|= IBS_VERTCAPTION
;
728 if (style
& wxTINY_CAPTION_HORIZ
)
729 msflags
|= IBS_HORZCAPTION
;
731 if (style
& wxTINY_CAPTION_VERT
)
732 msflags
|= WS_CAPTION
;
733 if (style
& wxTINY_CAPTION_HORIZ
)
734 msflags
|= WS_CAPTION
;
736 if ((style
& wxTHICK_FRAME
) == 0)
737 msflags
|= WS_BORDER
;
739 WXDWORD extendedStyle
= MakeExtendedStyle(style
);
741 // make all frames appear in the win9x shell taskbar unless
742 // wxFRAME_TOOL_WINDOW or wxFRAME_NO_TASKBAR is given - without giving them
743 // WS_EX_APPWINDOW style, the child (i.e. owned) frames wouldn't appear in it
744 #if !defined(__WIN16__) && !defined(__SC__)
745 if ( (style
& wxFRAME_TOOL_WINDOW
) ||
746 (style
& wxFRAME_NO_TASKBAR
) )
747 extendedStyle
|= WS_EX_TOOLWINDOW
;
748 else if ( !(style
& wxFRAME_NO_TASKBAR
) )
749 extendedStyle
|= WS_EX_APPWINDOW
;
752 if (style
& wxSTAY_ON_TOP
)
753 extendedStyle
|= WS_EX_TOPMOST
;
756 if (m_exStyle
& wxFRAME_EX_CONTEXTHELP
)
757 extendedStyle
|= WS_EX_CONTEXTHELP
;
761 if ( !wxWindow::MSWCreate(id
, parent
, wclass
, wx_win
, title
, x
, y
, width
, height
,
762 msflags
, NULL
, extendedStyle
) )
765 // Seems to be necessary if we use WS_POPUP
766 // style instead of WS_OVERLAPPED
767 if (width
> -1 && height
> -1)
768 ::PostMessage(GetHwnd(), WM_SIZE
, SIZE_RESTORED
, MAKELPARAM(width
, height
));
773 // Default activation behaviour - set the focus for the first child
775 void wxFrameMSW::OnActivate(wxActivateEvent
& event
)
777 if ( event
.GetActive() )
779 // restore focus to the child which was last focused
780 wxLogTrace(_T("focus"), _T("wxFrameMSW %08x activated."), m_hWnd
);
782 wxWindow
*parent
= m_winLastFocused
? m_winLastFocused
->GetParent()
789 wxSetFocusToChild(parent
, &m_winLastFocused
);
793 // remember the last focused child if it is our child
794 m_winLastFocused
= FindFocus();
796 // so we NULL it out if it's a child from some other frame
797 wxWindow
*win
= m_winLastFocused
;
800 if ( win
->IsTopLevel() )
804 m_winLastFocused
= NULL
;
810 win
= win
->GetParent();
813 wxLogTrace(_T("focus"),
814 _T("wxFrameMSW %08x deactivated, last focused: %08x."),
816 m_winLastFocused
? GetHwndOf(m_winLastFocused
)
823 // ----------------------------------------------------------------------------
824 // tool/status bar stuff
825 // ----------------------------------------------------------------------------
829 wxToolBar
* wxFrameMSW::CreateToolBar(long style
, wxWindowID id
, const wxString
& name
)
831 if ( wxFrameBase::CreateToolBar(style
, id
, name
) )
836 return m_frameToolBar
;
839 void wxFrameMSW::PositionToolBar()
842 ::GetClientRect(GetHwnd(), &rect
);
845 if ( GetStatusBar() )
847 int statusX
, statusY
;
848 GetStatusBar()->GetClientSize(&statusX
, &statusY
);
849 rect
.bottom
-= statusY
;
851 #endif // wxUSE_STATUSBAR
853 if ( GetToolBar() && GetToolBar()->IsShown() )
856 GetToolBar()->GetSize(&tw
, &th
);
858 if ( GetToolBar()->GetWindowStyleFlag() & wxTB_VERTICAL
)
867 // Use the 'real' MSW position here
868 GetToolBar()->SetSize(0, 0, tw
, th
, wxSIZE_NO_ADJUSTMENTS
);
871 #endif // wxUSE_TOOLBAR
873 // ----------------------------------------------------------------------------
874 // frame state (iconized/maximized/...)
875 // ----------------------------------------------------------------------------
877 // propagate our state change to all child frames: this allows us to emulate X
878 // Windows behaviour where child frames float independently of the parent one
879 // on the desktop, but are iconized/restored with it
880 void wxFrameMSW::IconizeChildFrames(bool bIconize
)
882 for ( wxWindowList::Node
*node
= GetChildren().GetFirst();
884 node
= node
->GetNext() )
886 wxWindow
*win
= node
->GetData();
888 // iconizing the frames with this style under Win95 shell puts them at
889 // the bottom of the screen (as the MDI children) instead of making
890 // them appear in the taskbar because they are, by virtue of this
891 // style, not managed by the taskbar - instead leave Windows take care
894 if ( win
->GetWindowStyle() & wxFRAME_TOOL_WINDOW
)
898 // the child MDI frames are a special case and should not be touched by
899 // the parent frame - instead, they are managed by the user
900 wxFrameMSW
*frame
= wxDynamicCast(win
, wxFrame
);
902 #if wxUSE_MDI_ARCHITECTURE
903 && !wxDynamicCast(frame
, wxMDIChildFrame
)
904 #endif // wxUSE_MDI_ARCHITECTURE
907 frame
->Iconize(bIconize
);
912 // ===========================================================================
913 // message processing
914 // ===========================================================================
916 // ---------------------------------------------------------------------------
918 // ---------------------------------------------------------------------------
920 bool wxFrameMSW::MSWTranslateMessage(WXMSG
* pMsg
)
922 if ( wxWindow::MSWTranslateMessage(pMsg
) )
925 #if wxUSE_MENUS && wxUSE_ACCEL && !defined(__WXUNIVERSAL__)
926 // try the menu bar accels
927 wxMenuBar
*menuBar
= GetMenuBar();
931 const wxAcceleratorTable
& acceleratorTable
= menuBar
->GetAccelTable();
932 return acceleratorTable
.Translate(this, pMsg
);
935 #endif // wxUSE_MENUS && wxUSE_ACCEL
938 // ---------------------------------------------------------------------------
939 // our private (non virtual) message handlers
940 // ---------------------------------------------------------------------------
942 bool wxFrameMSW::HandlePaint()
945 if ( GetUpdateRect(GetHwnd(), &rect
, FALSE
) )
947 #ifndef __WXMICROWIN__
950 HICON hIcon
= m_icon
.Ok() ? GetHiconOf(m_icon
)
951 : (HICON
)m_defaultIcon
;
953 // Hold a pointer to the dc so long as the OnPaint() message
954 // is being processed
956 HDC hdc
= ::BeginPaint(GetHwnd(), &ps
);
958 // Erase background before painting or we get white background
959 MSWDefWindowProc(WM_ICONERASEBKGND
, (WORD
)(LONG
)ps
.hdc
, 0L);
964 ::GetClientRect(GetHwnd(), &rect
);
966 // FIXME: why hardcoded?
967 static const int icon_width
= 32;
968 static const int icon_height
= 32;
970 int icon_x
= (int)((rect
.right
- icon_width
)/2);
971 int icon_y
= (int)((rect
.bottom
- icon_height
)/2);
973 ::DrawIcon(hdc
, icon_x
, icon_y
, hIcon
);
976 ::EndPaint(GetHwnd(), &ps
);
983 return wxWindow::HandlePaint();
988 // nothing to paint - processed
993 bool wxFrameMSW::HandleSize(int x
, int y
, WXUINT id
)
995 bool processed
= FALSE
;
996 #ifndef __WXMICROWIN__
1001 // only do it it if we were iconized before, otherwise resizing the
1002 // parent frame has a curious side effect of bringing it under it's
1007 // restore all child frames too
1008 IconizeChildFrames(FALSE
);
1010 (void)SendIconizeEvent(FALSE
);
1014 case SIZEFULLSCREEN
:
1019 // iconize all child frames too
1020 IconizeChildFrames(TRUE
);
1022 (void)SendIconizeEvent();
1032 PositionStatusBar();
1033 #endif // wxUSE_STATUSBAR
1037 #endif // wxUSE_TOOLBAR
1039 wxSizeEvent
event(wxSize(x
, y
), m_windowId
);
1040 event
.SetEventObject( this );
1041 processed
= GetEventHandler()->ProcessEvent(event
);
1047 bool wxFrameMSW::HandleCommand(WXWORD id
, WXWORD cmd
, WXHWND control
)
1051 // In case it's e.g. a toolbar.
1052 wxWindow
*win
= wxFindWinFromHandle(control
);
1054 return win
->MSWCommand(cmd
, id
);
1057 // handle here commands from menus and accelerators
1058 if ( cmd
== 0 || cmd
== 1 )
1060 #if wxUSE_MENUS_NATIVE
1061 if ( wxCurrentPopupMenu
)
1063 wxMenu
*popupMenu
= wxCurrentPopupMenu
;
1064 wxCurrentPopupMenu
= NULL
;
1066 return popupMenu
->MSWCommand(cmd
, id
);
1068 #endif // wxUSE_MENUS_NATIVE
1070 if ( ProcessCommand(id
) )
1079 bool wxFrameMSW::HandleMenuSelect(WXWORD nItem
, WXWORD flags
, WXHMENU hMenu
)
1082 if ( flags
== 0xFFFF && hMenu
== 0 )
1084 // menu was removed from screen
1087 #ifndef __WXMICROWIN__
1088 else if ( !(flags
& MF_POPUP
) && !(flags
& MF_SEPARATOR
) )
1096 // don't give hints for separators (doesn't make sense) nor for the
1097 // items opening popup menus (they don't have them anyhow) but do clear
1098 // the status line - otherwise, we would be left with the help message
1099 // for the previous item which doesn't apply any more
1100 wxStatusBar
*statbar
= GetStatusBar();
1103 statbar
->SetStatusText(wxEmptyString
);
1105 #endif // wxUSE_STATUSBAR
1110 wxMenuEvent
event(wxEVT_MENU_HIGHLIGHT
, item
);
1111 event
.SetEventObject( this );
1113 return GetEventHandler()->ProcessEvent(event
);
1116 // ---------------------------------------------------------------------------
1117 // the window proc for wxFrameMSW
1118 // ---------------------------------------------------------------------------
1120 long wxFrameMSW::MSWWindowProc(WXUINT message
, WXWPARAM wParam
, WXLPARAM lParam
)
1123 bool processed
= FALSE
;
1128 // if we can't close, tell the system that we processed the
1129 // message - otherwise it would close us
1130 processed
= !Close();
1137 UnpackCommand((WXWPARAM
)wParam
, (WXLPARAM
)lParam
,
1140 processed
= HandleCommand(id
, cmd
, (WXHWND
)hwnd
);
1144 #ifndef __WXMICROWIN__
1149 UnpackMenuSelect(wParam
, lParam
, &item
, &flags
, &hmenu
);
1151 processed
= HandleMenuSelect(item
, flags
, hmenu
);
1157 processed
= HandlePaint();
1160 #ifndef __WXMICROWIN__
1161 case WM_QUERYDRAGICON
:
1163 HICON hIcon
= m_icon
.Ok() ? GetHiconOf(m_icon
)
1164 : (HICON
)(m_defaultIcon
);
1166 processed
= rc
!= 0;
1172 processed
= HandleSize(LOWORD(lParam
), HIWORD(lParam
), wParam
);
1177 rc
= wxWindow::MSWWindowProc(message
, wParam
, lParam
);