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 wxList WXDLLEXPORT wxPendingDelete
;
68 extern const wxChar
*wxFrameClassName
;
70 #if wxUSE_MENUS_NATIVE
71 extern wxMenu
*wxCurrentPopupMenu
;
72 #endif // wxUSE_MENUS_NATIVE
74 // ----------------------------------------------------------------------------
76 // ----------------------------------------------------------------------------
78 BEGIN_EVENT_TABLE(wxFrameMSW
, wxFrameBase
)
79 EVT_ACTIVATE(wxFrameMSW::OnActivate
)
80 EVT_SYS_COLOUR_CHANGED(wxFrameMSW::OnSysColourChanged
)
83 #ifndef __WXUNIVERSAL__
84 IMPLEMENT_DYNAMIC_CLASS(wxFrame
, wxWindow
)
87 // ============================================================================
89 // ============================================================================
91 // ----------------------------------------------------------------------------
92 // static class members
93 // ----------------------------------------------------------------------------
96 #if wxUSE_NATIVE_STATUSBAR
97 bool wxFrameMSW::m_useNativeStatusBar
= TRUE
;
99 bool wxFrameMSW::m_useNativeStatusBar
= FALSE
;
101 #endif // wxUSE_NATIVE_STATUSBAR
103 // ----------------------------------------------------------------------------
104 // creation/destruction
105 // ----------------------------------------------------------------------------
107 void wxFrameMSW::Init()
110 m_maximizeOnShow
= FALSE
;
116 // Data to save/restore when calling ShowFullScreen
118 m_fsOldWindowStyle
= 0;
119 m_fsStatusBarFields
= 0;
120 m_fsStatusBarHeight
= 0;
121 m_fsToolBarHeight
= 0;
123 m_fsIsMaximized
= FALSE
;
124 m_fsIsShowing
= FALSE
;
126 m_winLastFocused
= (wxWindow
*)NULL
;
128 // unlike (almost?) all other windows, frames are created hidden
132 bool wxFrameMSW::Create(wxWindow
*parent
,
134 const wxString
& title
,
138 const wxString
& name
)
141 m_windowStyle
= style
;
143 SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_APPWORKSPACE
));
148 m_windowId
= (int)NewControlId();
150 if (parent
) parent
->AddChild(this);
159 wxTopLevelWindows
.Append(this);
161 MSWCreate(m_windowId
, parent
, wxFrameClassName
, this, title
,
162 x
, y
, width
, height
, style
);
164 wxModelessWindows
.Append(this);
169 wxFrameMSW::~wxFrameMSW()
171 m_isBeingDeleted
= TRUE
;
172 wxTopLevelWindows
.DeleteObject(this);
174 // the ~wxToolBar() code relies on the previous line to be executed before
175 // this one, i.e. the frame should remove itself from wxTopLevelWindows
176 // before destorying its toolbar
179 if (wxTheApp
&& (wxTopLevelWindows
.Number() == 0))
181 wxTheApp
->SetTopWindow(NULL
);
183 if (wxTheApp
->GetExitOnFrameDelete())
189 wxModelessWindows
.DeleteObject(this);
191 // For some reason, wxWindows can activate another task altogether
192 // when a frame is destroyed after a modal dialog has been invoked.
193 // Try to bring the parent to the top.
194 // MT:Only do this if this frame is currently the active window, else weird
195 // things start to happen
196 if ( wxGetActiveWindow() == this )
197 if (GetParent() && GetParent()->GetHWND())
198 ::BringWindowToTop((HWND
) GetParent()->GetHWND());
201 // Get size *available for subwindows* i.e. excluding menu bar, toolbar etc.
202 void wxFrameMSW::DoGetClientSize(int *x
, int *y
) const
205 ::GetClientRect(GetHwnd(), &rect
);
208 if ( GetStatusBar() && GetStatusBar()->IsShown() )
210 int statusX
, statusY
;
211 GetStatusBar()->GetClientSize(&statusX
, &statusY
);
212 rect
.bottom
-= statusY
;
214 #endif // wxUSE_STATUSBAR
216 wxPoint
pt(GetClientAreaOrigin());
226 // Set the client size (i.e. leave the calculation of borders etc.
228 void wxFrameMSW::DoSetClientSize(int width
, int height
)
230 HWND hWnd
= GetHwnd();
233 ::GetClientRect(hWnd
, &rectClient
);
236 ::GetWindowRect(hWnd
, &rectTotal
);
238 // Find the difference between the entire window (title bar and all)
239 // and the client area; add this to the new client size to move the
241 width
+= rectTotal
.right
- rectTotal
.left
- rectClient
.right
;
242 height
+= rectTotal
.bottom
- rectTotal
.top
- rectClient
.bottom
;
245 wxStatusBar
*statbar
= GetStatusBar();
246 if ( statbar
&& statbar
->IsShown() )
248 // leave enough space for the status bar
249 height
+= statbar
->GetSize().y
;
251 #endif // wxUSE_STATUSBAR
253 // note that this takes the toolbar into account
254 wxPoint pt
= GetClientAreaOrigin();
258 if ( !::MoveWindow(hWnd
, rectTotal
.left
, rectTotal
.top
,
259 width
, height
, TRUE
/* redraw */) )
261 wxLogLastError(_T("MoveWindow"));
264 wxSizeEvent
event(wxSize(width
, height
), m_windowId
);
265 event
.SetEventObject(this);
266 GetEventHandler()->ProcessEvent(event
);
269 void wxFrameMSW::DoGetSize(int *width
, int *height
) const
272 ::GetWindowRect(GetHwnd(), &rect
);
274 *width
= rect
.right
- rect
.left
;
275 *height
= rect
.bottom
- rect
.top
;
278 void wxFrameMSW::DoGetPosition(int *x
, int *y
) const
281 ::GetWindowRect(GetHwnd(), &rect
);
287 // ----------------------------------------------------------------------------
288 // variations around ::ShowWindow()
289 // ----------------------------------------------------------------------------
291 void wxFrameMSW::DoShowWindow(int nShowCmd
)
293 ::ShowWindow(GetHwnd(), nShowCmd
);
295 m_iconized
= nShowCmd
== SW_MINIMIZE
;
298 bool wxFrameMSW::Show(bool show
)
300 // don't use wxWindow version as we want to call DoShowWindow()
301 if ( !wxWindowBase::Show(show
) )
307 if ( m_maximizeOnShow
)
310 nShowCmd
= SW_MAXIMIZE
;
312 m_maximizeOnShow
= FALSE
;
324 DoShowWindow(nShowCmd
);
328 ::BringWindowToTop(GetHwnd());
330 wxActivateEvent
event(wxEVT_ACTIVATE
, TRUE
, m_windowId
);
331 event
.SetEventObject( this );
332 GetEventHandler()->ProcessEvent(event
);
336 // Try to highlight the correct window (the parent)
339 HWND hWndParent
= GetHwndOf(GetParent());
341 ::BringWindowToTop(hWndParent
);
348 void wxFrameMSW::Iconize(bool iconize
)
350 DoShowWindow(iconize
? SW_MINIMIZE
: SW_RESTORE
);
353 void wxFrameMSW::Maximize(bool maximize
)
357 // just maximize it directly
358 DoShowWindow(maximize
? SW_MAXIMIZE
: SW_RESTORE
);
362 // we can't maximize the hidden frame because it shows it as well, so
363 // just remember that we should do it later in this case
364 m_maximizeOnShow
= TRUE
;
368 void wxFrameMSW::Restore()
370 DoShowWindow(SW_RESTORE
);
373 bool wxFrameMSW::IsIconized() const
375 #ifdef __WXMICROWIN__
379 ((wxFrameMSW
*)this)->m_iconized
= (::IsIconic(GetHwnd()) != 0);
385 bool wxFrameMSW::IsMaximized() const
387 #ifdef __WXMICROWIN__
391 return (::IsZoomed(GetHwnd()) != 0);
395 void wxFrameMSW::SetIcon(const wxIcon
& icon
)
397 wxFrameBase::SetIcon(icon
);
399 #if defined(__WIN95__) && !defined(__WXMICROWIN__)
402 SendMessage(GetHwnd(), WM_SETICON
,
403 (WPARAM
)TRUE
, (LPARAM
)(HICON
) m_icon
.GetHICON());
408 // generate an artificial resize event
409 void wxFrameMSW::SendSizeEvent()
413 ::GetWindowRect(GetHwnd(), &r
);
415 if ( !::GetWindowRect(GetHwnd(), &r
) )
417 wxLogLastError(_T("GetWindowRect"));
423 (void)::PostMessage(GetHwnd(), WM_SIZE
,
424 IsMaximized() ? SIZE_MAXIMIZED
: SIZE_RESTORED
,
425 MAKELPARAM(r
.right
- r
.left
, r
.bottom
- r
.top
));
430 wxStatusBar
*wxFrameMSW::OnCreateStatusBar(int number
,
433 const wxString
& name
)
435 wxStatusBar
*statusBar
= NULL
;
437 #if wxUSE_NATIVE_STATUSBAR
438 if ( !UsesNativeStatusBar() )
440 statusBar
= (wxStatusBar
*)new wxStatusBarGeneric(this, id
, style
);
445 statusBar
= new wxStatusBar(this, id
, style
, name
);
448 // Set the height according to the font and the border size
449 wxClientDC
dc(statusBar
);
450 dc
.SetFont(statusBar
->GetFont());
453 dc
.GetTextExtent(_T("X"), NULL
, &y
);
455 int height
= (int)( (11*y
)/10 + 2*statusBar
->GetBorderY());
457 statusBar
->SetSize(-1, -1, -1, height
);
459 statusBar
->SetFieldsCount(number
);
464 void wxFrameMSW::PositionStatusBar()
466 if ( !m_frameStatusBar
)
470 GetClientSize(&w
, &h
);
472 m_frameStatusBar
->GetSize(&sw
, &sh
);
474 // Since we wish the status bar to be directly under the client area,
475 // we use the adjusted sizes without using wxSIZE_NO_ADJUSTMENTS.
476 m_frameStatusBar
->SetSize(0, h
, w
, sh
);
478 #endif // wxUSE_STATUSBAR
480 #if wxUSE_MENUS_NATIVE
482 void wxFrameMSW::AttachMenuBar(wxMenuBar
*menubar
)
484 m_frameMenuBar
= menubar
;
488 // actually remove the menu from the frame
489 m_hMenu
= (WXHMENU
)0;
490 InternalSetMenuBar();
492 else // set new non NULL menu bar
494 // Can set a menubar several times.
495 if ( menubar
->GetHMenu() )
497 m_hMenu
= menubar
->GetHMenu();
501 if ( menubar
->IsAttached() )
504 m_hMenu
= menubar
->Create();
510 InternalSetMenuBar();
514 void wxFrameMSW::InternalSetMenuBar()
516 #ifndef __WXMICROWIN__
517 if ( !::SetMenu(GetHwnd(), (HMENU
)m_hMenu
) )
519 wxLogLastError(wxT("SetMenu"));
524 #endif // wxUSE_MENUS_NATIVE
526 // Responds to colour changes, and passes event on to children.
527 void wxFrameMSW::OnSysColourChanged(wxSysColourChangedEvent
& event
)
529 SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_APPWORKSPACE
));
533 if ( m_frameStatusBar
)
535 wxSysColourChangedEvent event2
;
536 event2
.SetEventObject( m_frameStatusBar
);
537 m_frameStatusBar
->GetEventHandler()->ProcessEvent(event2
);
539 #endif // wxUSE_STATUSBAR
541 // Propagate the event to the non-top-level children
542 wxWindow::OnSysColourChanged(event
);
545 // Pass TRUE to show full screen, FALSE to restore.
546 bool wxFrameMSW::ShowFullScreen(bool show
, long style
)
553 m_fsIsShowing
= TRUE
;
557 wxToolBar
*theToolBar
= GetToolBar();
559 theToolBar
->GetSize(NULL
, &m_fsToolBarHeight
);
561 // zap the toolbar, menubar, and statusbar
563 if ((style
& wxFULLSCREEN_NOTOOLBAR
) && theToolBar
)
565 theToolBar
->SetSize(-1,0);
566 theToolBar
->Show(FALSE
);
568 #endif // wxUSE_TOOLBAR
570 #ifndef __WXMICROWIN__
571 if (style
& wxFULLSCREEN_NOMENUBAR
)
572 SetMenu((HWND
)GetHWND(), (HMENU
) NULL
);
576 wxStatusBar
*theStatusBar
= GetStatusBar();
578 theStatusBar
->GetSize(NULL
, &m_fsStatusBarHeight
);
580 // Save the number of fields in the statusbar
581 if ((style
& wxFULLSCREEN_NOSTATUSBAR
) && theStatusBar
)
583 //m_fsStatusBarFields = theStatusBar->GetFieldsCount();
584 //SetStatusBar((wxStatusBar*) NULL);
585 //delete theStatusBar;
586 theStatusBar
->Show(FALSE
);
589 m_fsStatusBarFields
= 0;
590 #endif // wxUSE_STATUSBAR
592 // zap the frame borders
594 // save the 'normal' window style
595 m_fsOldWindowStyle
= GetWindowLong((HWND
)GetHWND(), GWL_STYLE
);
597 // save the old position, width & height, maximize state
598 m_fsOldSize
= GetRect();
599 m_fsIsMaximized
= IsMaximized();
601 // decide which window style flags to turn off
602 LONG newStyle
= m_fsOldWindowStyle
;
605 if (style
& wxFULLSCREEN_NOBORDER
)
606 offFlags
|= WS_BORDER
;
607 if (style
& wxFULLSCREEN_NOCAPTION
)
608 offFlags
|= (WS_CAPTION
| WS_SYSMENU
);
610 newStyle
&= (~offFlags
);
612 // change our window style to be compatible with full-screen mode
613 SetWindowLong((HWND
)GetHWND(), GWL_STYLE
, newStyle
);
615 // resize to the size of the desktop
619 ::GetWindowRect(GetDesktopWindow(), &rect
);
620 width
= rect
.right
- rect
.left
;
621 height
= rect
.bottom
- rect
.top
;
623 SetSize(width
, height
);
625 // now flush the window style cache and actually go full-screen
626 SetWindowPos((HWND
)GetHWND(), HWND_TOP
, 0, 0, width
, height
, SWP_FRAMECHANGED
);
628 wxSizeEvent
event(wxSize(width
, height
), GetId());
629 GetEventHandler()->ProcessEvent(event
);
638 m_fsIsShowing
= FALSE
;
641 wxToolBar
*theToolBar
= GetToolBar();
643 // restore the toolbar, menubar, and statusbar
644 if (theToolBar
&& (m_fsStyle
& wxFULLSCREEN_NOTOOLBAR
))
646 theToolBar
->SetSize(-1, m_fsToolBarHeight
);
647 theToolBar
->Show(TRUE
);
649 #endif // wxUSE_TOOLBAR
652 if ( m_fsStyle
& wxFULLSCREEN_NOSTATUSBAR
)
654 //CreateStatusBar(m_fsStatusBarFields);
657 GetStatusBar()->Show(TRUE
);
661 #endif // wxUSE_STATUSBAR
663 #ifndef __WXMICROWIN__
664 if ((m_fsStyle
& wxFULLSCREEN_NOMENUBAR
) && (m_hMenu
!= 0))
665 SetMenu((HWND
)GetHWND(), (HMENU
)m_hMenu
);
668 Maximize(m_fsIsMaximized
);
669 SetWindowLong((HWND
)GetHWND(),GWL_STYLE
, m_fsOldWindowStyle
);
670 SetWindowPos((HWND
)GetHWND(),HWND_TOP
,m_fsOldSize
.x
, m_fsOldSize
.y
,
671 m_fsOldSize
.width
, m_fsOldSize
.height
, SWP_FRAMECHANGED
);
682 bool wxFrameMSW::MSWCreate(int id
, wxWindow
*parent
, const wxChar
*wclass
, wxWindow
*wx_win
, const wxChar
*title
,
683 int x
, int y
, int width
, int height
, long style
)
686 m_defaultIcon
= (WXHICON
) (wxSTD_FRAME_ICON
? wxSTD_FRAME_ICON
: wxDEFAULT_FRAME_ICON
);
688 // If child windows aren't properly drawn initially, WS_CLIPCHILDREN
689 // could be the culprit. But without it, you can get a lot of flicker.
692 if ( style
& wxCAPTION
)
694 if ( style
& wxFRAME_TOOL_WINDOW
)
695 msflags
|= WS_POPUPWINDOW
;
697 msflags
|= WS_OVERLAPPED
;
704 if (style
& wxMINIMIZE_BOX
)
705 msflags
|= WS_MINIMIZEBOX
;
706 if (style
& wxMAXIMIZE_BOX
)
707 msflags
|= WS_MAXIMIZEBOX
;
708 if (style
& wxTHICK_FRAME
)
709 msflags
|= WS_THICKFRAME
;
710 if (style
& wxSYSTEM_MENU
)
711 msflags
|= WS_SYSMENU
;
712 if ( style
& wxMINIMIZE
)
713 msflags
|= WS_MINIMIZE
;
714 if (style
& wxMAXIMIZE
)
715 msflags
|= WS_MAXIMIZE
;
716 if (style
& wxCAPTION
)
717 msflags
|= WS_CAPTION
;
718 if (style
& wxCLIP_CHILDREN
)
719 msflags
|= WS_CLIPCHILDREN
;
721 // Keep this in wxFrameMSW because it saves recoding this function
723 #if wxUSE_ITSY_BITSY && !defined(__WIN32__)
724 if (style
& wxTINY_CAPTION_VERT
)
725 msflags
|= IBS_VERTCAPTION
;
726 if (style
& wxTINY_CAPTION_HORIZ
)
727 msflags
|= IBS_HORZCAPTION
;
729 if (style
& wxTINY_CAPTION_VERT
)
730 msflags
|= WS_CAPTION
;
731 if (style
& wxTINY_CAPTION_HORIZ
)
732 msflags
|= WS_CAPTION
;
734 if ((style
& wxTHICK_FRAME
) == 0)
735 msflags
|= WS_BORDER
;
737 WXDWORD extendedStyle
= MakeExtendedStyle(style
);
739 // make all frames appear in the win9x shell taskbar unless
740 // wxFRAME_TOOL_WINDOW or wxFRAME_NO_TASKBAR is given - without giving them
741 // WS_EX_APPWINDOW style, the child (i.e. owned) frames wouldn't appear in it
742 #if !defined(__WIN16__) && !defined(__SC__)
743 if ( (style
& wxFRAME_TOOL_WINDOW
) ||
744 (style
& wxFRAME_NO_TASKBAR
) )
745 extendedStyle
|= WS_EX_TOOLWINDOW
;
746 else if ( !(style
& wxFRAME_NO_TASKBAR
) )
747 extendedStyle
|= WS_EX_APPWINDOW
;
750 if (style
& wxSTAY_ON_TOP
)
751 extendedStyle
|= WS_EX_TOPMOST
;
754 if (m_exStyle
& wxFRAME_EX_CONTEXTHELP
)
755 extendedStyle
|= WS_EX_CONTEXTHELP
;
759 if ( !wxWindow::MSWCreate(id
, parent
, wclass
, wx_win
, title
, x
, y
, width
, height
,
760 msflags
, NULL
, extendedStyle
) )
763 // Seems to be necessary if we use WS_POPUP
764 // style instead of WS_OVERLAPPED
765 if (width
> -1 && height
> -1)
766 ::PostMessage(GetHwnd(), WM_SIZE
, SIZE_RESTORED
, MAKELPARAM(width
, height
));
771 // Default activation behaviour - set the focus for the first child
773 void wxFrameMSW::OnActivate(wxActivateEvent
& event
)
775 if ( event
.GetActive() )
777 // restore focus to the child which was last focused
778 wxLogTrace(_T("focus"), _T("wxFrameMSW %08x activated."), m_hWnd
);
780 wxWindow
*parent
= m_winLastFocused
? m_winLastFocused
->GetParent()
787 wxSetFocusToChild(parent
, &m_winLastFocused
);
791 // remember the last focused child if it is our child
792 m_winLastFocused
= FindFocus();
794 // so we NULL it out if it's a child from some other frame
795 wxWindow
*win
= m_winLastFocused
;
798 if ( win
->IsTopLevel() )
802 m_winLastFocused
= NULL
;
808 win
= win
->GetParent();
811 wxLogTrace(_T("focus"),
812 _T("wxFrameMSW %08x deactivated, last focused: %08x."),
814 m_winLastFocused
? GetHwndOf(m_winLastFocused
)
821 // ----------------------------------------------------------------------------
822 // tool/status bar stuff
823 // ----------------------------------------------------------------------------
827 wxToolBar
* wxFrameMSW::CreateToolBar(long style
, wxWindowID id
, const wxString
& name
)
829 if ( wxFrameBase::CreateToolBar(style
, id
, name
) )
834 return m_frameToolBar
;
837 void wxFrameMSW::PositionToolBar()
840 ::GetClientRect(GetHwnd(), &rect
);
843 if ( GetStatusBar() )
845 int statusX
, statusY
;
846 GetStatusBar()->GetClientSize(&statusX
, &statusY
);
847 rect
.bottom
-= statusY
;
849 #endif // wxUSE_STATUSBAR
851 if ( GetToolBar() && GetToolBar()->IsShown() )
854 GetToolBar()->GetSize(&tw
, &th
);
856 if ( GetToolBar()->GetWindowStyleFlag() & wxTB_VERTICAL
)
865 // Use the 'real' MSW position here
866 GetToolBar()->SetSize(0, 0, tw
, th
, wxSIZE_NO_ADJUSTMENTS
);
869 #endif // wxUSE_TOOLBAR
871 // ----------------------------------------------------------------------------
872 // frame state (iconized/maximized/...)
873 // ----------------------------------------------------------------------------
875 // propagate our state change to all child frames: this allows us to emulate X
876 // Windows behaviour where child frames float independently of the parent one
877 // on the desktop, but are iconized/restored with it
878 void wxFrameMSW::IconizeChildFrames(bool bIconize
)
880 for ( wxWindowList::Node
*node
= GetChildren().GetFirst();
882 node
= node
->GetNext() )
884 wxWindow
*win
= node
->GetData();
886 // iconizing the frames with this style under Win95 shell puts them at
887 // the bottom of the screen (as the MDI children) instead of making
888 // them appear in the taskbar because they are, by virtue of this
889 // style, not managed by the taskbar - instead leave Windows take care
892 if ( win
->GetWindowStyle() & wxFRAME_TOOL_WINDOW
)
896 // the child MDI frames are a special case and should not be touched by
897 // the parent frame - instead, they are managed by the user
898 wxFrameMSW
*frame
= wxDynamicCast(win
, wxFrame
);
900 #if wxUSE_MDI_ARCHITECTURE
901 && !wxDynamicCast(frame
, wxMDIChildFrame
)
902 #endif // wxUSE_MDI_ARCHITECTURE
905 frame
->Iconize(bIconize
);
910 // ===========================================================================
911 // message processing
912 // ===========================================================================
914 // ---------------------------------------------------------------------------
916 // ---------------------------------------------------------------------------
918 bool wxFrameMSW::MSWTranslateMessage(WXMSG
* pMsg
)
920 if ( wxWindow::MSWTranslateMessage(pMsg
) )
923 #if wxUSE_MENUS && wxUSE_ACCEL && !defined(__WXUNIVERSAL__)
924 // try the menu bar accels
925 wxMenuBar
*menuBar
= GetMenuBar();
929 const wxAcceleratorTable
& acceleratorTable
= menuBar
->GetAccelTable();
930 return acceleratorTable
.Translate(this, pMsg
);
933 #endif // wxUSE_MENUS && wxUSE_ACCEL
936 // ---------------------------------------------------------------------------
937 // our private (non virtual) message handlers
938 // ---------------------------------------------------------------------------
940 bool wxFrameMSW::HandlePaint()
943 if ( GetUpdateRect(GetHwnd(), &rect
, FALSE
) )
945 #ifndef __WXMICROWIN__
948 HICON hIcon
= m_icon
.Ok() ? GetHiconOf(m_icon
)
949 : (HICON
)m_defaultIcon
;
951 // Hold a pointer to the dc so long as the OnPaint() message
952 // is being processed
954 HDC hdc
= ::BeginPaint(GetHwnd(), &ps
);
956 // Erase background before painting or we get white background
957 MSWDefWindowProc(WM_ICONERASEBKGND
, (WORD
)(LONG
)ps
.hdc
, 0L);
962 ::GetClientRect(GetHwnd(), &rect
);
964 // FIXME: why hardcoded?
965 static const int icon_width
= 32;
966 static const int icon_height
= 32;
968 int icon_x
= (int)((rect
.right
- icon_width
)/2);
969 int icon_y
= (int)((rect
.bottom
- icon_height
)/2);
971 ::DrawIcon(hdc
, icon_x
, icon_y
, hIcon
);
974 ::EndPaint(GetHwnd(), &ps
);
981 return wxWindow::HandlePaint();
986 // nothing to paint - processed
991 bool wxFrameMSW::HandleSize(int x
, int y
, WXUINT id
)
993 bool processed
= FALSE
;
994 #ifndef __WXMICROWIN__
999 // only do it it if we were iconized before, otherwise resizing the
1000 // parent frame has a curious side effect of bringing it under it's
1005 // restore all child frames too
1006 IconizeChildFrames(FALSE
);
1008 (void)SendIconizeEvent(FALSE
);
1012 case SIZEFULLSCREEN
:
1017 // iconize all child frames too
1018 IconizeChildFrames(TRUE
);
1020 (void)SendIconizeEvent();
1030 PositionStatusBar();
1031 #endif // wxUSE_STATUSBAR
1035 #endif // wxUSE_TOOLBAR
1037 wxSizeEvent
event(wxSize(x
, y
), m_windowId
);
1038 event
.SetEventObject( this );
1039 processed
= GetEventHandler()->ProcessEvent(event
);
1045 bool wxFrameMSW::HandleCommand(WXWORD id
, WXWORD cmd
, WXHWND control
)
1049 // In case it's e.g. a toolbar.
1050 wxWindow
*win
= wxFindWinFromHandle(control
);
1052 return win
->MSWCommand(cmd
, id
);
1055 // handle here commands from menus and accelerators
1056 if ( cmd
== 0 || cmd
== 1 )
1058 #if wxUSE_MENUS_NATIVE
1059 if ( wxCurrentPopupMenu
)
1061 wxMenu
*popupMenu
= wxCurrentPopupMenu
;
1062 wxCurrentPopupMenu
= NULL
;
1064 return popupMenu
->MSWCommand(cmd
, id
);
1066 #endif // wxUSE_MENUS_NATIVE
1068 if ( ProcessCommand(id
) )
1077 bool wxFrameMSW::HandleMenuSelect(WXWORD nItem
, WXWORD flags
, WXHMENU hMenu
)
1080 if ( flags
== 0xFFFF && hMenu
== 0 )
1082 // menu was removed from screen
1085 #ifndef __WXMICROWIN__
1086 else if ( !(flags
& MF_POPUP
) && !(flags
& MF_SEPARATOR
) )
1094 // don't give hints for separators (doesn't make sense) nor for the
1095 // items opening popup menus (they don't have them anyhow) but do clear
1096 // the status line - otherwise, we would be left with the help message
1097 // for the previous item which doesn't apply any more
1098 wxStatusBar
*statbar
= GetStatusBar();
1101 statbar
->SetStatusText(wxEmptyString
);
1103 #endif // wxUSE_STATUSBAR
1108 wxMenuEvent
event(wxEVT_MENU_HIGHLIGHT
, item
);
1109 event
.SetEventObject( this );
1111 return GetEventHandler()->ProcessEvent(event
);
1114 // ---------------------------------------------------------------------------
1115 // the window proc for wxFrameMSW
1116 // ---------------------------------------------------------------------------
1118 long wxFrameMSW::MSWWindowProc(WXUINT message
, WXWPARAM wParam
, WXLPARAM lParam
)
1121 bool processed
= FALSE
;
1126 // if we can't close, tell the system that we processed the
1127 // message - otherwise it would close us
1128 processed
= !Close();
1135 UnpackCommand((WXWPARAM
)wParam
, (WXLPARAM
)lParam
,
1138 processed
= HandleCommand(id
, cmd
, (WXHWND
)hwnd
);
1142 #ifndef __WXMICROWIN__
1147 UnpackMenuSelect(wParam
, lParam
, &item
, &flags
, &hmenu
);
1149 processed
= HandleMenuSelect(item
, flags
, hmenu
);
1155 processed
= HandlePaint();
1158 #ifndef __WXMICROWIN__
1159 case WM_QUERYDRAGICON
:
1161 HICON hIcon
= m_icon
.Ok() ? GetHiconOf(m_icon
)
1162 : (HICON
)(m_defaultIcon
);
1164 processed
= rc
!= 0;
1170 processed
= HandleSize(LOWORD(lParam
), HIWORD(lParam
), wParam
);
1175 rc
= wxWindow::MSWWindowProc(message
, wParam
, lParam
);