1 ///////////////////////////////////////////////////////////////////////////// 
   2 // Name:        src/os2/frame.cpp 
   4 // Author:      David Webster 
   8 // Copyright:   (c) David Webster 
   9 // Licence:     wxWindows licence 
  10 ///////////////////////////////////////////////////////////////////////////// 
  12 // For compilers that support precompilation, includes "wx.h". 
  13 #include "wx/wxprec.h" 
  16     #include "wx/object.h" 
  17     #include "wx/dynarray.h" 
  20     #include "wx/string.h" 
  28     #include "wx/dialog.h" 
  29     #include "wx/settings.h" 
  30     #include "wx/dcclient.h" 
  34 #include "wx/os2/private.h" 
  37     #include "wx/statusbr.h" 
  38     #include "wx/generic/statusbr.h" 
  39 #endif // wxUSE_STATUSBAR 
  42     #include "wx/toolbar.h" 
  43 #endif // wxUSE_TOOLBAR 
  45 #include "wx/menuitem.h" 
  47 // ---------------------------------------------------------------------------- 
  49 // ---------------------------------------------------------------------------- 
  51 #if wxUSE_MENUS_NATIVE 
  52 extern wxMenu 
*wxCurrentPopupMenu
; 
  55 // ---------------------------------------------------------------------------- 
  57 // ---------------------------------------------------------------------------- 
  59 BEGIN_EVENT_TABLE(wxFrame
, wxFrameBase
) 
  60     EVT_SYS_COLOUR_CHANGED(wxFrame::OnSysColourChanged
) 
  63 IMPLEMENT_DYNAMIC_CLASS(wxFrame
, wxWindow
) 
  65 // ============================================================================ 
  67 // ============================================================================ 
  69 // ---------------------------------------------------------------------------- 
  70 // static class members 
  71 // ---------------------------------------------------------------------------- 
  74 #if wxUSE_NATIVE_STATUSBAR 
  75     bool wxFrame::m_bUseNativeStatusBar 
= true; 
  77     bool wxFrame::m_bUseNativeStatusBar 
= false; 
  80 #endif //wxUSE_STATUSBAR 
  82 // ---------------------------------------------------------------------------- 
  83 // creation/destruction 
  84 // ---------------------------------------------------------------------------- 
  88     m_nFsStatusBarFields 
= 0; 
  89     m_nFsStatusBarHeight 
= 0; 
  90     m_nFsToolBarHeight   
= 0; 
  92     m_bWasMinimized      
= false; 
  95     m_frameMenuBar   
= NULL
; 
  96     m_frameToolBar   
= NULL
; 
  97     m_frameStatusBar 
= NULL
; 
  99     m_hTitleBar 
= NULLHANDLE
; 
 100     m_hHScroll  
= NULLHANDLE
; 
 101     m_hVScroll  
= NULLHANDLE
; 
 106     memset(&m_vSwpTitleBar
, 0, sizeof(SWP
)); 
 107     memset(&m_vSwpMenuBar
, 0, sizeof(SWP
)); 
 108     memset(&m_vSwpHScroll
, 0, sizeof(SWP
)); 
 109     memset(&m_vSwpVScroll
, 0, sizeof(SWP
)); 
 110     memset(&m_vSwpStatusBar
, 0, sizeof(SWP
)); 
 111     memset(&m_vSwpToolBar
, 0, sizeof(SWP
)); 
 114 } // end of wxFrame::Init 
 116 bool wxFrame::Create( wxWindow
*       pParent
, 
 118                       const wxString
& rsTitle
, 
 122                       const wxString
& rsName 
) 
 124     if (!wxTopLevelWindow::Create( pParent
 
 134 } // end of wxFrame::Create 
 138     m_isBeingDeleted 
= true; 
 140 } // end of wxFrame::~wxFrame 
 143 // Get size *available for subwindows* i.e. excluding menu bar, toolbar etc. 
 145 void wxFrame::DoGetClientSize( 
 150     wxTopLevelWindow::DoGetClientSize( pX
 
 154     // No need to use statusbar code as in WIN32 as the FORMATFRAME 
 155     // window procedure ensures PM knows about the new frame client 
 156     // size internally.  A ::WinQueryWindowRect (that is called in 
 157     // wxWindow's GetClient size from above) is all that is needed! 
 159 } // end of wxFrame::DoGetClientSize 
 162 // Set the client size (i.e. leave the calculation of borders etc. 
 165 void wxFrame::DoSetClientSize( 
 171     // Statusbars are not part of the OS/2 Client but parent frame 
 172     // so no statusbar consideration 
 174     wxTopLevelWindow::DoSetClientSize( nWidth
 
 177 } // end of wxFrame::DoSetClientSize 
 179 // ---------------------------------------------------------------------------- 
 180 // wxFrame: various geometry-related functions 
 181 // ---------------------------------------------------------------------------- 
 183 void wxFrame::Raise() 
 185     wxFrameBase::Raise(); 
 186     ::WinSetWindowPos( (HWND
) GetParent()->GetHWND() 
 197 wxStatusBar
* wxFrame::OnCreateStatusBar( 
 201 , const wxString
&                   rName
 
 204     wxStatusBar
*                    pStatusBar 
= NULL
; 
 207     pStatusBar 
= wxFrameBase::OnCreateStatusBar( nNumber
 
 216     wxClientDC                      
vDC(pStatusBar
); 
 220     // Set the height according to the font and the border size 
 222     vDC
.SetFont(pStatusBar
->GetFont()); // Screws up the menues for some reason 
 223     vDC
.GetTextExtent( wxT("X") 
 228     int                             nHeight 
= ((11 * nY
) / 10 + 2 * pStatusBar
->GetBorderY()); 
 230     pStatusBar
->SetSize( wxDefaultCoord
 
 236     ::WinSetParent( pStatusBar
->GetHWND(), m_hFrame
, FALSE 
); 
 237     ::WinSetOwner( pStatusBar
->GetHWND(), m_hFrame
); 
 241     if(::WinIsWindowShowing(m_hFrame
)) 
 242         ::WinSendMsg(m_hFrame
, WM_UPDATEFRAME
, (MPARAM
)~0, 0); 
 245 } // end of wxFrame::OnCreateStatusBar 
 247 void wxFrame::PositionStatusBar() 
 254     // Native status bar positions itself 
 256     if (m_frameStatusBar
) 
 265         ::WinQueryWindowRect(m_hFrame
, &vRect
); 
 267         ::WinMapWindowPoints(m_hFrame
, HWND_DESKTOP
, (PPOINTL
)&vRect
, 2); 
 269         ::WinCalcFrameRect(m_hFrame
, &vRect
, TRUE
); 
 270         nWidth 
= vRect
.xRight 
- vRect
.xLeft
; 
 271         nY 
= nY 
- (vRect
.yBottom 
- vFRect
.yBottom
); 
 273         m_frameStatusBar
->GetSize( &nStatbarWidth
 
 277         nY
= nY 
- nStatbarHeight
; 
 279         // Since we wish the status bar to be directly under the client area, 
 280         // we use the adjusted sizes without using wxSIZE_NO_ADJUSTMENTS. 
 282         m_frameStatusBar
->SetSize( vRect
.xLeft 
- vFRect
.xLeft
 
 287         if (!::WinQueryWindowPos(m_frameStatusBar
->GetHWND(), &vSwp
)) 
 289             vError 
= ::WinGetLastError(vHabmain
); 
 290             sError 
= wxPMErrorToStr(vError
); 
 291             wxLogError(_T("Error setting parent for StatusBar. Error: %s\n"), sError
.c_str()); 
 295 } // end of wxFrame::PositionStatusBar 
 296 #endif // wxUSE_STATUSBAR 
 299 wxToolBar
* wxFrame::OnCreateToolBar( long lStyle
, wxWindowID vId
, const wxString
& rsName 
) 
 301     wxToolBar
*                      pToolBar 
= wxFrameBase::OnCreateToolBar( lStyle
 
 306     ::WinSetParent( pToolBar
->GetHWND(), m_hFrame
, FALSE
); 
 307     ::WinSetOwner( pToolBar
->GetHWND(), m_hFrame
); 
 309 } // end of WinGuiBase_CFrame::OnCreateToolBar 
 312 #if wxUSE_MENUS_NATIVE 
 313 void wxFrame::DetachMenuBar() 
 317         m_frameMenuBar
->Detach(); 
 318         m_frameMenuBar 
= NULL
; 
 320 } // end of wxFrame::DetachMenuBar 
 322 void wxFrame::SetMenuBar( 
 333         // Actually remove the menu from the frame 
 335         m_hMenu 
= (WXHMENU
)0; 
 336         InternalSetMenuBar(); 
 338     else // set new non NULL menu bar 
 340         m_frameMenuBar 
= NULL
; 
 343         // Can set a menubar several times. 
 344         // TODO: how to prevent a memory leak if you have a currently-unattached 
 345         // menubar? wxWidgets assumes that the frame will delete the menu (otherwise 
 346         // there are problems for MDI). 
 348         if (pMenuBar
->GetHMenu()) 
 350             m_hMenu 
= pMenuBar
->GetHMenu(); 
 355             m_hMenu 
= pMenuBar
->Create(); 
 359         InternalSetMenuBar(); 
 360         m_frameMenuBar 
= pMenuBar
; 
 361         pMenuBar
->Attach((wxFrame
*)this); 
 363 } // end of wxFrame::SetMenuBar 
 365 void wxFrame::AttachMenuBar( 
 369     wxFrameBase::AttachMenuBar(pMenubar
); 
 371     m_frameMenuBar 
= pMenubar
; 
 376         // Actually remove the menu from the frame 
 378         m_hMenu 
= (WXHMENU
)0; 
 379         InternalSetMenuBar(); 
 381     else // Set new non NULL menu bar 
 384         // Can set a menubar several times. 
 386         if (pMenubar
->GetHMenu()) 
 388             m_hMenu 
= pMenubar
->GetHMenu(); 
 392             if (pMenubar
->IsAttached()) 
 395             m_hMenu 
= pMenubar
->Create(); 
 400         InternalSetMenuBar(); 
 402 } // end of wxFrame::AttachMenuBar 
 404 void wxFrame::InternalSetMenuBar() 
 409     // Set the parent and owner of the menubar to be the frame 
 411     if (!::WinSetParent(m_hMenu
, m_hFrame
, FALSE
)) 
 413         vError 
= ::WinGetLastError(vHabmain
); 
 414         sError 
= wxPMErrorToStr(vError
); 
 415         wxLogError(_T("Error setting parent for submenu. Error: %s\n"), sError
.c_str()); 
 418     if (!::WinSetOwner(m_hMenu
, m_hFrame
)) 
 420         vError 
= ::WinGetLastError(vHabmain
); 
 421         sError 
= wxPMErrorToStr(vError
); 
 422         wxLogError(_T("Error setting parent for submenu. Error: %s\n"), sError
.c_str()); 
 424     ::WinSendMsg(m_hFrame
, WM_UPDATEFRAME
, (MPARAM
)FCF_MENU
, (MPARAM
)0); 
 425 } // end of wxFrame::InternalSetMenuBar 
 426 #endif // wxUSE_MENUS_NATIVE 
 429 // Responds to colour changes, and passes event on to children 
 431 void wxFrame::OnSysColourChanged( 
 432   wxSysColourChangedEvent
&          rEvent
 
 435     SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_APPWORKSPACE
)); 
 439     if (m_frameStatusBar
) 
 441         wxSysColourChangedEvent     vEvent2
; 
 443         vEvent2
.SetEventObject(m_frameStatusBar
); 
 444         m_frameStatusBar
->GetEventHandler()->ProcessEvent(vEvent2
); 
 446 #endif //wxUSE_STATUSBAR 
 449     // Propagate the event to the non-top-level children 
 451     wxWindow::OnSysColourChanged(rEvent
); 
 452 } // end of wxFrame::OnSysColourChanged 
 454 // Pass true to show full screen, false to restore. 
 455 bool wxFrame::ShowFullScreen( bool bShow
, long lStyle 
) 
 462         m_bFsIsShowing 
= true; 
 466         wxToolBar
*                  pTheToolBar 
= GetToolBar(); 
 467 #endif //wxUSE_TOOLBAR 
 470         wxStatusBar
*                pTheStatusBar 
= GetStatusBar(); 
 471 #endif //wxUSE_STATUSBAR 
 477             pTheToolBar
->GetSize(&nDummyWidth
, &m_nFsToolBarHeight
); 
 478 #endif //wxUSE_TOOLBAR 
 482             pTheStatusBar
->GetSize(&nDummyWidth
, &m_nFsStatusBarHeight
); 
 483 #endif //wxUSE_STATUSBAR 
 487         // Zap the toolbar, menubar, and statusbar 
 489         if ((lStyle 
& wxFULLSCREEN_NOTOOLBAR
) && pTheToolBar
) 
 491             pTheToolBar
->SetSize(wxDefaultCoord
,0); 
 492             pTheToolBar
->Show(false); 
 494 #endif //wxUSE_TOOLBAR 
 496         if (lStyle 
& wxFULLSCREEN_NOMENUBAR
) 
 498             ::WinSetParent(m_hMenu
, m_hFrame
, FALSE
); 
 499             ::WinSetOwner(m_hMenu
, m_hFrame
); 
 500             ::WinSendMsg((HWND
)m_hFrame
, WM_UPDATEFRAME
, (MPARAM
)FCF_MENU
, (MPARAM
)0); 
 505         // Save the number of fields in the statusbar 
 507         if ((lStyle 
& wxFULLSCREEN_NOSTATUSBAR
) && pTheStatusBar
) 
 509             m_nFsStatusBarFields 
= pTheStatusBar
->GetFieldsCount(); 
 510             SetStatusBar((wxStatusBar
*) NULL
); 
 511             delete pTheStatusBar
; 
 514             m_nFsStatusBarFields 
= 0; 
 515 #endif //wxUSE_STATUSBAR 
 518         // Zap the frame borders 
 522         // Save the 'normal' window style 
 524         m_lFsOldWindowStyle 
= ::WinQueryWindowULong(m_hFrame
, QWL_STYLE
); 
 527         // Save the old position, width & height, maximize state 
 529         m_vFsOldSize 
= GetRect(); 
 530         m_bFsIsMaximized 
= IsMaximized(); 
 533         // Decide which window style flags to turn off 
 535         LONG lNewStyle 
= m_lFsOldWindowStyle
; 
 538         if (lStyle 
& wxFULLSCREEN_NOBORDER
) 
 539             lOffFlags 
|= FCF_BORDER
; 
 540         if (lStyle 
& wxFULLSCREEN_NOCAPTION
) 
 541             lOffFlags 
|= (FCF_TASKLIST 
| FCF_SYSMENU
); 
 543         lNewStyle 
&= (~lOffFlags
); 
 546         // Change our window style to be compatible with full-screen mode 
 548         ::WinSetWindowULong((HWND
)m_hFrame
, QWL_STYLE
, (ULONG
)lNewStyle
); 
 551         // Resize to the size of the desktop 
 557         ::WinQueryWindowRect(HWND_DESKTOP
, &vRect
); 
 558         nWidth 
= vRect
.xRight 
- vRect
.xLeft
; 
 560         // Remember OS/2 is backwards! 
 562         nHeight 
= vRect
.yTop 
- vRect
.yBottom
; 
 564         SetSize( nWidth
, nHeight
); 
 567         // Now flush the window style cache and actually go full-screen 
 569         ::WinSetWindowPos( (HWND
) GetParent()->GetHWND() 
 578         wxSize 
sz( nWidth
, nHeight 
); 
 579         wxSizeEvent 
vEvent( sz
, GetId() ); 
 581         GetEventHandler()->ProcessEvent(vEvent
); 
 589         m_bFsIsShowing 
= false; 
 592         wxToolBar
*                  pTheToolBar 
= GetToolBar(); 
 595         // Restore the toolbar, menubar, and statusbar 
 597         if (pTheToolBar 
&& (m_lFsStyle 
& wxFULLSCREEN_NOTOOLBAR
)) 
 599             pTheToolBar
->SetSize(wxDefaultCoord
, m_nFsToolBarHeight
); 
 600             pTheToolBar
->Show(true); 
 602 #endif //wxUSE_TOOLBAR 
 605         if ((m_lFsStyle 
& wxFULLSCREEN_NOSTATUSBAR
) && (m_nFsStatusBarFields 
> 0)) 
 607             CreateStatusBar(m_nFsStatusBarFields
); 
 608 //          PositionStatusBar(); 
 610 #endif //wxUSE_STATUSBAR 
 612         if ((m_lFsStyle 
& wxFULLSCREEN_NOMENUBAR
) && (m_hMenu 
!= 0)) 
 614             ::WinSetParent(m_hMenu
, m_hFrame
, FALSE
); 
 615             ::WinSetOwner(m_hMenu
, m_hFrame
); 
 616             ::WinSendMsg(m_hFrame
, WM_UPDATEFRAME
, (MPARAM
)FCF_MENU
, (MPARAM
)0); 
 618         Maximize(m_bFsIsMaximized
); 
 620         ::WinSetWindowULong( m_hFrame
 
 622                             ,(ULONG
)m_lFsOldWindowStyle
 
 624         ::WinSetWindowPos( (HWND
) GetParent()->GetHWND() 
 633     return wxFrameBase::ShowFullScreen(bShow
, lStyle
); 
 634 } // end of wxFrame::ShowFullScreen 
 639 // ---------------------------------------------------------------------------- 
 640 // wxFrame size management: we exclude the areas taken by menu/status/toolbars 
 641 // from the client area, so the client area is what's really available for the 
 643 // ---------------------------------------------------------------------------- 
 645 // Checks if there is a toolbar, and returns the first free client position 
 646 wxPoint 
wxFrame::GetClientAreaOrigin() const 
 648     wxPoint                         vPoint 
= wxTopLevelWindow::GetClientAreaOrigin(); 
 651     // In OS/2 the toolbar and statusbar are frame extensions so there is no 
 652     // adjustment.  The client is supposedly resized for a toolbar in OS/2 
 653     // as it is for the status bar. 
 656 } // end of wxFrame::GetClientAreaOrigin 
 658 // ---------------------------------------------------------------------------- 
 659 // tool/status bar stuff 
 660 // ---------------------------------------------------------------------------- 
 664 wxToolBar
* wxFrame::CreateToolBar( 
 667 , const wxString
&                   rName
 
 670     if (wxFrameBase::CreateToolBar( lStyle
 
 677     return m_frameToolBar
; 
 678 } // end of wxFrame::CreateToolBar 
 680 void wxFrame::PositionToolBar() 
 682     wxToolBar
*                      pToolBar 
= GetToolBar(); 
 695     ::WinQueryWindowRect(m_hFrame
, &vRect
); 
 696     vPos
.y 
= (wxCoord
)vRect
.yTop
; 
 697     ::WinMapWindowPoints(m_hFrame
, HWND_DESKTOP
, (PPOINTL
)&vRect
, 2); 
 699     ::WinCalcFrameRect(m_hFrame
, &vRect
, TRUE
); 
 701     vPos
.y 
= (wxCoord
)(vFRect
.yTop 
- vRect
.yTop
); 
 702     pToolBar
->GetSize( &vTWidth
 
 706     if (pToolBar
->GetWindowStyleFlag() & wxTB_HORIZONTAL
) 
 708         vWidth 
= (wxCoord
)(vRect
.xRight 
- vRect
.xLeft
); 
 709         pToolBar
->SetSize( vRect
.xLeft 
- vFRect
.xLeft
 
 718         wxCoord                     vSheight 
= 0; 
 720         if (m_frameStatusBar
) 
 721             m_frameStatusBar
->GetSize( &vSwidth
 
 724         vHeight 
= (wxCoord
)(vRect
.yTop 
- vRect
.yBottom
); 
 725         pToolBar
->SetSize( vRect
.xLeft 
- vFRect
.xLeft
 
 731     if( ::WinIsWindowShowing(m_hFrame
) ) 
 732         ::WinSendMsg(m_hFrame
, WM_UPDATEFRAME
, (MPARAM
)~0, 0); 
 733 } // end of wxFrame::PositionToolBar 
 734 #endif // wxUSE_TOOLBAR 
 736 // ---------------------------------------------------------------------------- 
 737 // frame state (iconized/maximized/...) 
 738 // ---------------------------------------------------------------------------- 
 741 // propagate our state change to all child frames: this allows us to emulate X 
 742 // Windows behaviour where child frames float independently of the parent one 
 743 // on the desktop, but are iconized/restored with it 
 745 void wxFrame::IconizeChildFrames( bool WXUNUSED(bIconize
) ) 
 747   // FIXME: Generic MDI does not use Frames for the Childs, so this does _not_ 
 748   //        work. Possibly, the right thing is simply to eliminate this 
 749   //        functions and all the calls to it from within this file. 
 751     for (wxWindowList::Node
* pNode 
= GetChildren().GetFirst(); 
 753          pNode 
= pNode
->GetNext() ) 
 755         wxWindow
*                   pWin 
= pNode
->GetData(); 
 756         wxFrame
*                    pFrame 
= wxDynamicCast(pWin
, wxFrame
); 
 759 #if wxUSE_MDI_ARCHITECTURE 
 760                 && !wxDynamicCast(pFrame
, wxMDIChildFrame
) 
 761 #endif // wxUSE_MDI_ARCHITECTURE 
 765             // We don't want to restore the child frames which had been 
 766             // iconized even before we were iconized, so save the child frame 
 767             // status when iconizing the parent frame and check it when 
 772                 pFrame
->m_bWasMinimized 
= pFrame
->IsIconized(); 
 776             // This test works for both iconizing and restoring 
 778             if (!pFrame
->m_bWasMinimized
) 
 779                 pFrame
->Iconize(bIconize
); 
 783 } // end of wxFrame::IconizeChildFrames 
 785 WXHICON 
wxFrame::GetDefaultIcon() const 
 787     return (WXHICON
)(wxSTD_FRAME_ICON 
? wxSTD_FRAME_ICON
 
 788                                       : wxDEFAULT_FRAME_ICON
); 
 790 // =========================================================================== 
 791 // message processing 
 792 // =========================================================================== 
 794 // --------------------------------------------------------------------------- 
 796 // --------------------------------------------------------------------------- 
 797 bool wxFrame::OS2TranslateMessage( WXMSG
* pMsg 
) 
 800     // try the menu bar accels 
 802     wxMenuBar
* pMenuBar 
= GetMenuBar(); 
 807 #if wxUSE_ACCEL && wxUSE_MENUS_NATIVE 
 808     const wxAcceleratorTable
&       rAcceleratorTable 
= pMenuBar
->GetAccelTable(); 
 809     return rAcceleratorTable
.Translate(GetHWND(), pMsg
); 
 813 } // end of wxFrame::OS2TranslateMessage 
 815 // --------------------------------------------------------------------------- 
 816 // our private (non virtual) message handlers 
 817 // --------------------------------------------------------------------------- 
 818 bool wxFrame::HandlePaint() 
 822     if (::WinQueryUpdateRect(GetHWND(), &vRect
)) 
 827             // Icons in PM are the same as "pointers" 
 829             const wxIcon
&           vIcon 
= GetIcon(); 
 833                 hIcon 
= (HPOINTER
)::WinSendMsg(m_hFrame
, WM_QUERYICON
, 0L, 0L); 
 835                 hIcon 
= (HPOINTER
)m_hDefaultIcon
; 
 838             // Hold a pointer to the dc so long as the OnPaint() message 
 839             // is being processed 
 842             HPS                     hPs 
= ::WinBeginPaint(GetHwnd(), NULLHANDLE
, &vRect2
); 
 845             // Erase background before painting or we get white background 
 847             OS2DefWindowProc(WM_ERASEBACKGROUND
, (MPARAM
)hPs
, (MPARAM
)&vRect2
); 
 853                 ::WinQueryWindowRect(GetHwnd(), &vRect3
); 
 855                 static const int    nIconWidth 
= 32; 
 856                 static const int    nIconHeight 
= 32; 
 857                 int                 nIconX 
= (int)((vRect3
.xRight 
- nIconWidth
)/2); 
 858                 int                 nIconY 
= (int)((vRect3
.yBottom 
+ nIconHeight
)/2); 
 860                 ::WinDrawPointer(hPs
, nIconX
, nIconY
, hIcon
, DP_NORMAL
); 
 866             if (!wxWindow::HandlePaint()) 
 871                 hPS 
= ::WinBeginPaint( GetHwnd() 
 877                     ::GpiCreateLogColorTable( hPS
 
 881                                              ,(LONG
)wxTheColourDatabase
->m_nSize
 
 882                                              ,(PLONG
)wxTheColourDatabase
->m_palTable
 
 884                     ::GpiCreateLogColorTable( hPS
 
 894                                   ,GetBackgroundColour().GetPixel() 
 903 } // end of wxFrame::HandlePaint 
 905 bool wxFrame::HandleSize( int nX
, int nY
, WXUINT nId 
) 
 907     bool bProcessed 
= false; 
 913             // Only do it it if we were iconized before, otherwise resizing the 
 914             // parent frame has a curious side effect of bringing it under it's 
 920             // restore all child frames too 
 922             IconizeChildFrames(false); 
 923             (void)SendIconizeEvent(false); 
 935             // Iconize all child frames too 
 937             IconizeChildFrames(true); 
 938             (void)SendIconizeEvent(); 
 946         // forward WM_SIZE to status bar control 
 948 #if wxUSE_NATIVE_STATUSBAR 
 949         if (m_frameStatusBar 
&& m_frameStatusBar
->IsKindOf(CLASSINFO(wxStatusBar95
))) 
 951             wxSizeEvent             
vEvent( wxSize( nX
 
 954                                            ,m_frameStatusBar
->GetId() 
 957             vEvent
.SetEventObject(m_frameStatusBar
); 
 958             m_frameStatusBar
->OnSize(vEvent
); 
 960 #endif // wxUSE_NATIVE_STATUSBAR 
 965 #endif // wxUSE_TOOLBAR 
 967         bProcessed 
= wxWindow::HandleSize( nX
 
 973 } // end of wxFrame::HandleSize 
 975 bool wxFrame::HandleCommand( WXWORD nId
, 
 982         // In case it's e.g. a toolbar. 
 984         wxWindow
*                   pWin 
= wxFindWinFromHandle(hControl
); 
 987             return pWin
->OS2Command( nCmd
, nId 
); 
 991     // Handle here commands from menus and accelerators 
 993     if (nCmd 
== CMDSRC_MENU 
|| nCmd 
== CMDSRC_ACCELERATOR
) 
 995 #if wxUSE_MENUS_NATIVE 
 996         if (wxCurrentPopupMenu
) 
 998             wxMenu
*                 pPopupMenu 
= wxCurrentPopupMenu
; 
1000             wxCurrentPopupMenu 
= NULL
; 
1002             return pPopupMenu
->OS2Command( nCmd
, nId 
); 
1006         if (ProcessCommand(nId
)) 
1012 } // end of wxFrame::HandleCommand 
1014 bool wxFrame::HandleMenuSelect( WXWORD nItem
, 
1023         rc 
= ::WinSendMsg(hMenu
, MM_QUERYITEM
, MPFROM2SHORT(nItem
, TRUE
), (MPARAM
)&mItem
); 
1025         if(rc 
&& !(mItem
.afStyle 
& (MIS_SUBMENU 
| MIS_SEPARATOR
))) 
1027             wxMenuEvent                     
vEvent(wxEVT_MENU_HIGHLIGHT
, nItem
); 
1029             vEvent
.SetEventObject(this); 
1030             GetEventHandler()->ProcessEvent(vEvent
); // return value would be ignored by PM 
1034             DoGiveHelp(wxEmptyString
, false); 
1039 } // end of wxFrame::HandleMenuSelect 
1041 // --------------------------------------------------------------------------- 
1042 // Main Frame window proc 
1043 // --------------------------------------------------------------------------- 
1044 MRESULT EXPENTRY 
wxFrameMainWndProc( HWND   hWnd
, 
1049     MRESULT  rc 
= (MRESULT
)0; 
1050     bool     bProcessed 
= false; 
1051     wxFrame
* pWnd  
= NULL
; 
1053     pWnd 
= (wxFrame
*) wxFindWinFromHandle((WXHWND
) hWnd
); 
1056         case WM_QUERYFRAMECTLCOUNT
: 
1057             if(pWnd 
&& pWnd
->m_fnOldWndProc
) 
1059                 USHORT              uItemCount 
= SHORT1FROMMR(pWnd
->m_fnOldWndProc(hWnd
, ulMsg
, wParam
, lParam
)); 
1061                 rc 
= MRFROMSHORT(uItemCount
); 
1065         case WM_FORMATFRAME
: 
1066 ///////////////////////////////////////////////////////////////////////////////// 
1067 // Applications that subclass frame controls may find that the frame is already 
1068 // subclassed the number of frame controls is variable. 
1069 // The WM_FORMATFRAME and WM_QUERYFRAMECTLCOUNT messages must always be 
1070 // subclassed by calling the previous window procedure and modifying its result. 
1071 //////////////////////////////////////////////////////////////////////////////// 
1083                 pSWP 
= (PSWP
)PVOIDFROMMP(wParam
); 
1084                 nItemCount 
= SHORT1FROMMR(pWnd
->m_fnOldWndProc(hWnd
, ulMsg
, wParam
, lParam
)); 
1085                 if(pWnd
->m_frameStatusBar
) 
1087                     ::WinQueryWindowRect(pWnd
->m_frameStatusBar
->GetHWND(), &vRstb
); 
1088                     pWnd
->m_frameStatusBar
->GetSize(NULL
, &nHeight
); 
1090                 if(pWnd
->m_frameToolBar
) 
1092                     ::WinQueryWindowRect(pWnd
->m_frameToolBar
->GetHWND(), &vRtlb
); 
1093                     pWnd
->m_frameToolBar
->GetSize(&nWidth
, &nHeight2
); 
1095                 ::WinQueryWindowRect(pWnd
->m_hFrame
, &vRectl
); 
1096                 ::WinMapWindowPoints(pWnd
->m_hFrame
, HWND_DESKTOP
, (PPOINTL
)&vRectl
, 2); 
1097                 ::WinCalcFrameRect(pWnd
->m_hFrame
, &vRectl
, TRUE
); 
1098                 ::WinMapWindowPoints(HWND_DESKTOP
, pWnd
->m_hFrame
, (PPOINTL
)&vRectl
, 2); 
1099                 for(i 
= 0; i 
< nItemCount
; i
++) 
1101                     if(pWnd
->m_hWnd 
&& pSWP
[i
].hwnd 
== pWnd
->m_hWnd
) 
1103                         if (pWnd
->m_frameToolBar 
&& pWnd
->m_frameToolBar
->GetWindowStyleFlag() & wxTB_HORIZONTAL
) 
1105                             pSWP
[i
].x    
= vRectl
.xLeft
; 
1106                             pSWP
[i
].y    
= vRectl
.yBottom 
+ nHeight
; 
1107                             pSWP
[i
].cx   
= vRectl
.xRight 
- vRectl
.xLeft
; 
1108                             pSWP
[i
].cy   
= vRectl
.yTop 
- vRectl
.yBottom 
- (nHeight 
+ nHeight2
); 
1112                             pSWP
[i
].x    
= vRectl
.xLeft 
+ nWidth
; 
1113                             pSWP
[i
].y    
= vRectl
.yBottom 
+ nHeight
; 
1114                             pSWP
[i
].cx   
= vRectl
.xRight 
- (vRectl
.xLeft 
+ nWidth
); 
1115                             pSWP
[i
].cy   
= vRectl
.yTop 
- vRectl
.yBottom 
- nHeight
; 
1117                         pSWP
[i
].fl   
= SWP_SIZE 
| SWP_MOVE 
| SWP_SHOW
; 
1118                         pSWP
[i
].hwndInsertBehind 
= HWND_TOP
; 
1122                 rc 
= MRFROMSHORT(nItemCount
); 
1127             if(pWnd 
&& pWnd
->m_fnOldWndProc
) 
1128                 rc 
= pWnd
->m_fnOldWndProc(hWnd
, ulMsg
, wParam
, lParam
); 
1130                 rc 
= ::WinDefWindowProc(hWnd
, ulMsg
, wParam
, lParam
); 
1133 } // end of wxFrameMainWndProc 
1135 MRESULT EXPENTRY 
wxFrameWndProc( 
1143     // Trace all ulMsgs - useful for the debugging 
1146     wxFrame
*                        pWnd  
= NULL
; 
1148     parentHwnd  
= WinQueryWindow(hWnd
,QW_PARENT
); 
1149     pWnd 
= (wxFrame
*) wxFindWinFromHandle((WXHWND
) hWnd
); 
1152     // When we get the first message for the HWND we just created, we associate 
1153     // it with wxWindow stored in wxWndHook 
1156     MRESULT                         rc 
= (MRESULT
)0; 
1159     // Stop right here if we don't have a valid handle in our wxWindow object. 
1161     if (pWnd 
&& !pWnd
->GetHWND()) 
1163         pWnd
->SetHWND((WXHWND
) hWnd
); 
1164         rc 
= pWnd
->OS2DefWindowProc(ulMsg
, wParam
, lParam 
); 
1170             rc 
= pWnd
->OS2WindowProc(ulMsg
, wParam
, lParam
); 
1172             rc 
= ::WinDefWindowProc(hWnd
, ulMsg
, wParam
, lParam
); 
1175 } // end of wxFrameWndProc 
1177 MRESULT 
wxFrame::OS2WindowProc( WXUINT uMessage
, 
1182     bool    bProcessed 
= false; 
1188             // If we can't close, tell the system that we processed the 
1189             // message - otherwise it would close us 
1191             bProcessed 
= !Close(); 
1195             bProcessed 
= HandlePaint(); 
1196             mRc 
= (MRESULT
)FALSE
; 
1199          case WM_ERASEBACKGROUND
: 
1201             // Returning TRUE to requests PM to paint the window background 
1202             // in SYSCLR_WINDOW. We capture this here because the PS returned 
1203             // in Frames is the PS for the whole frame, which we can't really 
1204             // use at all. If you want to paint a different background, do it 
1205             // in an OnPaint using a wxPaintDC. 
1207             mRc 
= (MRESULT
)(TRUE
); 
1216                 UnpackCommand( (WXWPARAM
)wParam
 
1223                 bProcessed 
= HandleCommand( wId
 
1236                 UnpackMenuSelect( wParam
 
1242                 bProcessed 
= HandleMenuSelect( wItem
 
1246                 mRc 
= (MRESULT
)TRUE
; 
1252                 SHORT               nScxnew 
= SHORT1FROMMP(lParam
); // New horizontal size. 
1253                 SHORT               nScynew 
= SHORT2FROMMP(lParam
); // New vertical size. 
1255                 lParam 
= MRFROM2SHORT( nScxnew 
- 20 
1259             bProcessed 
= HandleSize(LOWORD(lParam
), HIWORD(lParam
), (WXUINT
)wParam
); 
1260             mRc 
= (MRESULT
)FALSE
; 
1263         case CM_QUERYDRAGIMAGE
: 
1265                 const wxIcon
&           vIcon 
= GetIcon(); 
1269                     hIcon 
= (HPOINTER
)::WinSendMsg(GetHWND(), WM_QUERYICON
, 0L, 0L); 
1271                     hIcon 
= (HPOINTER
)m_hDefaultIcon
; 
1272                 mRc 
= (MRESULT
)hIcon
; 
1273                 bProcessed 
= mRc 
!= 0; 
1279         mRc 
= wxWindow::OS2WindowProc( uMessage
 
1283     return (MRESULT
)mRc
; 
1284 } // wxFrame::OS2WindowProc 
1286 void wxFrame::SetClient(WXHWND 
WXUNUSED(c_Hwnd
)) 
1288    // Duh...nothing to do under OS/2 
1291 void wxFrame::SetClient( wxWindow
* pWindow 
) 
1293     wxWindow
* pOldClient      
= this->GetClient(); 
1294     bool      bClientHasFocus 
= pOldClient 
&& (pOldClient 
== wxWindow::FindFocus()); 
1296     if(pOldClient 
== pWindow
)  // nothing to do 
1298     if(pWindow 
== NULL
) // just need to remove old client 
1300         if(pOldClient 
== NULL
) // nothing to do 
1303         if(bClientHasFocus 
) 
1306         pOldClient
->Enable( false ); 
1307         pOldClient
->Show( false ); 
1308         ::WinSetWindowUShort(pOldClient
->GetHWND(), QWS_ID
, (USHORT
)pOldClient
->GetId()); 
1309         // to avoid OS/2 bug need to update frame 
1310         ::WinSendMsg((HWND
)this->GetFrame(), WM_UPDATEFRAME
, (MPARAM
)~0, 0); 
1315     // Else need to change client 
1320     ::WinEnableWindowUpdate((HWND
)GetHWND(), FALSE
); 
1323         pOldClient
->Enable(false); 
1324         pOldClient
->Show(false); 
1325         ::WinSetWindowUShort(pOldClient
->GetHWND(), QWS_ID
, (USHORT
)pOldClient
->GetId()); 
1327     pWindow
->Reparent(this); 
1328     ::WinSetWindowUShort(pWindow
->GetHWND(), QWS_ID
, FID_CLIENT
); 
1329     ::WinEnableWindowUpdate((HWND
)GetHWND(), TRUE
); 
1331     pWindow
->Show();   // ensure client is showing 
1332     if( this->IsShown() ) 
1335         ::WinSendMsg(m_hFrame
, WM_UPDATEFRAME
, (MPARAM
)~0, 0); 
1339 wxWindow
* wxFrame::GetClient() 
1341     return wxFindWinFromHandle((WXHWND
)::WinWindowFromID(m_hFrame
, FID_CLIENT
)); 
1344 void wxFrame::SendSizeEvent() 
1348         RECTL                       vRect 
= wxGetWindowRect(GetHwnd()); 
1350         ::WinPostMsg( GetHwnd() 
1352                      ,MPFROM2SHORT( vRect
.xRight 
- vRect
.xLeft
 
1353                                    ,vRect
.xRight 
- vRect
.xLeft
 
1355                      ,MPFROM2SHORT( vRect
.yTop 
- vRect
.yBottom
 
1356                                    ,vRect
.yTop 
- vRect
.yBottom