1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/msw/frame.cpp
4 // Author: Julian Smart
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 // ============================================================================
14 // ============================================================================
16 // ----------------------------------------------------------------------------
18 // ----------------------------------------------------------------------------
20 // For compilers that support precompilation, includes "wx.h".
21 #include "wx/wxprec.h"
30 #include "wx/msw/wrapcctl.h" // include <commctrl.h> "properly"
34 #include "wx/dialog.h"
35 #include "wx/settings.h"
36 #include "wx/dcclient.h"
40 #include "wx/toolbar.h"
41 #include "wx/statusbr.h"
42 #include "wx/menuitem.h"
45 #include "wx/msw/private.h"
47 #if defined(__POCKETPC__) || defined(__SMARTPHONE__)
50 #include "wx/msw/winundef.h"
53 #include "wx/generic/statusbr.h"
55 #ifdef __WXUNIVERSAL__
56 #include "wx/univ/theme.h"
57 #include "wx/univ/colschem.h"
58 #endif // __WXUNIVERSAL__
60 // FIXME-VC6: Only VC6 doesn't have this in its standard headers so this
61 // could be removed once support for it is dropped.
62 #ifndef WM_UNINITMENUPOPUP
63 #define WM_UNINITMENUPOPUP 0x0125
66 // ----------------------------------------------------------------------------
68 // ----------------------------------------------------------------------------
70 #if wxUSE_MENUS || wxUSE_MENUS_NATIVE
71 extern wxMenu
*wxCurrentPopupMenu
;
72 #endif // wxUSE_MENUS || wxUSE_MENUS_NATIVE
74 // ----------------------------------------------------------------------------
76 // ----------------------------------------------------------------------------
78 BEGIN_EVENT_TABLE(wxFrame
, wxFrameBase
)
79 EVT_SYS_COLOUR_CHANGED(wxFrame::OnSysColourChanged
)
82 // ============================================================================
84 // ============================================================================
86 // ----------------------------------------------------------------------------
87 // static class members
88 // ----------------------------------------------------------------------------
91 #if wxUSE_NATIVE_STATUSBAR
92 bool wxFrame::m_useNativeStatusBar
= true;
94 bool wxFrame::m_useNativeStatusBar
= false;
96 #endif // wxUSE_NATIVE_STATUSBAR
98 // ----------------------------------------------------------------------------
99 // creation/destruction
100 // ----------------------------------------------------------------------------
106 #endif // wxUSE_MENUS
112 m_wasMinimized
= false;
115 bool wxFrame::Create(wxWindow
*parent
,
117 const wxString
& title
,
121 const wxString
& name
)
123 if ( !wxTopLevelWindow::Create(parent
, id
, title
, pos
, size
, style
, name
) )
126 SetOwnBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_APPWORKSPACE
));
128 #if defined(__SMARTPHONE__)
129 SetLeftMenu(wxID_EXIT
, _("Done"));
132 #if wxUSE_ACCEL && defined(__POCKETPC__)
133 // The guidelines state that Ctrl+Q should quit the app.
134 // Let's define an accelerator table to send wxID_EXIT.
135 wxAcceleratorEntry entries
[1];
136 entries
[0].Set(wxACCEL_CTRL
, 'Q', wxID_EXIT
);
137 wxAcceleratorTable
accel(1, entries
);
138 SetAcceleratorTable(accel
);
139 #endif // wxUSE_ACCEL && __POCKETPC__
151 // ----------------------------------------------------------------------------
152 // wxFrame client size calculations
153 // ----------------------------------------------------------------------------
155 void wxFrame::DoSetClientSize(int width
, int height
)
157 // leave enough space for the status bar if we have (and show) it
159 wxStatusBar
*statbar
= GetStatusBar();
160 if ( statbar
&& statbar
->IsShown() )
162 height
+= statbar
->GetSize().y
;
164 #endif // wxUSE_STATUSBAR
166 // call GetClientAreaOrigin() to take the toolbar into account
167 wxPoint pt
= GetClientAreaOrigin();
172 wxToolBar
* const toolbar
= GetToolBar();
175 if ( toolbar
->HasFlag(wxTB_RIGHT
| wxTB_BOTTOM
) )
177 const wxSize sizeTB
= toolbar
->GetSize();
178 if ( toolbar
->HasFlag(wxTB_RIGHT
) )
183 //else: toolbar already taken into account by GetClientAreaOrigin()
185 #endif // wxUSE_TOOLBAR
187 wxTopLevelWindow::DoSetClientSize(width
, height
);
190 // Get size *available for subwindows* i.e. excluding menu bar, toolbar etc.
191 void wxFrame::DoGetClientSize(int *x
, int *y
) const
193 wxTopLevelWindow::DoGetClientSize(x
, y
);
195 // account for the possible toolbar
196 wxPoint pt
= GetClientAreaOrigin();
204 wxToolBar
* const toolbar
= GetToolBar();
207 if ( toolbar
->HasFlag(wxTB_RIGHT
| wxTB_BOTTOM
) )
209 const wxSize sizeTB
= toolbar
->GetSize();
210 if ( toolbar
->HasFlag(wxTB_RIGHT
) )
221 //else: toolbar already taken into account by GetClientAreaOrigin()
223 #endif // wxUSE_TOOLBAR
226 // adjust client area height to take the status bar into account
229 wxStatusBar
*statbar
= GetStatusBar();
230 if ( statbar
&& statbar
->IsShown() )
232 *y
-= statbar
->GetSize().y
;
235 #endif // wxUSE_STATUSBAR
238 // ----------------------------------------------------------------------------
239 // wxFrame: various geometry-related functions
240 // ----------------------------------------------------------------------------
242 void wxFrame::Raise()
244 ::SetForegroundWindow(GetHwnd());
247 // generate an artificial resize event
248 void wxFrame::SendSizeEvent(int flags
)
252 RECT r
= wxGetWindowRect(GetHwnd());
254 if ( flags
& wxSEND_EVENT_POST
)
256 ::PostMessage(GetHwnd(), WM_SIZE
,
257 IsMaximized() ? SIZE_MAXIMIZED
: SIZE_RESTORED
,
258 MAKELPARAM(r
.right
- r
.left
, r
.bottom
- r
.top
));
262 ::SendMessage(GetHwnd(), WM_SIZE
,
263 IsMaximized() ? SIZE_MAXIMIZED
: SIZE_RESTORED
,
264 MAKELPARAM(r
.right
- r
.left
, r
.bottom
- r
.top
));
270 wxStatusBar
*wxFrame::OnCreateStatusBar(int number
,
273 const wxString
& name
)
275 wxStatusBar
*statusBar
wxDUMMY_INITIALIZE(NULL
);
277 #if wxUSE_NATIVE_STATUSBAR
278 if ( !UsesNativeStatusBar() )
280 statusBar
= (wxStatusBar
*)new wxStatusBarGeneric(this, id
, style
);
285 statusBar
= new wxStatusBar(this, id
, style
, name
);
288 statusBar
->SetFieldsCount(number
);
293 void wxFrame::PositionStatusBar()
295 if ( !m_frameStatusBar
|| !m_frameStatusBar
->IsShown() )
299 GetClientSize(&w
, &h
);
302 m_frameStatusBar
->GetSize(&sw
, &sh
);
306 wxToolBar
* const toolbar
= GetToolBar();
307 if ( toolbar
&& !toolbar
->HasFlag(wxTB_TOP
) )
309 const wxSize sizeTB
= toolbar
->GetSize();
311 if ( toolbar
->HasFlag(wxTB_LEFT
| wxTB_RIGHT
) )
313 if ( toolbar
->HasFlag(wxTB_LEFT
) )
320 // we need to position the status bar below the toolbar
324 //else: no adjustments necessary for the toolbar on top
325 #endif // wxUSE_TOOLBAR
327 // Since we wish the status bar to be directly under the client area,
328 // we use the adjusted sizes without using wxSIZE_NO_ADJUSTMENTS.
329 m_frameStatusBar
->SetSize(x
, h
, w
, sh
);
332 #endif // wxUSE_STATUSBAR
334 #if wxUSE_MENUS_NATIVE
336 void wxFrame::AttachMenuBar(wxMenuBar
*menubar
)
338 #if defined(__SMARTPHONE__) && defined(__WXWINCE__)
340 wxMenu
*autoMenu
= NULL
;
342 if( menubar
->GetMenuCount() == 1 )
344 autoMenu
= wxTopLevelWindowMSW::ButtonMenu::DuplicateMenu(menubar
->GetMenu(0));
345 SetRightMenu(wxID_ANY
, menubar
->GetMenuLabel(0), autoMenu
);
349 autoMenu
= new wxMenu
;
351 for( size_t n
= 0; n
< menubar
->GetMenuCount(); n
++ )
353 wxMenu
*item
= menubar
->GetMenu(n
);
354 wxString label
= menubar
->GetMenuLabel(n
);
355 wxMenu
*new_item
= wxTopLevelWindowMSW::ButtonMenu::DuplicateMenu(item
);
356 autoMenu
->Append(wxID_ANY
, label
, new_item
);
359 SetRightMenu(wxID_ANY
, _("Menu"), autoMenu
);
362 #elif defined(WINCE_WITHOUT_COMMANDBAR)
365 wxToolMenuBar
* toolBar
= new wxToolMenuBar(this, wxID_ANY
,
366 wxDefaultPosition
, wxDefaultSize
,
367 wxBORDER_NONE
| wxTB_HORIZONTAL
,
368 wxToolBarNameStr
, menubar
);
370 menubar
->SetToolBar(toolBar
);
373 // When the main window is created using CW_USEDEFAULT the height of the
374 // menubar is not taken into account, so we resize it afterwards if a
375 // menubar is present
376 HWND hwndMenuBar
= SHFindMenuBar(GetHwnd());
380 ::GetWindowRect(hwndMenuBar
, &mbRect
);
381 const int menuHeight
= mbRect
.bottom
- mbRect
.top
;
384 ::GetWindowRect(GetHwnd(), &rc
);
385 // adjust for menu / titlebar height
386 rc
.bottom
-= (2*menuHeight
-1);
388 ::MoveWindow(Gethwnd(), rc
.left
, rc
.top
, rc
.right
, rc
.bottom
, FALSE
);
392 wxFrameBase::AttachMenuBar(menubar
);
396 // actually remove the menu from the frame
397 m_hMenu
= (WXHMENU
)0;
398 InternalSetMenuBar();
400 else // set new non NULL menu bar
402 #if !defined(__WXWINCE__) || defined(WINCE_WITH_COMMANDBAR)
403 // Can set a menubar several times.
404 if ( menubar
->GetHMenu() )
406 m_hMenu
= menubar
->GetHMenu();
410 m_hMenu
= menubar
->Create();
414 wxFAIL_MSG( wxT("failed to create menu bar") );
419 InternalSetMenuBar();
423 void wxFrame::InternalSetMenuBar()
425 #if defined(__WXMICROWIN__) || defined(__WXWINCE__)
428 if ( !::SetMenu(GetHwnd(), (HMENU
)m_hMenu
) )
430 wxLogLastError(wxT("SetMenu"));
435 #endif // wxUSE_MENUS_NATIVE
437 // Responds to colour changes, and passes event on to children.
438 void wxFrame::OnSysColourChanged(wxSysColourChangedEvent
& event
)
440 SetOwnBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_APPWORKSPACE
));
444 if ( m_frameStatusBar
)
446 wxSysColourChangedEvent event2
;
447 event2
.SetEventObject( m_frameStatusBar
);
448 m_frameStatusBar
->HandleWindowEvent(event2
);
450 #endif // wxUSE_STATUSBAR
452 // Propagate the event to the non-top-level children
453 wxWindow::OnSysColourChanged(event
);
456 // Pass true to show full screen, false to restore.
457 bool wxFrame::ShowFullScreen(bool show
, long style
)
459 // TODO-CE: add support for CE
460 #if !defined(__WXMICROWIN__) && !defined(__WXWINCE__)
461 if ( IsFullScreen() == show
)
466 // zap the toolbar, menubar, and statusbar if needed
468 // TODO: hide commandbar for WINCE_WITH_COMMANDBAR
470 wxToolBar
*theToolBar
= GetToolBar();
472 if ((style
& wxFULLSCREEN_NOTOOLBAR
) && theToolBar
)
474 if ( theToolBar
->IsShown() )
476 theToolBar
->SetSize(wxDefaultCoord
,0);
477 theToolBar
->Show(false);
479 else // prevent it from being restored later
481 style
&= ~wxFULLSCREEN_NOTOOLBAR
;
484 #endif // wxUSE_TOOLBAR
486 if (style
& wxFULLSCREEN_NOMENUBAR
)
487 SetMenu((HWND
)GetHWND(), (HMENU
) NULL
);
490 wxStatusBar
*theStatusBar
= GetStatusBar();
492 // Save the number of fields in the statusbar
493 if ((style
& wxFULLSCREEN_NOSTATUSBAR
) && theStatusBar
)
495 if ( theStatusBar
->IsShown() )
496 theStatusBar
->Show(false);
498 style
&= ~wxFULLSCREEN_NOSTATUSBAR
;
500 #endif // wxUSE_STATUSBAR
502 else // restore to normal
504 // restore the toolbar, menubar, and statusbar if we had hid them
506 wxToolBar
*theToolBar
= GetToolBar();
508 if ((m_fsStyle
& wxFULLSCREEN_NOTOOLBAR
) && theToolBar
)
510 theToolBar
->Show(true);
512 #endif // wxUSE_TOOLBAR
515 if (m_fsStyle
& wxFULLSCREEN_NOMENUBAR
)
517 const WXHMENU hmenu
= MSWGetActiveMenu();
519 ::SetMenu(GetHwnd(), (HMENU
)hmenu
);
521 #endif // wxUSE_MENUS
524 wxStatusBar
*theStatusBar
= GetStatusBar();
526 if ((m_fsStyle
& wxFULLSCREEN_NOSTATUSBAR
) && theStatusBar
)
528 theStatusBar
->Show(true);
531 #endif // wxUSE_STATUSBAR
533 #endif // !defined(__WXMICROWIN__) && !defined(__WXWINCE__)
535 return wxFrameBase::ShowFullScreen(show
, style
);
538 // ----------------------------------------------------------------------------
539 // tool/status bar stuff
540 // ----------------------------------------------------------------------------
544 wxToolBar
* wxFrame::CreateToolBar(long style
, wxWindowID id
, const wxString
& name
)
546 #if defined(WINCE_WITHOUT_COMMANDBAR)
547 // We may already have a toolbar from calling SetMenuBar.
551 if ( wxFrameBase::CreateToolBar(style
, id
, name
) )
556 return m_frameToolBar
;
559 void wxFrame::PositionToolBar()
561 // TODO: we want to do something different in WinCE, because the toolbar
562 // should be associated with the commandbar, instead of being
563 // independent window.
564 #if !defined(WINCE_WITHOUT_COMMANDBAR)
565 wxToolBar
*toolbar
= GetToolBar();
566 if ( toolbar
&& toolbar
->IsShown() )
568 // don't call our (or even wxTopLevelWindow) version because we want
569 // the real (full) client area size, not excluding the tool/status bar
571 wxWindow::DoGetClientSize(&width
, &height
);
574 wxStatusBar
*statbar
= GetStatusBar();
575 if ( statbar
&& statbar
->IsShown() )
577 height
-= statbar
->GetClientSize().y
;
579 #endif // wxUSE_STATUSBAR
582 toolbar
->GetPosition( &tx
, &ty
);
583 toolbar
->GetSize( &tw
, &th
);
586 if ( toolbar
->HasFlag(wxTB_BOTTOM
) )
591 else if ( toolbar
->HasFlag(wxTB_RIGHT
) )
602 #if defined(WINCE_WITH_COMMANDBAR)
603 // We're using a commandbar - so we have to allow for it.
604 if (GetMenuBar() && GetMenuBar()->GetCommandBar())
607 ::GetWindowRect((HWND
) GetMenuBar()->GetCommandBar(), &rect
);
608 y
= rect
.bottom
- rect
.top
;
610 #endif // WINCE_WITH_COMMANDBAR
612 if ( toolbar
->HasFlag(wxTB_BOTTOM
) )
614 if ( ty
< 0 && ( -ty
== th
) )
616 if ( tx
< 0 && (-tx
== tw
) )
619 else if ( toolbar
->HasFlag(wxTB_RIGHT
) )
621 if( ty
< 0 && ( -ty
== th
) )
623 if( tx
< 0 && ( -tx
== tw
) )
628 if (ty
< 0 && (-ty
== th
))
630 if (tx
< 0 && (-tx
== tw
))
637 if ( toolbar
->IsVertical() )
648 // use the 'real' MSW position here, don't offset relatively to the
649 // client area origin
650 toolbar
->SetSize(x
, y
, desiredW
, desiredH
, wxSIZE_NO_ADJUSTMENTS
);
653 #endif // !WINCE_WITH_COMMANDBAR
656 #endif // wxUSE_TOOLBAR
658 // ----------------------------------------------------------------------------
659 // frame state (iconized/maximized/...)
660 // ----------------------------------------------------------------------------
662 // propagate our state change to all child frames: this allows us to emulate X
663 // Windows behaviour where child frames float independently of the parent one
664 // on the desktop, but are iconized/restored with it
665 void wxFrame::IconizeChildFrames(bool bIconize
)
667 m_iconized
= bIconize
;
669 for ( wxWindowList::compatibility_iterator node
= GetChildren().GetFirst();
671 node
= node
->GetNext() )
673 wxWindow
*win
= node
->GetData();
675 // iconizing the frames with this style under Win95 shell puts them at
676 // the bottom of the screen (as the MDI children) instead of making
677 // them appear in the taskbar because they are, by virtue of this
678 // style, not managed by the taskbar - instead leave Windows take care
680 if ( win
->GetWindowStyle() & wxFRAME_TOOL_WINDOW
)
683 // the child MDI frames are a special case and should not be touched by
684 // the parent frame - instead, they are managed by the user
685 wxFrame
*frame
= wxDynamicCast(win
, wxFrame
);
687 #if wxUSE_MDI_ARCHITECTURE
688 && !frame
->IsMDIChild()
689 #endif // wxUSE_MDI_ARCHITECTURE
692 // we don't want to restore the child frames which had been
693 // iconized even before we were iconized, so save the child frame
694 // status when iconizing the parent frame and check it when
698 frame
->m_wasMinimized
= frame
->IsIconized();
701 // note that we shouldn't touch the hidden frames neither because
702 // iconizing/restoring them would show them as a side effect
703 if ( !frame
->m_wasMinimized
&& frame
->IsShown() )
704 frame
->Iconize(bIconize
);
709 WXHICON
wxFrame::GetDefaultIcon() const
711 // we don't have any standard icons (any more)
715 // ===========================================================================
716 // message processing
717 // ===========================================================================
719 // ---------------------------------------------------------------------------
721 // ---------------------------------------------------------------------------
723 bool wxFrame::MSWDoTranslateMessage(wxFrame
*frame
, WXMSG
*pMsg
)
725 if ( wxWindow::MSWTranslateMessage(pMsg
) )
728 #if wxUSE_MENUS && wxUSE_ACCEL && !defined(__WXUNIVERSAL__)
729 // try the menu bar accelerators
730 wxMenuBar
*menuBar
= GetMenuBar();
731 if ( menuBar
&& menuBar
->GetAcceleratorTable()->Translate(frame
, pMsg
) )
733 #endif // wxUSE_MENUS && wxUSE_ACCEL
738 // ---------------------------------------------------------------------------
739 // our private (non virtual) message handlers
740 // ---------------------------------------------------------------------------
742 bool wxFrame::HandleSize(int WXUNUSED(x
), int WXUNUSED(y
), WXUINT id
)
744 #if !defined(__WXMICROWIN__) && !defined(__WXWINCE__)
749 // only do it it if we were iconized before, otherwise resizing the
750 // parent frame has a curious side effect of bringing it under it's
755 // restore all child frames too
756 IconizeChildFrames(false);
758 (void)SendIconizeEvent(false);
762 // iconize all child frames too
763 IconizeChildFrames(true);
768 #endif // !__WXWINCE__
774 #endif // wxUSE_STATUSBAR
778 #endif // wxUSE_TOOLBAR
780 #if defined(WINCE_WITH_COMMANDBAR)
781 // Position the menu command bar
782 if (GetMenuBar() && GetMenuBar()->GetCommandBar())
785 ::GetWindowRect((HWND
) GetMenuBar()->GetCommandBar(), &rect
);
786 wxSize clientSz
= GetClientSize();
788 if ( !::MoveWindow((HWND
) GetMenuBar()->GetCommandBar(), 0, 0, clientSz
.x
, rect
.bottom
- rect
.top
, true ) )
790 wxLogLastError(wxT("MoveWindow"));
794 #endif // WINCE_WITH_COMMANDBAR
797 // call the base class version to generate the appropriate events
801 bool wxFrame::HandleCommand(WXWORD id
, WXWORD cmd
, WXHWND control
)
805 #if defined(WINCE_WITHOUT_COMMANDBAR)
806 if (GetToolBar() && GetToolBar()->FindById(id
))
807 return GetToolBar()->MSWCommand(cmd
, id
);
810 // we only need to handle the menu and accelerator commands from the items
811 // of our menu bar, base wxWindow class already handles the rest
812 if ( !control
&& (cmd
== 0 /* menu */ || cmd
== 1 /* accel */) )
814 #if wxUSE_MENUS_NATIVE
815 if ( !wxCurrentPopupMenu
)
816 #endif // wxUSE_MENUS_NATIVE
818 wxMenuItem
* const mitem
= FindItemInMenuBar((signed short)id
);
820 return ProcessCommand(mitem
);
823 #endif // wxUSE_MENUS
825 return wxFrameBase::HandleCommand(id
, cmd
, control
);;
831 wxFrame::HandleMenuSelect(WXWORD nItem
, WXWORD flags
, WXHMENU
WXUNUSED(hMenu
))
833 // sign extend to int from unsigned short we get from Windows
834 int item
= (signed short)nItem
;
836 // WM_MENUSELECT is generated for both normal items and menus, including
837 // the top level menus of the menu bar, which can't be represented using
838 // any valid identifier in wxMenuEvent so use an otherwise unused value for
840 if ( flags
& (MF_POPUP
| MF_SEPARATOR
) )
843 wxMenuEvent
event(wxEVT_MENU_HIGHLIGHT
, item
);
844 event
.SetEventObject(this);
846 if ( HandleWindowEvent(event
) )
849 // by default, i.e. if the event wasn't handled above, clear the status bar
850 // text when an item which can't have any associated help string in wx API
852 if ( item
== wxID_NONE
)
853 DoGiveHelp(wxEmptyString
, true);
859 wxFrame::DoSendMenuOpenCloseEvent(wxEventType evtType
, wxMenu
* menu
, bool popup
)
861 wxMenuEvent
event(evtType
, popup
? wxID_ANY
: 0, menu
);
862 event
.SetEventObject(this);
864 return HandleWindowEvent(event
);
867 bool wxFrame::HandleExitMenuLoop(WXWORD isPopup
)
869 return DoSendMenuOpenCloseEvent(wxEVT_MENU_CLOSE
,
870 isPopup
? wxCurrentPopupMenu
: NULL
,
874 bool wxFrame::HandleMenuPopup(wxEventType evtType
, WXHMENU hMenu
)
876 bool isPopup
= false;
878 if ( wxCurrentPopupMenu
&& wxCurrentPopupMenu
->GetHMenu() == hMenu
)
880 menu
= wxCurrentPopupMenu
;
883 else if ( GetMenuBar() )
885 menu
= GetMenuBar()->MSWGetMenu(hMenu
);
889 return DoSendMenuOpenCloseEvent(evtType
, menu
, isPopup
);
892 #endif // wxUSE_MENUS
894 // ---------------------------------------------------------------------------
895 // the window proc for wxFrame
896 // ---------------------------------------------------------------------------
898 WXLRESULT
wxFrame::MSWWindowProc(WXUINT message
, WXWPARAM wParam
, WXLPARAM lParam
)
901 bool processed
= false;
906 // if we can't close, tell the system that we processed the
907 // message - otherwise it would close us
908 processed
= !Close();
912 processed
= HandleSize(LOWORD(lParam
), HIWORD(lParam
), wParam
);
919 UnpackCommand((WXWPARAM
)wParam
, (WXLPARAM
)lParam
,
922 HandleCommand(id
, cmd
, (WXHWND
)hwnd
);
924 // don't pass WM_COMMAND to the base class whether we processed
925 // it or not because we did generate an event for it (our
926 // HandleCommand() calls the base class version) and we must
927 // not do it again or the handlers which skip the event would
933 #if !defined(__WXMICROWIN__) && !defined(__WXWINCE__)
935 case WM_INITMENUPOPUP
:
936 processed
= HandleMenuPopup(wxEVT_MENU_OPEN
, (WXHMENU
)wParam
);
943 UnpackMenuSelect(wParam
, lParam
, &item
, &flags
, &hmenu
);
945 processed
= HandleMenuSelect(item
, flags
, hmenu
);
949 case WM_EXITMENULOOP
:
950 // Under Windows 98 and 2000 and later we're going to get
951 // WM_UNINITMENUPOPUP which will be used to generate this event
952 // with more information (notably the menu that was closed) so we
953 // only need this one under old Windows systems where the newer
954 // event is never sent.
955 if ( wxGetWinVersion() < wxWinVersion_98
)
956 processed
= HandleExitMenuLoop(wParam
);
959 case WM_UNINITMENUPOPUP
:
960 processed
= HandleMenuPopup(wxEVT_MENU_CLOSE
, (WXHMENU
)wParam
);
962 #endif // wxUSE_MENUS
964 case WM_QUERYDRAGICON
:
966 const wxIcon
& icon
= GetIcon();
967 HICON hIcon
= icon
.IsOk() ? GetHiconOf(icon
)
968 : (HICON
)GetDefaultIcon();
969 rc
= (WXLRESULT
)hIcon
;
973 #endif // !__WXMICROWIN__
977 rc
= wxFrameBase::MSWWindowProc(message
, wParam
, lParam
);
982 // ----------------------------------------------------------------------------
983 // wxFrame size management: we exclude the areas taken by menu/status/toolbars
984 // from the client area, so the client area is what's really available for the
986 // ----------------------------------------------------------------------------
988 // get the origin of the client area in the client coordinates
989 wxPoint
wxFrame::GetClientAreaOrigin() const
991 wxPoint pt
= wxTopLevelWindow::GetClientAreaOrigin();
993 #if wxUSE_TOOLBAR && !defined(__WXUNIVERSAL__) && \
994 (!defined(__WXWINCE__) || (_WIN32_WCE >= 400 && !defined(__POCKETPC__) && !defined(__SMARTPHONE__)))
995 wxToolBar
* const toolbar
= GetToolBar();
996 if ( toolbar
&& toolbar
->IsShown() )
998 const wxSize sizeTB
= toolbar
->GetSize();
1000 if ( toolbar
->HasFlag(wxTB_TOP
) )
1004 else if ( toolbar
->HasFlag(wxTB_LEFT
) )
1009 #endif // wxUSE_TOOLBAR
1011 #if defined(WINCE_WITH_COMMANDBAR)
1012 if (GetMenuBar() && GetMenuBar()->GetCommandBar())
1015 ::GetWindowRect((HWND
) GetMenuBar()->GetCommandBar(), &rect
);
1016 pt
.y
+= (rect
.bottom
- rect
.top
);