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 // generate an artificial resize event
243 void wxFrame::SendSizeEvent(int flags
)
247 RECT r
= wxGetWindowRect(GetHwnd());
249 if ( flags
& wxSEND_EVENT_POST
)
251 ::PostMessage(GetHwnd(), WM_SIZE
,
252 IsMaximized() ? SIZE_MAXIMIZED
: SIZE_RESTORED
,
253 MAKELPARAM(r
.right
- r
.left
, r
.bottom
- r
.top
));
257 ::SendMessage(GetHwnd(), WM_SIZE
,
258 IsMaximized() ? SIZE_MAXIMIZED
: SIZE_RESTORED
,
259 MAKELPARAM(r
.right
- r
.left
, r
.bottom
- r
.top
));
265 wxStatusBar
*wxFrame::OnCreateStatusBar(int number
,
268 const wxString
& name
)
270 wxStatusBar
*statusBar
wxDUMMY_INITIALIZE(NULL
);
272 #if wxUSE_NATIVE_STATUSBAR
273 if ( !UsesNativeStatusBar() )
275 statusBar
= (wxStatusBar
*)new wxStatusBarGeneric(this, id
, style
);
280 statusBar
= new wxStatusBar(this, id
, style
, name
);
283 statusBar
->SetFieldsCount(number
);
288 void wxFrame::PositionStatusBar()
290 if ( !m_frameStatusBar
|| !m_frameStatusBar
->IsShown() )
294 GetClientSize(&w
, &h
);
297 m_frameStatusBar
->GetSize(&sw
, &sh
);
301 wxToolBar
* const toolbar
= GetToolBar();
302 if ( toolbar
&& !toolbar
->HasFlag(wxTB_TOP
) )
304 const wxSize sizeTB
= toolbar
->GetSize();
306 if ( toolbar
->HasFlag(wxTB_LEFT
| wxTB_RIGHT
) )
308 if ( toolbar
->HasFlag(wxTB_LEFT
) )
315 // we need to position the status bar below the toolbar
319 //else: no adjustments necessary for the toolbar on top
320 #endif // wxUSE_TOOLBAR
322 // Since we wish the status bar to be directly under the client area,
323 // we use the adjusted sizes without using wxSIZE_NO_ADJUSTMENTS.
324 m_frameStatusBar
->SetSize(x
, h
, w
, sh
);
327 #endif // wxUSE_STATUSBAR
329 #if wxUSE_MENUS_NATIVE
331 void wxFrame::AttachMenuBar(wxMenuBar
*menubar
)
333 #if defined(__SMARTPHONE__) && defined(__WXWINCE__)
335 wxMenu
*autoMenu
= NULL
;
337 if( menubar
->GetMenuCount() == 1 )
339 autoMenu
= wxTopLevelWindowMSW::ButtonMenu::DuplicateMenu(menubar
->GetMenu(0));
340 SetRightMenu(wxID_ANY
, menubar
->GetMenuLabel(0), autoMenu
);
344 autoMenu
= new wxMenu
;
346 for( size_t n
= 0; n
< menubar
->GetMenuCount(); n
++ )
348 wxMenu
*item
= menubar
->GetMenu(n
);
349 wxString label
= menubar
->GetMenuLabel(n
);
350 wxMenu
*new_item
= wxTopLevelWindowMSW::ButtonMenu::DuplicateMenu(item
);
351 autoMenu
->Append(wxID_ANY
, label
, new_item
);
354 SetRightMenu(wxID_ANY
, _("Menu"), autoMenu
);
357 #elif defined(WINCE_WITHOUT_COMMANDBAR)
360 wxToolMenuBar
* toolBar
= new wxToolMenuBar(this, wxID_ANY
,
361 wxDefaultPosition
, wxDefaultSize
,
362 wxBORDER_NONE
| wxTB_HORIZONTAL
,
363 wxToolBarNameStr
, menubar
);
365 menubar
->SetToolBar(toolBar
);
368 // When the main window is created using CW_USEDEFAULT the height of the
369 // menubar is not taken into account, so we resize it afterwards if a
370 // menubar is present
371 HWND hwndMenuBar
= SHFindMenuBar(GetHwnd());
375 ::GetWindowRect(hwndMenuBar
, &mbRect
);
376 const int menuHeight
= mbRect
.bottom
- mbRect
.top
;
379 ::GetWindowRect(GetHwnd(), &rc
);
380 // adjust for menu / titlebar height
381 rc
.bottom
-= (2*menuHeight
-1);
383 ::MoveWindow(GetHwnd(), rc
.left
, rc
.top
, rc
.right
, rc
.bottom
, FALSE
);
387 wxFrameBase::AttachMenuBar(menubar
);
391 // actually remove the menu from the frame
392 m_hMenu
= (WXHMENU
)0;
393 InternalSetMenuBar();
395 else // set new non NULL menu bar
397 #if !defined(__WXWINCE__) || defined(WINCE_WITH_COMMANDBAR)
398 // Can set a menubar several times.
399 if ( menubar
->GetHMenu() )
401 m_hMenu
= menubar
->GetHMenu();
405 m_hMenu
= menubar
->Create();
409 wxFAIL_MSG( wxT("failed to create menu bar") );
414 InternalSetMenuBar();
418 void wxFrame::InternalSetMenuBar()
420 #if defined(__WXMICROWIN__) || defined(__WXWINCE__)
423 if ( !::SetMenu(GetHwnd(), (HMENU
)m_hMenu
) )
425 wxLogLastError(wxT("SetMenu"));
430 #endif // wxUSE_MENUS_NATIVE
432 // Responds to colour changes, and passes event on to children.
433 void wxFrame::OnSysColourChanged(wxSysColourChangedEvent
& event
)
435 // Don't override the colour explicitly set by the user, if any.
438 SetOwnBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_APPWORKSPACE
));
443 if ( m_frameStatusBar
)
445 wxSysColourChangedEvent event2
;
446 event2
.SetEventObject( m_frameStatusBar
);
447 m_frameStatusBar
->HandleWindowEvent(event2
);
449 #endif // wxUSE_STATUSBAR
451 // Propagate the event to the non-top-level children
452 wxWindow::OnSysColourChanged(event
);
455 // Pass true to show full screen, false to restore.
456 bool wxFrame::ShowFullScreen(bool show
, long style
)
458 // TODO-CE: add support for CE
459 #if !defined(__WXMICROWIN__) && !defined(__WXWINCE__)
460 if ( IsFullScreen() == show
)
465 // zap the toolbar, menubar, and statusbar if needed
467 // TODO: hide commandbar for WINCE_WITH_COMMANDBAR
469 wxToolBar
*theToolBar
= GetToolBar();
471 if ((style
& wxFULLSCREEN_NOTOOLBAR
) && theToolBar
)
473 if ( theToolBar
->IsShown() )
475 theToolBar
->SetSize(wxDefaultCoord
,0);
476 theToolBar
->Show(false);
478 else // prevent it from being restored later
480 style
&= ~wxFULLSCREEN_NOTOOLBAR
;
483 #endif // wxUSE_TOOLBAR
485 if (style
& wxFULLSCREEN_NOMENUBAR
)
486 SetMenu((HWND
)GetHWND(), (HMENU
) NULL
);
489 wxStatusBar
*theStatusBar
= GetStatusBar();
491 // Save the number of fields in the statusbar
492 if ((style
& wxFULLSCREEN_NOSTATUSBAR
) && theStatusBar
)
494 if ( theStatusBar
->IsShown() )
495 theStatusBar
->Show(false);
497 style
&= ~wxFULLSCREEN_NOSTATUSBAR
;
499 #endif // wxUSE_STATUSBAR
501 else // restore to normal
503 // restore the toolbar, menubar, and statusbar if we had hid them
505 wxToolBar
*theToolBar
= GetToolBar();
507 if ((m_fsStyle
& wxFULLSCREEN_NOTOOLBAR
) && theToolBar
)
509 theToolBar
->Show(true);
511 #endif // wxUSE_TOOLBAR
514 if (m_fsStyle
& wxFULLSCREEN_NOMENUBAR
)
516 const WXHMENU hmenu
= MSWGetActiveMenu();
518 ::SetMenu(GetHwnd(), (HMENU
)hmenu
);
520 #endif // wxUSE_MENUS
523 wxStatusBar
*theStatusBar
= GetStatusBar();
525 if ((m_fsStyle
& wxFULLSCREEN_NOSTATUSBAR
) && theStatusBar
)
527 theStatusBar
->Show(true);
530 #endif // wxUSE_STATUSBAR
532 #endif // !defined(__WXMICROWIN__) && !defined(__WXWINCE__)
534 return wxFrameBase::ShowFullScreen(show
, style
);
537 // ----------------------------------------------------------------------------
538 // tool/status bar stuff
539 // ----------------------------------------------------------------------------
543 wxToolBar
* wxFrame::CreateToolBar(long style
, wxWindowID id
, const wxString
& name
)
545 #if defined(WINCE_WITHOUT_COMMANDBAR)
546 // We may already have a toolbar from calling SetMenuBar.
550 if ( wxFrameBase::CreateToolBar(style
, id
, name
) )
555 return m_frameToolBar
;
558 void wxFrame::PositionToolBar()
560 // TODO: we want to do something different in WinCE, because the toolbar
561 // should be associated with the commandbar, instead of being
562 // independent window.
563 #if !defined(WINCE_WITHOUT_COMMANDBAR)
564 wxToolBar
*toolbar
= GetToolBar();
565 if ( toolbar
&& toolbar
->IsShown() )
567 // don't call our (or even wxTopLevelWindow) version because we want
568 // the real (full) client area size, not excluding the tool/status bar
570 wxWindow::DoGetClientSize(&width
, &height
);
573 wxStatusBar
*statbar
= GetStatusBar();
574 if ( statbar
&& statbar
->IsShown() )
576 height
-= statbar
->GetClientSize().y
;
578 #endif // wxUSE_STATUSBAR
581 toolbar
->GetPosition( &tx
, &ty
);
582 toolbar
->GetSize( &tw
, &th
);
585 if ( toolbar
->HasFlag(wxTB_BOTTOM
) )
590 else if ( toolbar
->HasFlag(wxTB_RIGHT
) )
601 #if defined(WINCE_WITH_COMMANDBAR)
602 // We're using a commandbar - so we have to allow for it.
603 if (GetMenuBar() && GetMenuBar()->GetCommandBar())
606 ::GetWindowRect((HWND
) GetMenuBar()->GetCommandBar(), &rect
);
607 y
= rect
.bottom
- rect
.top
;
609 #endif // WINCE_WITH_COMMANDBAR
611 if ( toolbar
->HasFlag(wxTB_BOTTOM
) )
613 if ( ty
< 0 && ( -ty
== th
) )
615 if ( tx
< 0 && (-tx
== tw
) )
618 else if ( toolbar
->HasFlag(wxTB_RIGHT
) )
620 if( ty
< 0 && ( -ty
== th
) )
622 if( tx
< 0 && ( -tx
== tw
) )
627 if (ty
< 0 && (-ty
== th
))
629 if (tx
< 0 && (-tx
== tw
))
636 if ( toolbar
->IsVertical() )
647 // use the 'real' MSW position here, don't offset relatively to the
648 // client area origin
649 toolbar
->SetSize(x
, y
, desiredW
, desiredH
, wxSIZE_NO_ADJUSTMENTS
);
652 #endif // !WINCE_WITH_COMMANDBAR
655 #endif // wxUSE_TOOLBAR
657 // ----------------------------------------------------------------------------
658 // frame state (iconized/maximized/...)
659 // ----------------------------------------------------------------------------
661 // propagate our state change to all child frames: this allows us to emulate X
662 // Windows behaviour where child frames float independently of the parent one
663 // on the desktop, but are iconized/restored with it
664 void wxFrame::IconizeChildFrames(bool bIconize
)
666 m_iconized
= bIconize
;
668 for ( wxWindowList::compatibility_iterator node
= GetChildren().GetFirst();
670 node
= node
->GetNext() )
672 wxWindow
*win
= node
->GetData();
674 // iconizing the frames with this style under Win95 shell puts them at
675 // the bottom of the screen (as the MDI children) instead of making
676 // them appear in the taskbar because they are, by virtue of this
677 // style, not managed by the taskbar - instead leave Windows take care
679 if ( win
->GetWindowStyle() & wxFRAME_TOOL_WINDOW
)
682 // the child MDI frames are a special case and should not be touched by
683 // the parent frame - instead, they are managed by the user
684 wxFrame
*frame
= wxDynamicCast(win
, wxFrame
);
686 #if wxUSE_MDI_ARCHITECTURE
687 && !frame
->IsMDIChild()
688 #endif // wxUSE_MDI_ARCHITECTURE
691 // we don't want to restore the child frames which had been
692 // iconized even before we were iconized, so save the child frame
693 // status when iconizing the parent frame and check it when
697 frame
->m_wasMinimized
= frame
->IsIconized();
700 // note that we shouldn't touch the hidden frames neither because
701 // iconizing/restoring them would show them as a side effect
702 if ( !frame
->m_wasMinimized
&& frame
->IsShown() )
703 frame
->Iconize(bIconize
);
708 WXHICON
wxFrame::GetDefaultIcon() const
710 // we don't have any standard icons (any more)
714 // ===========================================================================
715 // message processing
716 // ===========================================================================
718 // ---------------------------------------------------------------------------
720 // ---------------------------------------------------------------------------
722 bool wxFrame::MSWDoTranslateMessage(wxFrame
*frame
, WXMSG
*pMsg
)
724 if ( wxWindow::MSWTranslateMessage(pMsg
) )
727 #if wxUSE_MENUS && wxUSE_ACCEL && !defined(__WXUNIVERSAL__)
728 // try the menu bar accelerators
729 wxMenuBar
*menuBar
= GetMenuBar();
730 if ( menuBar
&& menuBar
->GetAcceleratorTable()->Translate(frame
, pMsg
) )
732 #endif // wxUSE_MENUS && wxUSE_ACCEL
737 // ---------------------------------------------------------------------------
738 // our private (non virtual) message handlers
739 // ---------------------------------------------------------------------------
741 bool wxFrame::HandleSize(int WXUNUSED(x
), int WXUNUSED(y
), WXUINT id
)
743 #if !defined(__WXMICROWIN__) && !defined(__WXWINCE__)
748 // only do it it if we were iconized before, otherwise resizing the
749 // parent frame has a curious side effect of bringing it under it's
754 // restore all child frames too
755 IconizeChildFrames(false);
757 (void)SendIconizeEvent(false);
761 // iconize all child frames too
762 IconizeChildFrames(true);
767 #endif // !__WXWINCE__
773 #endif // wxUSE_STATUSBAR
777 #endif // wxUSE_TOOLBAR
779 #if defined(WINCE_WITH_COMMANDBAR)
780 // Position the menu command bar
781 if (GetMenuBar() && GetMenuBar()->GetCommandBar())
784 ::GetWindowRect((HWND
) GetMenuBar()->GetCommandBar(), &rect
);
785 wxSize clientSz
= GetClientSize();
787 if ( !::MoveWindow((HWND
) GetMenuBar()->GetCommandBar(), 0, 0, clientSz
.x
, rect
.bottom
- rect
.top
, true ) )
789 wxLogLastError(wxT("MoveWindow"));
793 #endif // WINCE_WITH_COMMANDBAR
796 // call the base class version to generate the appropriate events
800 bool wxFrame::HandleCommand(WXWORD id
, WXWORD cmd
, WXHWND control
)
804 #if defined(WINCE_WITHOUT_COMMANDBAR)
805 if (GetToolBar() && GetToolBar()->FindById(id
))
806 return GetToolBar()->MSWCommand(cmd
, id
);
809 // we only need to handle the menu and accelerator commands from the items
810 // of our menu bar, base wxWindow class already handles the rest
811 if ( !control
&& (cmd
== 0 /* menu */ || cmd
== 1 /* accel */) )
813 #if wxUSE_MENUS_NATIVE
814 if ( !wxCurrentPopupMenu
)
815 #endif // wxUSE_MENUS_NATIVE
817 wxMenuItem
* const mitem
= FindItemInMenuBar((signed short)id
);
819 return ProcessCommand(mitem
);
822 #endif // wxUSE_MENUS
824 return wxFrameBase::HandleCommand(id
, cmd
, control
);;
830 wxFrame::HandleMenuSelect(WXWORD nItem
, WXWORD flags
, WXHMENU
WXUNUSED(hMenu
))
832 // sign extend to int from unsigned short we get from Windows
833 int item
= (signed short)nItem
;
835 // WM_MENUSELECT is generated for both normal items and menus, including
836 // the top level menus of the menu bar, which can't be represented using
837 // any valid identifier in wxMenuEvent so use an otherwise unused value for
839 if ( flags
& (MF_POPUP
| MF_SEPARATOR
) )
842 wxMenuEvent
event(wxEVT_MENU_HIGHLIGHT
, item
);
843 event
.SetEventObject(this);
845 if ( HandleWindowEvent(event
) )
848 // by default, i.e. if the event wasn't handled above, clear the status bar
849 // text when an item which can't have any associated help string in wx API
851 if ( item
== wxID_NONE
)
852 DoGiveHelp(wxEmptyString
, true);
858 wxFrame::DoSendMenuOpenCloseEvent(wxEventType evtType
, wxMenu
* menu
, bool popup
)
860 wxMenuEvent
event(evtType
, popup
? wxID_ANY
: 0, menu
);
861 event
.SetEventObject(menu
);
863 return HandleWindowEvent(event
);
866 bool wxFrame::HandleExitMenuLoop(WXWORD isPopup
)
868 return DoSendMenuOpenCloseEvent(wxEVT_MENU_CLOSE
,
869 isPopup
? wxCurrentPopupMenu
: NULL
,
873 bool wxFrame::HandleMenuPopup(wxEventType evtType
, WXHMENU hMenu
)
875 bool isPopup
= false;
877 if ( wxCurrentPopupMenu
&& wxCurrentPopupMenu
->GetHMenu() == hMenu
)
879 menu
= wxCurrentPopupMenu
;
882 else if ( GetMenuBar() )
884 menu
= GetMenuBar()->MSWGetMenu(hMenu
);
888 return DoSendMenuOpenCloseEvent(evtType
, menu
, isPopup
);
891 #endif // wxUSE_MENUS
893 // ---------------------------------------------------------------------------
894 // the window proc for wxFrame
895 // ---------------------------------------------------------------------------
897 WXLRESULT
wxFrame::MSWWindowProc(WXUINT message
, WXWPARAM wParam
, WXLPARAM lParam
)
900 bool processed
= false;
905 // if we can't close, tell the system that we processed the
906 // message - otherwise it would close us
907 processed
= !Close();
911 processed
= HandleSize(LOWORD(lParam
), HIWORD(lParam
), wParam
);
918 UnpackCommand((WXWPARAM
)wParam
, (WXLPARAM
)lParam
,
921 HandleCommand(id
, cmd
, (WXHWND
)hwnd
);
923 // don't pass WM_COMMAND to the base class whether we processed
924 // it or not because we did generate an event for it (our
925 // HandleCommand() calls the base class version) and we must
926 // not do it again or the handlers which skip the event would
932 #if !defined(__WXMICROWIN__) && !defined(__WXWINCE__)
934 case WM_INITMENUPOPUP
:
935 processed
= HandleMenuPopup(wxEVT_MENU_OPEN
, (WXHMENU
)wParam
);
942 UnpackMenuSelect(wParam
, lParam
, &item
, &flags
, &hmenu
);
944 processed
= HandleMenuSelect(item
, flags
, hmenu
);
948 case WM_EXITMENULOOP
:
949 // Under Windows 98 and 2000 and later we're going to get
950 // WM_UNINITMENUPOPUP which will be used to generate this event
951 // with more information (notably the menu that was closed) so we
952 // only need this one under old Windows systems where the newer
953 // event is never sent.
954 if ( wxGetWinVersion() < wxWinVersion_98
)
955 processed
= HandleExitMenuLoop(wParam
);
958 case WM_UNINITMENUPOPUP
:
959 processed
= HandleMenuPopup(wxEVT_MENU_CLOSE
, (WXHMENU
)wParam
);
961 #endif // wxUSE_MENUS
963 case WM_QUERYDRAGICON
:
965 const wxIcon
& icon
= GetIcon();
966 HICON hIcon
= icon
.IsOk() ? GetHiconOf(icon
)
967 : (HICON
)GetDefaultIcon();
968 rc
= (WXLRESULT
)hIcon
;
972 #endif // !__WXMICROWIN__
976 rc
= wxFrameBase::MSWWindowProc(message
, wParam
, lParam
);
981 // ----------------------------------------------------------------------------
982 // wxFrame size management: we exclude the areas taken by menu/status/toolbars
983 // from the client area, so the client area is what's really available for the
985 // ----------------------------------------------------------------------------
987 // get the origin of the client area in the client coordinates
988 wxPoint
wxFrame::GetClientAreaOrigin() const
990 wxPoint pt
= wxTopLevelWindow::GetClientAreaOrigin();
992 #if wxUSE_TOOLBAR && !defined(__WXUNIVERSAL__) && \
993 (!defined(__WXWINCE__) || (_WIN32_WCE >= 400 && !defined(__POCKETPC__) && !defined(__SMARTPHONE__)))
994 wxToolBar
* const toolbar
= GetToolBar();
995 if ( toolbar
&& toolbar
->IsShown() )
997 const wxSize sizeTB
= toolbar
->GetSize();
999 if ( toolbar
->HasFlag(wxTB_TOP
) )
1003 else if ( toolbar
->HasFlag(wxTB_LEFT
) )
1008 #endif // wxUSE_TOOLBAR
1010 #if defined(WINCE_WITH_COMMANDBAR)
1011 if (GetMenuBar() && GetMenuBar()->GetCommandBar())
1014 ::GetWindowRect((HWND
) GetMenuBar()->GetCommandBar(), &rect
);
1015 pt
.y
+= (rect
.bottom
- rect
.top
);