]>
git.saurik.com Git - wxWidgets.git/blob - src/os2/toplevel.cpp
   1 /////////////////////////////////////////////////////////////////////////////// 
   2 // Name:        os2/toplevel.cpp 
   3 // Purpose:     implements wxTopLevelWindow for OS/2 
   4 // Author:      Vadim Zeitlin 
   8 // Copyright:   (c) 2001 SciTech Software, Inc. (www.scitechsoft.com) 
   9 // License:     wxWindows licence 
  10 /////////////////////////////////////////////////////////////////////////////// 
  12 // ============================================================================ 
  14 // ============================================================================ 
  16 // ---------------------------------------------------------------------------- 
  18 // ---------------------------------------------------------------------------- 
  21     #pragma implementation "toplevel.h" 
  24 // For compilers that support precompilation, includes "wx.h". 
  25 #include "wx/wxprec.h" 
  33     #include "wx/toplevel.h" 
  34     #include "wx/dialog.h" 
  35     #include "wx/string.h" 
  39     #include "wx/control.h" 
  40     #include "wx/containr.h"        // wxSetFocusToChild() 
  43 #include "wx/module.h"        // wxSetFocusToChild() 
  44 #include "wx/os2/private.h" 
  46 // ---------------------------------------------------------------------------- 
  47 // stubs for missing functions under MicroWindows 
  48 // ---------------------------------------------------------------------------- 
  51 // ---------------------------------------------------------------------------- 
  53 // ---------------------------------------------------------------------------- 
  55 // the name of the default wxWidgets class 
  56 extern void          wxAssociateWinWithHandle( HWND         hWnd
 
  59 bool                 wxTopLevelWindowOS2::m_sbInitialized 
= FALSE
; 
  60 wxWindow
*            wxTopLevelWindowOS2::m_spHiddenParent 
= NULL
; 
  62 // ============================================================================ 
  63 // wxTopLevelWindowOS2 implementation 
  64 // ============================================================================ 
  66 BEGIN_EVENT_TABLE(wxTopLevelWindowOS2
, wxTopLevelWindowBase
) 
  67     EVT_ACTIVATE(wxTopLevelWindowOS2::OnActivate
) 
  70 // ============================================================================ 
  71 // wxTopLevelWindowMSW implementation 
  72 // ============================================================================ 
  75 MRESULT EXPENTRY 
wxDlgProc( HWND 
WXUNUSED(hWnd
) 
  77                            ,void * WXUNUSED(wParam
) 
  78                            ,void * WXUNUSED(lParam
) 
  85             // For this message, returning TRUE tells system to set focus to 
  86             // the first control in the dialog box, but we set the focus 
  87             // ourselves, however in OS/2 we must return true to enable the dialog 
  92             // For all the other ones, FALSE means that we didn't process the 
  95             return (MRESULT
)FALSE
; 
  99 // ---------------------------------------------------------------------------- 
 100 // wxTLWHiddenParentModule: used to manage the hidden parent window (we need a 
 101 // module to ensure that the window is always deleted) 
 102 // ---------------------------------------------------------------------------- 
 104 class wxTLWHiddenParentModule 
: public wxModule
 
 108     // Module init/finalize 
 110     virtual bool OnInit(void); 
 111     virtual void OnExit(void); 
 114     // Get the hidden window (creates on demand) 
 116     static HWND 
GetHWND(void); 
 120     // The HWND of the hidden parent 
 125     // The class used to create it 
 127     static const wxChar
*            m_szClassName
; 
 128     DECLARE_DYNAMIC_CLASS(wxTLWHiddenParentModule
) 
 129 }; // end of CLASS wxTLWHiddenParentModule 
 131 IMPLEMENT_DYNAMIC_CLASS(wxTLWHiddenParentModule
, wxModule
) 
 133 // ---------------------------------------------------------------------------- 
 134 // wxTopLevelWindowOS2 creation 
 135 // ---------------------------------------------------------------------------- 
 137 void wxTopLevelWindowOS2::Init() 
 139     m_bIconized 
= m_bMaximizeOnShow 
= FALSE
; 
 142     // Unlike (almost?) all other windows, frames are created hidden 
 147     // Data to save/restore when calling ShowFullScreen 
 149     m_lFsOldWindowStyle 
= 0; 
 150     m_bFsIsMaximized    
= FALSE
; 
 151     m_bFsIsShowing      
= FALSE
; 
 153     m_hFrame    
= NULLHANDLE
; 
 154     memset(&m_vSwp
, 0, sizeof(SWP
)); 
 155     memset(&m_vSwpClient
, 0, sizeof(SWP
)); 
 156     m_pWinLastFocused 
= (wxWindow 
*)NULL
; 
 157 } // end of wxTopLevelWindowIOS2::Init 
 159 void wxTopLevelWindowOS2::OnActivate( 
 160   wxActivateEvent
&                  rEvent
 
 163     if (rEvent
.GetActive()) 
 166         // Restore focus to the child which was last focused 
 168         wxLogTrace(_T("focus"), _T("wxTLW %08lx activated."), m_hWnd
); 
 170         wxWindow
*                   pParent 
= m_pWinLastFocused 
? m_pWinLastFocused
->GetParent() 
 177         wxSetFocusToChild( pParent
 
 184         // Remember the last focused child if it is our child 
 186         m_pWinLastFocused 
= FindFocus(); 
 189         // So we NULL it out if it's a child from some other frame 
 191         wxWindow
*                   pWin 
= m_pWinLastFocused
; 
 195             if (pWin
->IsTopLevel()) 
 199                     m_pWinLastFocused 
= NULL
; 
 203             pWin 
= pWin
->GetParent(); 
 206         wxLogTrace(_T("focus"), 
 207                    _T("wxTLW %08lx deactivated, last focused: %08lx."), 
 209                    m_pWinLastFocused 
? GetHwndOf(m_pWinLastFocused
) 
 213 } // end of wxTopLevelWindowOS2::OnActivate 
 215 WXDWORD 
wxTopLevelWindowOS2::OS2GetStyle( 
 217 , WXDWORD
*                          pdwExflags
 
 220     long                            lMsflags 
= wxWindow::OS2GetStyle( (lStyle 
& ~wxBORDER_MASK
) | wxBORDER_NONE
 
 224     if ((lStyle 
& wxDEFAULT_FRAME_STYLE
) == wxDEFAULT_FRAME_STYLE
) 
 225         lMsflags 
|= FCF_SIZEBORDER 
| FCF_TITLEBAR 
| FCF_SYSMENU 
| 
 226                     FCF_MINMAX 
| FCF_TASKLIST
; 
 228     if ((lStyle 
& wxCAPTION
) == wxCAPTION
) 
 229         lMsflags 
|= FCF_TASKLIST
; 
 231         lMsflags 
|= FCF_NOMOVEWITHOWNER
; 
 233     if ((lStyle 
& wxVSCROLL
) == wxVSCROLL
) 
 234         lMsflags 
|= FCF_VERTSCROLL
; 
 235     if ((lStyle 
& wxHSCROLL
) == wxHSCROLL
) 
 236         lMsflags 
|= FCF_HORZSCROLL
; 
 237     if (lStyle 
& wxMINIMIZE_BOX
) 
 238         lMsflags 
|= FCF_MINBUTTON
; 
 239     if (lStyle 
& wxMAXIMIZE_BOX
) 
 240         lMsflags 
|= FCF_MAXBUTTON
; 
 241     if (lStyle 
& wxTHICK_FRAME
) 
 242         lMsflags 
|= FCF_DLGBORDER
; 
 243     if (lStyle 
& wxSYSTEM_MENU
) 
 244         lMsflags 
|= FCF_SYSMENU
; 
 245     if (lStyle 
& wxCAPTION
) 
 246         lMsflags 
|= FCF_TASKLIST
; 
 247     if (lStyle 
& wxCLIP_CHILDREN
) 
 249         // Invalid for frame windows under PM 
 252     if (lStyle 
& wxTINY_CAPTION_VERT
) 
 253         lMsflags 
|= FCF_TASKLIST
; 
 254     if (lStyle 
& wxTINY_CAPTION_HORIZ
) 
 255         lMsflags 
|= FCF_TASKLIST
; 
 257     if ((lStyle 
& wxTHICK_FRAME
) == 0) 
 258         lMsflags 
|= FCF_BORDER
; 
 259     if (lStyle 
& wxFRAME_TOOL_WINDOW
) 
 260         *pdwExflags 
= kFrameToolWindow
; 
 262     if (lStyle 
& wxSTAY_ON_TOP
) 
 263         lMsflags 
|= FCF_SYSMODAL
; 
 266 } // end of wxTopLevelWindowOS2::OS2GetCreateWindowFlags 
 268 WXHWND 
wxTopLevelWindowOS2::OS2GetParent() const 
 270     HWND                            hWndParent 
= NULL
; 
 273     // For the frames without wxFRAME_FLOAT_ON_PARENT style we should use NULL 
 274     // parent HWND or it would be always on top of its parent which is not what 
 275     // we usually want (in fact, we only want it for frames with the 
 276     // wxFRAME_FLOAT_ON_PARENT flag) 
 278     if (HasFlag(wxFRAME_FLOAT_ON_PARENT
) ) 
 280         const wxWindow
*             pParent 
= GetParent(); 
 285             // This flag doesn't make sense then and will be ignored 
 287             wxFAIL_MSG( _T("wxFRAME_FLOAT_ON_PARENT but no parent?") ); 
 291             hWndParent 
= GetHwndOf(pParent
); 
 294     //else: don't float on parent, must not be owned 
 297     // Now deal with the 2nd taskbar-related problem (see comments above in 
 300     if (HasFlag(wxFRAME_NO_TASKBAR
) && !hWndParent
) 
 305         hWndParent 
= wxTLWHiddenParentModule::GetHWND(); 
 307     return (WXHWND
)hWndParent
; 
 308 } // end of wxTopLevelWindowOS2::OS2GetParent 
 311 bool wxTopLevelWindowOS2::CreateDialog( ULONG           ulDlgTemplate
, 
 312                                         const wxString
& WXUNUSED(rsTitle
), 
 314                                         const wxSize
&   rSize 
) 
 316     wxWindow
*                       pParent 
= GetParent(); 
 319     // For the dialogs without wxDIALOG_NO_PARENT style, use the top level 
 320     // app window as parent - this avoids creating modal dialogs without 
 323     if (!pParent 
&& !(GetWindowStyleFlag() & wxDIALOG_NO_PARENT
)) 
 325         pParent 
= wxTheApp
->GetTopWindow(); 
 330             // Don't use transient windows as parents, this is dangerous as it 
 331             // can lead to a crash if the parent is destroyed before the child 
 333             // also don't use the window which is currently hidden as then the 
 334             // dialog would be hidden as well 
 335             if ((pParent
->GetExtraStyle() & wxWS_EX_TRANSIENT
) || 
 347         hWndOwner 
= GetHwndOf(pParent
); 
 349         hWndOwner 
= HWND_DESKTOP
; 
 351     hWndDlg 
= ::WinLoadDlg( HWND_DESKTOP
 
 355                            ,(ULONG
)ulDlgTemplate
 
 359     m_hWnd 
= (WXHWND
) hWndDlg
; 
 363         wxFAIL_MSG(wxT("Did you forget to include wx/os2/wx.rc in your resources?")); 
 365         wxLogSysError(wxT("Can't create dialog using template '%ld'"), ulDlgTemplate
); 
 371     // Move the dialog to its initial position without forcing repainting 
 378     if (!OS2GetCreateWindowCoords( rPos
 
 386         nX 
= nWidth 
= (int)CW_USEDEFAULT
; 
 390     // We can't use CW_USEDEFAULT here as we're not calling CreateWindow() 
 391     // and passing CW_USEDEFAULT to MoveWindow() results in resizing the 
 392     // window to (0, 0) size which breaks quite a lot of things, e.g. the 
 393     // sizer calculation in wxSizer::Fit() 
 395     if (nWidth 
== (int)CW_USEDEFAULT
) 
 398         // The exact number doesn't matter, the dialog will be resized 
 399         // again soon anyhow but it should be big enough to allow 
 400         // calculation relying on "totalSize - clientSize > 0" work, i.e. 
 401         // at least greater than the title bar height 
 403         nWidth 
= nHeight 
= 100; 
 405     if (nX 
== (int)CW_USEDEFAULT
) 
 408         // Centre it on the screen - what else can we do? 
 410         wxSize                      vSizeDpy 
= wxGetDisplaySize(); 
 412         nX 
= (vSizeDpy
.x 
- nWidth
) / 2; 
 413         nY 
= (vSizeDpy
.y 
- nHeight
) / 2; 
 415     m_backgroundColour
.Set(wxString(wxT("LIGHT GREY"))); 
 417     LONG                            lColor 
= (LONG
)m_backgroundColour
.GetPixel(); 
 419     if (!::WinSetPresParam( m_hWnd
 
 428     ::WinSetWindowPos( GetHwnd() 
 434                       ,SWP_MOVE 
| SWP_SIZE 
| SWP_ZORDER 
| SWP_SHOW 
| SWP_ACTIVATE
 
 436     ::WinQueryWindowPos(GetHwnd(), GetSwp()); 
 440 } // end of wxTopLevelWindowOS2::CreateDialog 
 442 bool wxTopLevelWindowOS2::CreateFrame( 
 443   const wxString
&                   rsTitle
 
 444 , const wxPoint
&                    rPos
 
 445 , const wxSize
&                     rSize
 
 449     WXDWORD                         lFlags 
= OS2GetCreateWindowFlags(&lExflags
); 
 450     long                            lStyle 
= GetWindowStyleFlag(); 
 453     int                             nWidth 
= rSize
.x
; 
 454     int                             nHeight 
= rSize
.y
; 
 455     ULONG                           ulStyleFlags 
= 0L; 
 458     wxWindow
*                       pParent 
= GetParent(); 
 464         hParent 
= GetHwndOf(pParent
); 
 466         hParent 
= HWND_DESKTOP
; 
 468     if ((lStyle 
& wxMINIMIZE
) || (lStyle 
& wxICONIZE
)) 
 469         ulStyleFlags 
|= WS_MINIMIZED
; 
 470     if (lStyle 
& wxMAXIMIZE
) 
 471         ulStyleFlags 
|= WS_MAXIMIZED
; 
 474     // Clear the visible flag, we always call show 
 476     ulStyleFlags 
&= (unsigned long)~WS_VISIBLE
; 
 480     // Create the frame window:  We break ranks with other ports now 
 481     // and instead of calling down into the base wxWindow class' OS2Create 
 482     // we do all our own stuff here.  We will set the needed pieces 
 483     // of wxWindow manually, here. 
 486      hFrame 
= ::WinCreateStdWindow( hParent
 
 487                                    ,ulStyleFlags          
// frame-window style 
 488                                    ,(PULONG
)&lFlags       
// window style 
 489                                    ,(PSZ
)wxFrameClassName 
// class name 
 490                                    ,(PSZ
)rsTitle
.c_str()  // window title 
 491                                    ,0L                    // default client style 
 492                                    ,NULLHANDLE            
// resource in executable file 
 494                                    ,&hClient              
// receives client window handle 
 498         vError 
= ::WinGetLastError(vHabmain
); 
 499         sError 
= wxPMErrorToStr(vError
); 
 500         wxLogError(_T("Error creating frame. Error: %s\n"), sError
.c_str()); 
 505     // wxWindow class' m_hWnd set here and needed associations 
 509     wxAssociateWinWithHandle(m_hWnd
, this); 
 510     wxAssociateWinWithHandle(m_hFrame
, this); 
 512     m_backgroundColour
.Set(wxString(wxT("MEDIUM GREY"))); 
 514     LONG                            lColor 
= (LONG
)m_backgroundColour
.GetPixel(); 
 516     if (!::WinSetPresParam( m_hWnd
 
 522         vError 
= ::WinGetLastError(vHabmain
); 
 523         sError 
= wxPMErrorToStr(vError
); 
 524         wxLogError(_T("Error creating frame. Error: %s\n"), sError
.c_str()); 
 529     // Now need to subclass window.  Instead of calling the SubClassWin in wxWindow 
 530     // we manually subclass here because we don't want to use the main wxWndProc 
 533     m_fnOldWndProc 
= (WXFARPROC
) ::WinSubclassWindow(m_hFrame
, (PFNWP
)wxFrameMainWndProc
); 
 536     // Now size everything.  If adding a menu the client will need to be resized. 
 541         nY 
= pParent
->GetSize().y 
- (nY 
+ nHeight
); 
 547         ::WinQueryWindowRect(HWND_DESKTOP
, &vRect
); 
 548         nY 
= vRect
.yTop 
- (nY 
+ nHeight
); 
 550     if (!::WinSetWindowPos( m_hFrame
 
 556                            ,SWP_SIZE 
| SWP_MOVE 
| SWP_ACTIVATE 
| SWP_ZORDER
 
 559         vError 
= ::WinGetLastError(vHabmain
); 
 560         sError 
= wxPMErrorToStr(vError
); 
 561         wxLogError(_T("Error sizing frame. Error: %s\n"), sError
.c_str()); 
 564     lStyle 
=  ::WinQueryWindowULong( m_hWnd
 
 567     lStyle 
|= WS_CLIPCHILDREN
; 
 568     ::WinSetWindowULong( m_hWnd
 
 573 } // end of wxTopLevelWindowOS2::CreateFrame 
 575 bool wxTopLevelWindowOS2::Create( 
 578 , const wxString
&                   rsTitle
 
 579 , const wxPoint
&                    rPos
 
 580 , const wxSize
&                     rSizeOrig
 
 582 , const wxString
&                   rsName
 
 589     m_windowStyle 
= lStyle
; 
 591     m_windowId 
= vId 
== -1 ? NewControlId() : vId
; 
 593     // always create a frame of some reasonable, even if arbitrary, size (at 
 594     // least for MSW compatibility) 
 595     wxSize rSize 
= rSizeOrig
; 
 596     if ( rSize
.x 
== -1 || rSize
.y 
== -1 ) 
 598         wxSize sizeDpy 
= wxGetDisplaySize(); 
 600             rSize
.x 
= sizeDpy
.x 
/ 3; 
 602             rSize
.y 
= sizeDpy
.y 
/ 5; 
 605     wxTopLevelWindows
.Append(this); 
 607         pParent
->AddChild(this); 
 609     if (GetExtraStyle() & wxTOPLEVEL_EX_DIALOG
) 
 612         // We have different dialog templates to allows creation of dialogs 
 613         // with & without captions under OS2indows, resizeable or not (but a 
 614         // resizeable dialog always has caption - otherwise it would look too 
 619         if (lStyle 
& wxRESIZE_BORDER
) 
 620             ulDlgTemplate 
= (ULONG
)kResizeableDialog
; 
 621         else if (lStyle 
& wxCAPTION
) 
 622             ulDlgTemplate 
= (ULONG
)kCaptionDialog
; 
 624             ulDlgTemplate 
= (ULONG
)kNoCaptionDialog
; 
 625         return CreateDialog( ulDlgTemplate
 
 633         return CreateFrame( rsTitle
 
 638 } // end of wxTopLevelWindowOS2::Create 
 640 wxTopLevelWindowOS2::~wxTopLevelWindowOS2() 
 643     // After destroying an owned window, Windows activates the next top level 
 644     // window in Z order but it may be different from our owner (to reproduce 
 645     // this simply Alt-TAB to another application and back before closing the 
 646     // owned frame) whereas we always want to yield activation to our parent 
 648     if (HasFlag(wxFRAME_FLOAT_ON_PARENT
)) 
 650         wxWindow
*                   pParent 
= GetParent(); 
 654             ::WinSetWindowPos( GetHwndOf(pParent
) 
 661 } // end of wxTopLevelWindowOS2::~wxTopLevelWindowOS2 
 663 // ---------------------------------------------------------------------------- 
 664 // wxTopLevelWindowOS2 client size 
 665 // ---------------------------------------------------------------------------- 
 667 void wxTopLevelWindowOS2::DoSetClientSize( 
 673     // Call GetClientAreaOrigin() to take the toolbar into account 
 675     wxPoint                         vPt 
= GetClientAreaOrigin(); 
 680     wxWindow::DoSetClientSize( nWidth
 
 683 } // end of wxTopLevelWindowOS2::DoSetClientSize 
 685 void wxTopLevelWindowOS2::DoGetClientSize( 
 690     wxWindow::DoGetClientSize( pnX
 
 694     wxPoint                         vPt 
= GetClientAreaOrigin(); 
 701 } // end of wxTopLevelWindowOS2::DoGetClientSize 
 703 // ---------------------------------------------------------------------------- 
 704 // wxTopLevelWindowOS2 showing 
 705 // ---------------------------------------------------------------------------- 
 707 void wxTopLevelWindowOS2::DoShowWindow( 
 711     ::WinShowWindow(m_hFrame
, (BOOL
)(nShowCmd 
& SWP_SHOW
)); 
 714     // Need to artificially send a size event as wxApps often expect to do some 
 715     // final child control sizing 
 717     m_bIconized 
= nShowCmd 
== SWP_MINIMIZE
; 
 718 } // end of wxTopLevelWindowOS2::DoShowWindow 
 720 bool wxTopLevelWindowOS2::Show( 
 727     if (bShow 
!= IsShown() ) 
 737         if (m_bMaximizeOnShow
) 
 739             nShowCmd 
= SWP_MAXIMIZE
; 
 740             m_bMaximizeOnShow 
= FALSE
; 
 751     DoShowWindow(nShowCmd
); 
 755         wxActivateEvent             
vEvent(wxEVT_ACTIVATE
, TRUE
, m_windowId
); 
 757         ::WinQueryWindowPos(m_hFrame
, &vSwp
); 
 758         m_bIconized 
= ( vSwp
.fl 
& SWP_MINIMIZE 
) == SWP_MINIMIZE 
; 
 759         ::WinQueryWindowPos(m_hWnd
, &m_vSwpClient
); 
 760         ::WinSendMsg(m_hFrame
, WM_UPDATEFRAME
, (MPARAM
)~0, 0); 
 761         ::WinQueryWindowPos(m_hWnd
, &vSwp
); 
 762         ::WinEnableWindow(m_hFrame
, TRUE
); 
 765         // Deal with children 
 767         MoveChildren(m_vSwpClient
.cy 
- vSwp
.cy
); 
 768         vEvent
.SetEventObject(this); 
 769         GetEventHandler()->ProcessEvent(vEvent
); 
 774         // Try to highlight the correct window (the parent) 
 778             HWND                    hWndParent 
= GetHwndOf(GetParent()); 
 780             ::WinQueryWindowPos(hWndParent
, &vSwp
); 
 781             m_bIconized 
= (vSwp
.fl 
& SWP_MINIMIZE
)==SWP_MINIMIZE
; 
 782             ::WinEnableWindow(hWndParent
, TRUE
); 
 786 } // end of wxTopLevelWindowOS2::Show 
 788 // ---------------------------------------------------------------------------- 
 789 // wxTopLevelWindowOS2 maximize/minimize 
 790 // ---------------------------------------------------------------------------- 
 792 void wxTopLevelWindowOS2::Maximize( 
 799         // Just maximize it directly 
 801         DoShowWindow(bMaximize 
? SWP_MAXIMIZE 
: SWP_RESTORE
); 
 806         // We can't maximize the hidden frame because it shows it as well, so 
 807         // just remember that we should do it later in this case 
 809         m_bMaximizeOnShow 
= bMaximize
; 
 811 } // end of wxTopLevelWindowOS2::Maximize 
 813 bool wxTopLevelWindowOS2::IsMaximized() const 
 815     ::WinQueryWindowPos(m_hFrame
, (PSWP
)&m_vSwp
); 
 816     return (m_vSwp
.fl 
& SWP_MAXIMIZE
) == SWP_MAXIMIZE
; 
 817 } // end of wxTopLevelWindowOS2::IsMaximized 
 819 void wxTopLevelWindowOS2::Iconize( 
 823     DoShowWindow(bIconize 
? SWP_MINIMIZE 
: SWP_RESTORE
); 
 824 } // end of wxTopLevelWindowOS2::Iconize 
 826 bool wxTopLevelWindowOS2::IsIconized() const 
 828     // also update the current state 
 829     ::WinQueryWindowPos(m_hFrame
, (PSWP
)&m_vSwp
); 
 830     if (m_vSwp
.fl 
& SWP_MINIMIZE
) 
 831         ((wxTopLevelWindow
*)this)->m_bIconized 
= TRUE
; 
 833         ((wxTopLevelWindow
*)this)->m_bIconized 
= FALSE
; 
 835 } // end of wxTopLevelWindowOS2::IsIconized 
 837 void wxTopLevelWindowOS2::Restore() 
 839     DoShowWindow(SWP_RESTORE
); 
 840 } // end of wxTopLevelWindowOS2::Restore 
 842 // generate an artificial resize event 
 843 void wxTopLevelWindowOS2::SendSizeEvent() 
 847         RECTL                       vRect 
= wxGetWindowRect(GetHwnd()); 
 849         (void)::WinPostMsg( m_hFrame
 
 851                            ,MPFROM2SHORT(vRect
.xRight 
- vRect
.xLeft
, vRect
.yTop 
- vRect
.yBottom
) 
 852                            ,MPFROM2SHORT(vRect
.xRight 
- vRect
.xLeft
, vRect
.yTop 
- vRect
.yBottom
) 
 855 } // end of wxTopLevelWindowOS2::SendSizeEvent 
 857 // ---------------------------------------------------------------------------- 
 858 // wxTopLevelWindowOS2 fullscreen 
 859 // ---------------------------------------------------------------------------- 
 861 bool wxTopLevelWindowOS2::ShowFullScreen( bool bShow
, 
 869         m_bFsIsShowing 
= true; 
 873         // Zap the frame borders 
 877         // Save the 'normal' window lStyle 
 879         m_lFsOldWindowStyle 
= ::WinQueryWindowULong( (HWND
)GetHWND() 
 884         // Save the old position, width & height, maximize state 
 886         m_vFsOldSize 
= GetRect(); 
 887         m_bFsIsMaximized 
= IsMaximized(); 
 890         // Decide which window lStyle flags to turn off 
 892         LONG lNewStyle 
= m_lFsOldWindowStyle
; 
 895         if (lStyle 
& wxFULLSCREEN_NOBORDER
) 
 896             lOffFlags 
|= FCF_BORDER
; 
 897         if (lStyle 
& wxFULLSCREEN_NOCAPTION
) 
 898             lOffFlags 
|= (FCF_TASKLIST 
| FCF_SYSMENU
); 
 900         lNewStyle 
&= (~lOffFlags
); 
 903         // Change our window style to be compatible with full-screen mode 
 905         ::WinSetWindowULong( (HWND
)GetHWND() 
 911         // Resize to the size of the desktop 
 915         RECTL vRect 
= wxGetWindowRect(HWND_DESKTOP
); 
 917         nWidth 
= vRect
.xRight 
- vRect
.xLeft
; 
 918         nHeight 
= vRect
.yTop 
- vRect
.yBottom
; 
 920         SetSize( nWidth
, nHeight 
); 
 923         // Now flush the window style cache and actually go full-screen 
 925         ::WinSetWindowPos( m_hFrame
 
 934         wxSize 
full( nWidth
, nHeight 
); 
 935         wxSizeEvent 
vEvent( full
, GetId() ); 
 936         GetEventHandler()->ProcessEvent(vEvent
); 
 944         m_bFsIsShowing 
= false; 
 945         Maximize(m_bFsIsMaximized
); 
 946         ::WinSetWindowULong( (HWND
)GetHWND() 
 950         ::WinSetWindowPos( m_hFrame
 
 960 } // end of wxTopLevelWindowOS2::ShowFullScreen 
 962 // ---------------------------------------------------------------------------- 
 963 // wxTopLevelWindowOS2 misc 
 964 // ---------------------------------------------------------------------------- 
 966 void wxTopLevelWindowOS2::SetIcon( 
 970     SetIcons(wxIconBundle(rIcon
)); 
 971 } // end of wxTopLevelWindowOS2::SetIcon 
 973 void wxTopLevelWindowOS2::SetIcons( 
 974   const wxIconBundle
&               rIcons
 
 980     wxTopLevelWindowBase::SetIcons(rIcons
); 
 982     const wxIcon
&                   vIcon 
= rIcons
.GetIcon(wxSize(32, 32)); 
 984     if (vIcon
.Ok() && vIcon
.GetWidth() == 32 && vIcon
.GetHeight() == 32) 
 986         ::WinSendMsg( m_hFrame
 
 988                      ,(MPARAM
)((HPOINTER
)vIcon
.GetHICON()) 
 991         ::WinSendMsg( m_hFrame
 
 997 } // end of wxTopLevelWindowOS2::SetIcon 
 999 bool wxTopLevelWindowOS2::EnableCloseButton( 
1004     // Get system (a.k.a. window) menu 
1006     HMENU                           hMenu 
= ::WinWindowFromID(m_hFrame
, FID_SYSMENU
); 
1010         wxLogLastError(_T("GetSystemMenu")); 
1015     // Enabling/disabling the close item from it also automatically 
1016     // disables/enables the close title bar button 
1019         (void)::WinSendMsg( hMenu
 
1021                            ,MPFROM2SHORT(SC_CLOSE
, FALSE
) 
1022                            ,MPFROM2SHORT(MIA_DISABLED
, FALSE
) 
1025         (void)::WinSendMsg( hMenu
 
1027                            ,MPFROM2SHORT(SC_CLOSE
, FALSE
) 
1028                            ,MPFROM2SHORT(MIA_DISABLED
, MIA_DISABLED
) 
1032     // Update appearance immediately 
1034     ::WinSendMsg( m_hFrame
 
1040 } // end of wxTopLevelWindowOS2::EnableCloseButton 
1042 // ============================================================================ 
1043 // wxTLWHiddenParentModule implementation 
1044 // ============================================================================ 
1046 HWND          
wxTLWHiddenParentModule::m_shWnd 
= NULL
; 
1047 const wxChar
* wxTLWHiddenParentModule::m_szClassName 
= NULL
; 
1049 bool wxTLWHiddenParentModule::OnInit() 
1052     m_szClassName 
= NULL
; 
1054 } // end of wxTLWHiddenParentModule::OnInit 
1056 void wxTLWHiddenParentModule::OnExit() 
1060         if (!::WinDestroyWindow(m_shWnd
)) 
1062             wxLogLastError(_T("DestroyWindow(hidden TLW parent)")); 
1067     m_szClassName 
= NULL
; 
1068 } // end of wxTLWHiddenParentModule::OnExit 
1071 HWND 
wxTLWHiddenParentModule::GetHWND() 
1077             static const wxChar
*    zHIDDEN_PARENT_CLASS 
= _T("wxTLWHiddenParent"); 
1079             if (!::WinRegisterClass( wxGetInstance() 
1080                                     ,(PSZ
)zHIDDEN_PARENT_CLASS
 
1086                 wxLogLastError(_T("RegisterClass(\"wxTLWHiddenParent\")")); 
1090                 m_szClassName 
= zHIDDEN_PARENT_CLASS
; 
1093         m_shWnd 
= ::WinCreateWindow( HWND_DESKTOP
 
1109             wxLogLastError(_T("CreateWindow(hidden TLW parent)")); 
1113 } // end of wxTLWHiddenParentModule::GetHWND