1 ///////////////////////////////////////////////////////////////////////////// 
   4 // Author:      Julian Smart 
   8 // Copyright:   (c) Julian Smart 
   9 // Licence:     wxWindows licence 
  10 ///////////////////////////////////////////////////////////////////////////// 
  12 // ============================================================================ 
  14 // ============================================================================ 
  16 // ---------------------------------------------------------------------------- 
  18 // ---------------------------------------------------------------------------- 
  20 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) 
  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" 
  50     #include "wx/statusbr.h" 
  51     #include "wx/generic/statusbr.h" 
  52 #endif // wxUSE_STATUSBAR 
  55     #include "wx/toolbar.h" 
  56 #endif // wxUSE_TOOLBAR 
  58 #include "wx/menuitem.h" 
  61 #ifdef __WXUNIVERSAL__ 
  62     #include "wx/univ/theme.h" 
  63     #include "wx/univ/colschem.h" 
  64 #endif // __WXUNIVERSAL__ 
  66 // ---------------------------------------------------------------------------- 
  68 // ---------------------------------------------------------------------------- 
  70 #if wxUSE_MENUS_NATIVE 
  71     extern wxMenu 
*wxCurrentPopupMenu
; 
  72 #endif // wxUSE_MENUS_NATIVE 
  74 // ---------------------------------------------------------------------------- 
  76 // ---------------------------------------------------------------------------- 
  78 BEGIN_EVENT_TABLE(wxFrame
, wxFrameBase
) 
  79     EVT_SYS_COLOUR_CHANGED(wxFrame::OnSysColourChanged
) 
  82 #if wxUSE_EXTENDED_RTTI 
  83 WX_DEFINE_FLAGS( wxFrameStyle 
) 
  85 wxBEGIN_FLAGS( wxFrameStyle 
) 
  86     // new style border flags, we put them first to 
  87     // use them for streaming out 
  88     wxFLAGS_MEMBER(wxBORDER_SIMPLE
) 
  89     wxFLAGS_MEMBER(wxBORDER_SUNKEN
) 
  90     wxFLAGS_MEMBER(wxBORDER_DOUBLE
) 
  91     wxFLAGS_MEMBER(wxBORDER_RAISED
) 
  92     wxFLAGS_MEMBER(wxBORDER_STATIC
) 
  93     wxFLAGS_MEMBER(wxBORDER_NONE
) 
  95     // old style border flags 
  96     wxFLAGS_MEMBER(wxSIMPLE_BORDER
) 
  97     wxFLAGS_MEMBER(wxSUNKEN_BORDER
) 
  98     wxFLAGS_MEMBER(wxDOUBLE_BORDER
) 
  99     wxFLAGS_MEMBER(wxRAISED_BORDER
) 
 100     wxFLAGS_MEMBER(wxSTATIC_BORDER
) 
 101     wxFLAGS_MEMBER(wxBORDER
) 
 103     // standard window styles 
 104     wxFLAGS_MEMBER(wxTAB_TRAVERSAL
) 
 105     wxFLAGS_MEMBER(wxCLIP_CHILDREN
) 
 106     wxFLAGS_MEMBER(wxTRANSPARENT_WINDOW
) 
 107     wxFLAGS_MEMBER(wxWANTS_CHARS
) 
 108     wxFLAGS_MEMBER(wxFULL_REPAINT_ON_RESIZE
) 
 109     wxFLAGS_MEMBER(wxALWAYS_SHOW_SB 
) 
 110     wxFLAGS_MEMBER(wxVSCROLL
) 
 111     wxFLAGS_MEMBER(wxHSCROLL
) 
 114     wxFLAGS_MEMBER(wxSTAY_ON_TOP
) 
 115     wxFLAGS_MEMBER(wxCAPTION
) 
 116     wxFLAGS_MEMBER(wxTHICK_FRAME
) 
 117     wxFLAGS_MEMBER(wxSYSTEM_MENU
) 
 118     wxFLAGS_MEMBER(wxRESIZE_BORDER
) 
 119     wxFLAGS_MEMBER(wxRESIZE_BOX
) 
 120     wxFLAGS_MEMBER(wxCLOSE_BOX
) 
 121     wxFLAGS_MEMBER(wxMAXIMIZE_BOX
) 
 122     wxFLAGS_MEMBER(wxMINIMIZE_BOX
) 
 124     wxFLAGS_MEMBER(wxFRAME_TOOL_WINDOW
) 
 125     wxFLAGS_MEMBER(wxFRAME_FLOAT_ON_PARENT
) 
 127     wxFLAGS_MEMBER(wxFRAME_SHAPED
) 
 129 wxEND_FLAGS( wxFrameStyle 
) 
 131 IMPLEMENT_DYNAMIC_CLASS_XTI(wxFrame
, wxTopLevelWindow
,"wx/frame.h") 
 133 wxBEGIN_PROPERTIES_TABLE(wxFrame
) 
 134         wxEVENT_PROPERTY( Menu 
, wxEVT_COMMAND_MENU_SELECTED 
, wxCommandEvent
) 
 136     wxPROPERTY( Title
,wxString
, SetTitle
, GetTitle
, wxString() , 0 /*flags*/ , wxT("Helpstring") , wxT("group")) 
 137     wxPROPERTY_FLAGS( WindowStyle 
, wxFrameStyle 
, long , SetWindowStyleFlag 
, GetWindowStyleFlag 
, EMPTY_MACROVALUE 
, 0 /*flags*/ , wxT("Helpstring") , wxT("group")) // style 
 138     wxPROPERTY( MenuBar 
, wxMenuBar 
* , SetMenuBar 
, GetMenuBar 
, EMPTY_MACROVALUE 
, 0 /*flags*/ , wxT("Helpstring") , wxT("group")) 
 139 wxEND_PROPERTIES_TABLE() 
 141 wxBEGIN_HANDLERS_TABLE(wxFrame
) 
 142 wxEND_HANDLERS_TABLE() 
 144 wxCONSTRUCTOR_6( wxFrame 
, wxWindow
* , Parent 
, wxWindowID 
, Id 
, wxString 
, Title 
, wxPoint 
, Position 
, wxSize 
, Size 
, long , WindowStyle
)  
 147 IMPLEMENT_DYNAMIC_CLASS(wxFrame
, wxTopLevelWindow
) 
 150 // ============================================================================ 
 152 // ============================================================================ 
 154 // ---------------------------------------------------------------------------- 
 155 // static class members 
 156 // ---------------------------------------------------------------------------- 
 159     #if wxUSE_NATIVE_STATUSBAR 
 160         bool wxFrame::m_useNativeStatusBar 
= TRUE
; 
 162         bool wxFrame::m_useNativeStatusBar 
= FALSE
; 
 164 #endif // wxUSE_NATIVE_STATUSBAR 
 166 // ---------------------------------------------------------------------------- 
 167 // creation/destruction 
 168 // ---------------------------------------------------------------------------- 
 176     // Data to save/restore when calling ShowFullScreen 
 177     m_fsStatusBarFields 
= 0; 
 178     m_fsStatusBarHeight 
= 0; 
 179     m_fsToolBarHeight 
= 0; 
 181     m_wasMinimized 
= FALSE
; 
 184 bool wxFrame::Create(wxWindow 
*parent
, 
 186                      const wxString
& title
, 
 190                      const wxString
& name
) 
 192     if ( !wxTopLevelWindow::Create(parent
, id
, title
, pos
, size
, style
, name
) ) 
 195     SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_APPWORKSPACE
)); 
 202     m_isBeingDeleted 
= TRUE
; 
 206 // ---------------------------------------------------------------------------- 
 207 // wxFrame client size calculations 
 208 // ---------------------------------------------------------------------------- 
 210 void wxFrame::DoSetClientSize(int width
, int height
) 
 212     // leave enough space for the status bar if we have (and show) it 
 214     wxStatusBar 
*statbar 
= GetStatusBar(); 
 215     if ( statbar 
&& statbar
->IsShown() ) 
 217         height 
+= statbar
->GetSize().y
; 
 219 #endif // wxUSE_STATUSBAR 
 221     // call GetClientAreaOrigin() to take the toolbar into account 
 222     wxPoint pt 
= GetClientAreaOrigin(); 
 226     wxTopLevelWindow::DoSetClientSize(width
, height
); 
 229 // Get size *available for subwindows* i.e. excluding menu bar, toolbar etc. 
 230 void wxFrame::DoGetClientSize(int *x
, int *y
) const 
 232     wxTopLevelWindow::DoGetClientSize(x
, y
); 
 234     // account for the possible toolbar 
 235     wxPoint pt 
= GetClientAreaOrigin(); 
 243     // adjust client area height to take the status bar into account 
 246         wxStatusBar 
*statbar 
= GetStatusBar(); 
 247         if ( statbar 
&& statbar
->IsShown() ) 
 249             *y 
-= statbar
->GetClientSize().y
; 
 252 #endif // wxUSE_STATUSBAR 
 255 // ---------------------------------------------------------------------------- 
 256 // wxFrame: various geometry-related functions 
 257 // ---------------------------------------------------------------------------- 
 259 void wxFrame::Raise() 
 261     ::SetForegroundWindow(GetHwnd()); 
 264 // generate an artificial resize event 
 265 void wxFrame::SendSizeEvent() 
 269         RECT r 
= wxGetWindowRect(GetHwnd()); 
 271         (void)::PostMessage(GetHwnd(), WM_SIZE
, 
 272                             IsMaximized() ? SIZE_MAXIMIZED 
: SIZE_RESTORED
, 
 273                             MAKELPARAM(r
.right 
- r
.left
, r
.bottom 
- r
.top
)); 
 278 wxStatusBar 
*wxFrame::OnCreateStatusBar(int number
, 
 281                                         const wxString
& name
) 
 283     wxStatusBar 
*statusBar 
= NULL
; 
 285 #if wxUSE_NATIVE_STATUSBAR 
 286     if ( !UsesNativeStatusBar() ) 
 288         statusBar 
= (wxStatusBar 
*)new wxStatusBarGeneric(this, id
, style
); 
 293         statusBar 
= new wxStatusBar(this, id
, style
, name
); 
 296     statusBar
->SetFieldsCount(number
); 
 301 void wxFrame::PositionStatusBar() 
 303     if ( !m_frameStatusBar 
|| !m_frameStatusBar
->IsShown() ) 
 307     GetClientSize(&w
, &h
); 
 309     m_frameStatusBar
->GetSize(&sw
, &sh
); 
 311     // Since we wish the status bar to be directly under the client area, 
 312     // we use the adjusted sizes without using wxSIZE_NO_ADJUSTMENTS. 
 313     m_frameStatusBar
->SetSize(0, h
, w
, sh
); 
 315 #endif // wxUSE_STATUSBAR 
 317 #if wxUSE_MENUS_NATIVE 
 319 void wxFrame::AttachMenuBar(wxMenuBar 
*menubar
) 
 321 #if defined(__WXWINCE__) && (_WIN32_WCE < 400 || defined(__POCKETPC__) || defined(__SMARTPHONE__)) 
 324         wxToolBar
* toolBar 
= new wxToolBar(this, -1, 
 325                          wxDefaultPosition
, wxDefaultSize
, 
 326                          wxBORDER_NONE 
| wxTB_HORIZONTAL
, 
 327                          wxToolBarNameStr
, menubar
); 
 329         menubar
->SetToolBar(toolBar
); 
 331         // Now adjust size for menu bar 
 334         //When the main window is created using CW_USEDEFAULT the height of the 
 335         // is created is not taken into account). So we resize the window after 
 336         // if a menubar is present 
 339                 ::GetWindowRect((HWND
) GetHWND(), &rc
); 
 340                 // adjust for menu / titlebar height 
 341                 rc
.bottom 
-= (2*menuHeight
-1); 
 343                 MoveWindow((HWND
) GetHWND(), rc
.left
, rc
.top
, rc
.right
, rc
.bottom
, FALSE
); 
 347     wxFrameBase::AttachMenuBar(menubar
); 
 351         // actually remove the menu from the frame 
 352         m_hMenu 
= (WXHMENU
)0; 
 353         InternalSetMenuBar(); 
 355     else // set new non NULL menu bar 
 357 #if !defined(__WXWINCE__) || (_WIN32_WCE >= 400 && !defined(__POCKETPC__) && !defined(__SMARTPHONE__)) 
 358         // Can set a menubar several times. 
 359         if ( menubar
->GetHMenu() ) 
 361             m_hMenu 
= menubar
->GetHMenu(); 
 365             m_hMenu 
= menubar
->Create(); 
 369                 wxFAIL_MSG( _T("failed to create menu bar") ); 
 374         InternalSetMenuBar(); 
 378 void wxFrame::InternalSetMenuBar() 
 380 #if defined(__WXMICROWIN__) || defined(__WXWINCE__) 
 383     if ( !::SetMenu(GetHwnd(), (HMENU
)m_hMenu
) ) 
 385         wxLogLastError(wxT("SetMenu")); 
 390 #endif // wxUSE_MENUS_NATIVE 
 392 // Responds to colour changes, and passes event on to children. 
 393 void wxFrame::OnSysColourChanged(wxSysColourChangedEvent
& event
) 
 395     SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_APPWORKSPACE
)); 
 399     if ( m_frameStatusBar 
) 
 401         wxSysColourChangedEvent event2
; 
 402         event2
.SetEventObject( m_frameStatusBar 
); 
 403         m_frameStatusBar
->GetEventHandler()->ProcessEvent(event2
); 
 405 #endif // wxUSE_STATUSBAR 
 407     // Propagate the event to the non-top-level children 
 408     wxWindow::OnSysColourChanged(event
); 
 411 // Pass TRUE to show full screen, FALSE to restore. 
 412 bool wxFrame::ShowFullScreen(bool show
, long style
) 
 414     if ( IsFullScreen() == show 
) 
 420 #if defined(__WXWINCE__) && (_WIN32_WCE < 400 || defined(__POCKETPC__) || defined(__SMARTPHONE__)) 
 421         // TODO: hide commandbar 
 423         wxToolBar 
*theToolBar 
= GetToolBar(); 
 425             theToolBar
->GetSize(NULL
, &m_fsToolBarHeight
); 
 427         // zap the toolbar, menubar, and statusbar 
 429         if ((style 
& wxFULLSCREEN_NOTOOLBAR
) && theToolBar
) 
 431             theToolBar
->SetSize(-1,0); 
 432             theToolBar
->Show(FALSE
); 
 434 #endif // __WXWINCE__ 
 435 #endif // wxUSE_TOOLBAR 
 437 #if defined(__WXMICROWIN__) 
 438 #elif defined(__WXWINCE__) 
 439         // TODO: make it work for WinCE 
 441         if (style 
& wxFULLSCREEN_NOMENUBAR
) 
 442             SetMenu((HWND
)GetHWND(), (HMENU
) NULL
); 
 446         wxStatusBar 
*theStatusBar 
= GetStatusBar(); 
 448             theStatusBar
->GetSize(NULL
, &m_fsStatusBarHeight
); 
 450         // Save the number of fields in the statusbar 
 451         if ((style 
& wxFULLSCREEN_NOSTATUSBAR
) && theStatusBar
) 
 453             //m_fsStatusBarFields = theStatusBar->GetFieldsCount(); 
 454             //SetStatusBar((wxStatusBar*) NULL); 
 455             //delete theStatusBar; 
 456             theStatusBar
->Show(FALSE
); 
 459             m_fsStatusBarFields 
= 0; 
 460 #endif // wxUSE_STATUSBAR 
 465 #if defined(__WXWINCE__) && (_WIN32_WCE < 400 || defined(__POCKETPC__) || defined(__SMARTPHONE__)) 
 466         // TODO: show commandbar 
 468         wxToolBar 
*theToolBar 
= GetToolBar(); 
 470         // restore the toolbar, menubar, and statusbar 
 471         if (theToolBar 
&& (m_fsStyle 
& wxFULLSCREEN_NOTOOLBAR
)) 
 473             theToolBar
->SetSize(-1, m_fsToolBarHeight
); 
 474             theToolBar
->Show(TRUE
); 
 476 #endif // __WXWINCE__ 
 477 #endif // wxUSE_TOOLBAR 
 480         if ( m_fsStyle 
& wxFULLSCREEN_NOSTATUSBAR 
) 
 482             //CreateStatusBar(m_fsStatusBarFields); 
 485                 GetStatusBar()->Show(TRUE
); 
 489 #endif // wxUSE_STATUSBAR 
 491 #if defined(__WXMICROWIN__) 
 492 #elif defined(__WXWINCE__) 
 493         // TODO: make it work for WinCE 
 495         if ((m_fsStyle 
& wxFULLSCREEN_NOMENUBAR
) && (m_hMenu 
!= 0)) 
 496             SetMenu((HWND
)GetHWND(), (HMENU
)m_hMenu
); 
 500     return wxFrameBase::ShowFullScreen(show
, style
); 
 503 // ---------------------------------------------------------------------------- 
 504 // tool/status bar stuff 
 505 // ---------------------------------------------------------------------------- 
 509 wxToolBar
* wxFrame::CreateToolBar(long style
, wxWindowID id
, const wxString
& name
) 
 511 #if defined(__WXWINCE__) && (_WIN32_WCE < 400 || defined(__POCKETPC__) || defined(__SMARTPHONE__)) 
 512     // We may already have a toolbar from calling SetMenuBar. 
 516     if ( wxFrameBase::CreateToolBar(style
, id
, name
) ) 
 521     return m_frameToolBar
; 
 524 void wxFrame::PositionToolBar() 
 526     wxToolBar 
*toolbar 
= GetToolBar(); 
 527     if ( toolbar 
&& toolbar
->IsShown() ) 
 529 #if defined(__WXWINCE__) && (_WIN32_WCE < 400 || defined(__POCKETPC__) || defined(__SMARTPHONE__)) 
 530         // We want to do something different in WinCE, because 
 531         // the toolbar should be associated with the commandbar, 
 532         // and not an independent window. 
 535         // don't call our (or even wxTopLevelWindow) version because we want 
 536         // the real (full) client area size, not excluding the tool/status bar 
 538         wxWindow::DoGetClientSize(&width
, &height
); 
 541         wxStatusBar 
*statbar 
= GetStatusBar(); 
 542         if ( statbar 
&& statbar
->IsShown() ) 
 544             height 
-= statbar
->GetClientSize().y
; 
 546 #endif // wxUSE_STATUSBAR 
 550 #if defined(__WXWINCE__) 
 551                 // We're using a commandbar - so we have to allow for it. 
 552                 if (GetMenuBar() && GetMenuBar()->GetCommandBar()) 
 555                         ::GetWindowRect((HWND
) GetMenuBar()->GetCommandBar(), &rect
); 
 556                         y 
= rect
.bottom 
- rect
.top
; 
 562         toolbar
->GetPosition(&tx
, &ty
); 
 563         toolbar
->GetSize(&tw
, &th
); 
 566         if (ty 
< 0 && (-ty 
== th
)) 
 568         if (tx 
< 0 && (-tx 
== tw
)) 
 574         if ( toolbar
->GetWindowStyleFlag() & wxTB_VERTICAL 
) 
 581 //            if ( toolbar->GetWindowStyleFlag() & wxTB_FLAT ) 
 585         // use the 'real' MSW position here, don't offset relativly to the 
 586         // client area origin 
 588         // Optimise such that we don't have to always resize the toolbar 
 589         // when the frame changes, otherwise we'll get a lot of flicker.         
 590         bool heightChanging 
= TRUE
; 
 591         bool widthChanging 
= TRUE
; 
 593         if ( toolbar
->GetWindowStyleFlag() & wxTB_VERTICAL 
) 
 595             // It's OK if the current height is greater than what can be shown. 
 596             heightChanging 
= (desiredH 
> th
) ; 
 597             widthChanging 
= (desiredW 
!= tw
) ; 
 599             // The next time around, we may not have to set the size             
 601                 desiredH 
= desiredH 
+ 200; 
 605             // It's OK if the current width is greater than what can be shown. 
 606             widthChanging 
= (desiredW 
> tw
) ; 
 607             heightChanging 
= (desiredH 
!= th
) ; 
 609             // The next time around, we may not have to set the size             
 611                 desiredW 
= desiredW 
+ 200; 
 614         if (tx 
!= 0 || ty 
!= 0 || widthChanging 
|| heightChanging
) 
 615             toolbar
->SetSize(x
, y
, desiredW
, desiredH
, wxSIZE_NO_ADJUSTMENTS
); 
 617 #endif // __WXWINCE__ 
 621 #endif // wxUSE_TOOLBAR 
 623 // ---------------------------------------------------------------------------- 
 624 // frame state (iconized/maximized/...) 
 625 // ---------------------------------------------------------------------------- 
 627 // propagate our state change to all child frames: this allows us to emulate X 
 628 // Windows behaviour where child frames float independently of the parent one 
 629 // on the desktop, but are iconized/restored with it 
 630 void wxFrame::IconizeChildFrames(bool bIconize
) 
 632     for ( wxWindowList::compatibility_iterator node 
= GetChildren().GetFirst(); 
 634           node 
= node
->GetNext() ) 
 636         wxWindow 
*win 
= node
->GetData(); 
 638         // iconizing the frames with this style under Win95 shell puts them at 
 639         // the bottom of the screen (as the MDI children) instead of making 
 640         // them appear in the taskbar because they are, by virtue of this 
 641         // style, not managed by the taskbar - instead leave Windows take care 
 644         if ( win
->GetWindowStyle() & wxFRAME_TOOL_WINDOW 
) 
 648         // the child MDI frames are a special case and should not be touched by 
 649         // the parent frame - instead, they are managed by the user 
 650         wxFrame 
*frame 
= wxDynamicCast(win
, wxFrame
); 
 652 #if wxUSE_MDI_ARCHITECTURE 
 653                 && !wxDynamicCast(frame
, wxMDIChildFrame
) 
 654 #endif // wxUSE_MDI_ARCHITECTURE 
 657             // we don't want to restore the child frames which had been 
 658             // iconized even before we were iconized, so save the child frame 
 659             // status when iconizing the parent frame and check it when 
 663                 frame
->m_wasMinimized 
= frame
->IsIconized(); 
 666             // note that we shouldn't touch the hidden frames neither because 
 667             // iconizing/restoring them would show them as a side effect 
 668             if ( !frame
->m_wasMinimized 
&& frame
->IsShown() ) 
 669                 frame
->Iconize(bIconize
); 
 674 WXHICON 
wxFrame::GetDefaultIcon() const 
 676     // we don't have any standard icons (any more) 
 680 // =========================================================================== 
 681 // message processing 
 682 // =========================================================================== 
 684 // --------------------------------------------------------------------------- 
 686 // --------------------------------------------------------------------------- 
 688 bool wxFrame::MSWTranslateMessage(WXMSG
* pMsg
) 
 690     if ( wxWindow::MSWTranslateMessage(pMsg
) ) 
 693 #if wxUSE_MENUS && wxUSE_ACCEL && !defined(__WXUNIVERSAL__) 
 694     // try the menu bar accels 
 695     wxMenuBar 
*menuBar 
= GetMenuBar(); 
 699     const wxAcceleratorTable
& acceleratorTable 
= menuBar
->GetAccelTable(); 
 700     return acceleratorTable
.Translate(this, pMsg
); 
 703 #endif // wxUSE_MENUS && wxUSE_ACCEL 
 706 // --------------------------------------------------------------------------- 
 707 // our private (non virtual) message handlers 
 708 // --------------------------------------------------------------------------- 
 710 bool wxFrame::HandlePaint() 
 713     if ( GetUpdateRect(GetHwnd(), &rect
, FALSE
) ) 
 715 #if !defined(__WXMICROWIN__) && !defined(__WXWINCE__) 
 718             const wxIcon
& icon 
= GetIcon(); 
 719             HICON hIcon 
= icon
.Ok() ? GetHiconOf(icon
) 
 720                                     : (HICON
)GetDefaultIcon(); 
 722             // Hold a pointer to the dc so long as the OnPaint() message 
 723             // is being processed 
 725             HDC hdc 
= ::BeginPaint(GetHwnd(), &ps
); 
 727             // Erase background before painting or we get white background 
 728             MSWDefWindowProc(WM_ICONERASEBKGND
, (WORD
)(LONG
)ps
.hdc
, 0L); 
 733                 ::GetClientRect(GetHwnd(), &rect
); 
 735                 // FIXME: why hardcoded? 
 736                 static const int icon_width 
= 32; 
 737                 static const int icon_height 
= 32; 
 739                 int icon_x 
= (int)((rect
.right 
- icon_width
)/2); 
 740                 int icon_y 
= (int)((rect
.bottom 
- icon_height
)/2); 
 742                 ::DrawIcon(hdc
, icon_x
, icon_y
, hIcon
); 
 745             ::EndPaint(GetHwnd(), &ps
); 
 752             return wxWindow::HandlePaint(); 
 757         // nothing to paint - processed 
 762 bool wxFrame::HandleSize(int x
, int y
, WXUINT id
) 
 764     bool processed 
= FALSE
; 
 765 #if !defined(__WXMICROWIN__) && !defined(__WXWINCE__) 
 770             // only do it it if we were iconized before, otherwise resizing the 
 771             // parent frame has a curious side effect of bringing it under it's 
 776             // restore all child frames too 
 777             IconizeChildFrames(FALSE
); 
 779             (void)SendIconizeEvent(FALSE
); 
 788             // iconize all child frames too 
 789             IconizeChildFrames(TRUE
); 
 791             (void)SendIconizeEvent(); 
 802 #endif // wxUSE_STATUSBAR 
 806 #endif // wxUSE_TOOLBAR 
 808 #if defined(__WXWINCE__) && (_WIN32_WCE >= 400 && !defined(__POCKETPC__) && !defined(__SMARTPHONE__)) 
 809                 // Position the menu command bar 
 810                 if (GetMenuBar() && GetMenuBar()->GetCommandBar()) 
 813                         ::GetWindowRect((HWND
) GetMenuBar()->GetCommandBar(), &rect
); 
 814                         wxSize clientSz 
= GetClientSize(); 
 816                         if ( !::MoveWindow((HWND
) GetMenuBar()->GetCommandBar(), 0, 0, clientSz
.x
, rect
.bottom 
- rect
.top
, true ) ) 
 818                                 wxLogLastError(wxT("MoveWindow")); 
 825         processed 
= wxWindow::HandleSize(x
, y
, id
); 
 831 bool wxFrame::HandleCommand(WXWORD id
, WXWORD cmd
, WXHWND control
) 
 835         // In case it's e.g. a toolbar. 
 836         wxWindow 
*win 
= wxFindWinFromHandle(control
); 
 838             return win
->MSWCommand(cmd
, id
); 
 841     // handle here commands from menus and accelerators 
 842     if ( cmd 
== 0 || cmd 
== 1 ) 
 844 #if wxUSE_MENUS_NATIVE 
 845         if ( wxCurrentPopupMenu 
) 
 847             wxMenu 
*popupMenu 
= wxCurrentPopupMenu
; 
 848             wxCurrentPopupMenu 
= NULL
; 
 850             return popupMenu
->MSWCommand(cmd
, id
); 
 852 #endif // wxUSE_MENUS_NATIVE 
 854         if ( ProcessCommand(id
) ) 
 863 bool wxFrame::HandleMenuSelect(WXWORD nItem
, WXWORD flags
, WXHMENU hMenu
) 
 866     if ( flags 
== 0xFFFF && hMenu 
== 0 ) 
 868         // menu was removed from screen 
 871 #ifndef __WXMICROWIN__ 
 872     else if ( !(flags 
& MF_POPUP
) && !(flags 
& MF_SEPARATOR
) ) 
 879         // don't give hints for separators (doesn't make sense) nor for the 
 880         // items opening popup menus (they don't have them anyhow) but do clear 
 881         // the status line - otherwise, we would be left with the help message 
 882         // for the previous item which doesn't apply any more 
 883         DoGiveHelp(wxEmptyString
, FALSE
); 
 888     wxMenuEvent 
event(wxEVT_MENU_HIGHLIGHT
, item
); 
 889     event
.SetEventObject(this); 
 891     return GetEventHandler()->ProcessEvent(event
); 
 894 bool wxFrame::HandleMenuLoop(const wxEventType
& evtType
, WXWORD isPopup
) 
 896     // we don't have the menu id here, so we use the id to specify if the event 
 897     // was from a popup menu or a normal one 
 898     wxMenuEvent 
event(evtType
, isPopup 
? -1 : 0); 
 899     event
.SetEventObject(this); 
 901     return GetEventHandler()->ProcessEvent(event
); 
 904 // --------------------------------------------------------------------------- 
 905 // the window proc for wxFrame 
 906 // --------------------------------------------------------------------------- 
 908 WXLRESULT 
wxFrame::MSWWindowProc(WXUINT message
, WXWPARAM wParam
, WXLPARAM lParam
) 
 911     bool processed 
= FALSE
; 
 916             // if we can't close, tell the system that we processed the 
 917             // message - otherwise it would close us 
 918             processed 
= !Close(); 
 922             processed 
= HandleSize(LOWORD(lParam
), HIWORD(lParam
), wParam
); 
 929                 UnpackCommand((WXWPARAM
)wParam
, (WXLPARAM
)lParam
, 
 932                 processed 
= HandleCommand(id
, cmd
, (WXHWND
)hwnd
); 
 937             processed 
= HandlePaint(); 
 940         case WM_INITMENUPOPUP
: 
 941             processed 
= HandleInitMenuPopup((WXHMENU
) wParam
); 
 944 #if !defined(__WXMICROWIN__) && !defined(__WXWINCE__) 
 949                 UnpackMenuSelect(wParam
, lParam
, &item
, &flags
, &hmenu
); 
 951                 processed 
= HandleMenuSelect(item
, flags
, hmenu
); 
 955         case WM_EXITMENULOOP
: 
 956             processed 
= HandleMenuLoop(wxEVT_MENU_CLOSE
, wParam
); 
 959         case WM_QUERYDRAGICON
: 
 961                 const wxIcon
& icon 
= GetIcon(); 
 962                 HICON hIcon 
= icon
.Ok() ? GetHiconOf(icon
) 
 963                                         : (HICON
)GetDefaultIcon(); 
 968 #endif // !__WXMICROWIN__ 
 972         rc 
= wxFrameBase::MSWWindowProc(message
, wParam
, lParam
); 
 977 // handle WM_INITMENUPOPUP message 
 978 bool wxFrame::HandleInitMenuPopup(WXHMENU hMenu
) 
 983         int nCount 
= GetMenuBar()->GetMenuCount(); 
 984         for (int n 
= 0; n 
< nCount
; n
++) 
 986             if (GetMenuBar()->GetMenu(n
)->GetHMenu() == hMenu
) 
 988                 menu 
= GetMenuBar()->GetMenu(n
); 
 994     wxMenuEvent 
event(wxEVT_MENU_OPEN
, 0, menu
); 
 995     event
.SetEventObject(this); 
 997     return GetEventHandler()->ProcessEvent(event
); 
1000 // ---------------------------------------------------------------------------- 
1001 // wxFrame size management: we exclude the areas taken by menu/status/toolbars 
1002 // from the client area, so the client area is what's really available for the 
1004 // ---------------------------------------------------------------------------- 
1006 // get the origin of the client area in the client coordinates 
1007 wxPoint 
wxFrame::GetClientAreaOrigin() const 
1009     wxPoint pt 
= wxTopLevelWindow::GetClientAreaOrigin(); 
1011 #if wxUSE_TOOLBAR && !defined(__WXUNIVERSAL__) && \ 
1012   (!defined(__WXWINCE__) || (_WIN32_WCE >= 400 && !defined(__POCKETPC__) && !defined(__SMARTPHONE__))) 
1013     wxToolBar 
*toolbar 
= GetToolBar(); 
1014     if ( toolbar 
&& toolbar
->IsShown() ) 
1017         toolbar
->GetSize(&w
, &h
); 
1019         if ( toolbar
->GetWindowStyleFlag() & wxTB_VERTICAL 
) 
1028 #endif // wxUSE_TOOLBAR 
1030 #if defined(__WXWINCE__) && defined(__WINCE_STANDARDSDK__) 
1031         if (GetMenuBar() && GetMenuBar()->GetCommandBar()) 
1034                 ::GetWindowRect((HWND
) GetMenuBar()->GetCommandBar(), &rect
); 
1035                 pt
.y 
+= (rect
.bottom 
- rect
.top
);