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 // list of all frames and modeless dialogs 
  56 wxWindowList wxModelessWindows
; 
  58 // the name of the default wxWidgets class 
  59 extern void          wxAssociateWinWithHandle( HWND         hWnd
 
  62 bool                 wxTopLevelWindowOS2::m_sbInitialized 
= FALSE
; 
  63 wxWindow
*            wxTopLevelWindowOS2::m_spHiddenParent 
= NULL
; 
  65 // ============================================================================ 
  66 // wxTopLevelWindowOS2 implementation 
  67 // ============================================================================ 
  69 BEGIN_EVENT_TABLE(wxTopLevelWindowOS2
, wxTopLevelWindowBase
) 
  70     EVT_ACTIVATE(wxTopLevelWindowOS2::OnActivate
) 
  73 // ============================================================================ 
  74 // wxTopLevelWindowMSW implementation 
  75 // ============================================================================ 
  78 MRESULT EXPENTRY 
wxDlgProc( HWND 
WXUNUSED(hWnd
) 
  80                            ,void * WXUNUSED(wParam
) 
  81                            ,void * WXUNUSED(lParam
) 
  88             // For this message, returning TRUE tells system to set focus to 
  89             // the first control in the dialog box, but we set the focus 
  90             // ourselves, however in OS/2 we must return true to enable the dialog 
  95             // For all the other ones, FALSE means that we didn't process the 
  98             return (MRESULT
)FALSE
; 
 100 } // end of wxDlgProc 
 102 // ---------------------------------------------------------------------------- 
 103 // wxTLWHiddenParentModule: used to manage the hidden parent window (we need a 
 104 // module to ensure that the window is always deleted) 
 105 // ---------------------------------------------------------------------------- 
 107 class wxTLWHiddenParentModule 
: public wxModule
 
 111     // Module init/finalize 
 113     virtual bool OnInit(void); 
 114     virtual void OnExit(void); 
 117     // Get the hidden window (creates on demand) 
 119     static HWND 
GetHWND(void); 
 123     // The HWND of the hidden parent 
 128     // The class used to create it 
 130     static const wxChar
*            m_szClassName
; 
 131     DECLARE_DYNAMIC_CLASS(wxTLWHiddenParentModule
) 
 132 }; // end of CLASS wxTLWHiddenParentModule 
 134 IMPLEMENT_DYNAMIC_CLASS(wxTLWHiddenParentModule
, wxModule
) 
 136 // ---------------------------------------------------------------------------- 
 137 // wxTopLevelWindowOS2 creation 
 138 // ---------------------------------------------------------------------------- 
 140 void wxTopLevelWindowOS2::Init() 
 142     m_bIconized 
= m_bMaximizeOnShow 
= FALSE
; 
 145     // Unlike (almost?) all other windows, frames are created hidden 
 150     // Data to save/restore when calling ShowFullScreen 
 152     m_lFsOldWindowStyle 
= 0; 
 153     m_bFsIsMaximized    
= FALSE
; 
 154     m_bFsIsShowing      
= FALSE
; 
 156     m_hFrame    
= NULLHANDLE
; 
 157     memset(&m_vSwp
, 0, sizeof(SWP
)); 
 158     memset(&m_vSwpClient
, 0, sizeof(SWP
)); 
 159     m_pWinLastFocused 
= (wxWindow 
*)NULL
; 
 160 } // end of wxTopLevelWindowIOS2::Init 
 162 void wxTopLevelWindowOS2::OnActivate( 
 163   wxActivateEvent
&                  rEvent
 
 166     if (rEvent
.GetActive()) 
 169         // Restore focus to the child which was last focused 
 171         wxLogTrace(_T("focus"), _T("wxTLW %08lx activated."), m_hWnd
); 
 173         wxWindow
*                   pParent 
= m_pWinLastFocused 
? m_pWinLastFocused
->GetParent() 
 180         wxSetFocusToChild( pParent
 
 187         // Remember the last focused child if it is our child 
 189         m_pWinLastFocused 
= FindFocus(); 
 192         // So we NULL it out if it's a child from some other frame 
 194         wxWindow
*                   pWin 
= m_pWinLastFocused
; 
 198             if (pWin
->IsTopLevel()) 
 202                     m_pWinLastFocused 
= NULL
; 
 206             pWin 
= pWin
->GetParent(); 
 209         wxLogTrace(_T("focus"), 
 210                    _T("wxTLW %08lx deactivated, last focused: %08lx."), 
 212                    m_pWinLastFocused 
? GetHwndOf(m_pWinLastFocused
) 
 216 } // end of wxTopLevelWindowOS2::OnActivate 
 218 WXDWORD 
wxTopLevelWindowOS2::OS2GetStyle( 
 220 , WXDWORD
*                          pdwExflags
 
 223     long                            lMsflags 
= wxWindow::OS2GetStyle( (lStyle 
& ~wxBORDER_MASK
) | wxBORDER_NONE
 
 227     if ((lStyle 
& wxDEFAULT_FRAME_STYLE
) == wxDEFAULT_FRAME_STYLE
) 
 228         lMsflags 
|= FCF_SIZEBORDER 
| FCF_TITLEBAR 
| FCF_SYSMENU 
| 
 229                     FCF_MINMAX 
| FCF_TASKLIST
; 
 231     if ((lStyle 
& wxCAPTION
) == wxCAPTION
) 
 232         lMsflags 
|= FCF_TASKLIST
; 
 234         lMsflags 
|= FCF_NOMOVEWITHOWNER
; 
 236     if ((lStyle 
& wxVSCROLL
) == wxVSCROLL
) 
 237         lMsflags 
|= FCF_VERTSCROLL
; 
 238     if ((lStyle 
& wxHSCROLL
) == wxHSCROLL
) 
 239         lMsflags 
|= FCF_HORZSCROLL
; 
 240     if (lStyle 
& wxMINIMIZE_BOX
) 
 241         lMsflags 
|= FCF_MINBUTTON
; 
 242     if (lStyle 
& wxMAXIMIZE_BOX
) 
 243         lMsflags 
|= FCF_MAXBUTTON
; 
 244     if (lStyle 
& wxTHICK_FRAME
) 
 245         lMsflags 
|= FCF_DLGBORDER
; 
 246     if (lStyle 
& wxSYSTEM_MENU
) 
 247         lMsflags 
|= FCF_SYSMENU
; 
 248     if (lStyle 
& wxCAPTION
) 
 249         lMsflags 
|= FCF_TASKLIST
; 
 250     if (lStyle 
& wxCLIP_CHILDREN
) 
 252         // Invalid for frame windows under PM 
 255     if (lStyle 
& wxTINY_CAPTION_VERT
) 
 256         lMsflags 
|= FCF_TASKLIST
; 
 257     if (lStyle 
& wxTINY_CAPTION_HORIZ
) 
 258         lMsflags 
|= FCF_TASKLIST
; 
 260     if ((lStyle 
& wxTHICK_FRAME
) == 0) 
 261         lMsflags 
|= FCF_BORDER
; 
 262     if (lStyle 
& wxFRAME_TOOL_WINDOW
) 
 263         *pdwExflags 
= kFrameToolWindow
; 
 265     if (lStyle 
& wxSTAY_ON_TOP
) 
 266         lMsflags 
|= FCF_SYSMODAL
; 
 269 } // end of wxTopLevelWindowOS2::OS2GetCreateWindowFlags 
 271 WXHWND 
wxTopLevelWindowOS2::OS2GetParent() const 
 273     HWND                            hWndParent 
= NULL
; 
 276     // For the frames without wxFRAME_FLOAT_ON_PARENT style we should use NULL 
 277     // parent HWND or it would be always on top of its parent which is not what 
 278     // we usually want (in fact, we only want it for frames with the 
 279     // wxFRAME_FLOAT_ON_PARENT flag) 
 281     if (HasFlag(wxFRAME_FLOAT_ON_PARENT
) ) 
 283         const wxWindow
*             pParent 
= GetParent(); 
 288             // This flag doesn't make sense then and will be ignored 
 290             wxFAIL_MSG( _T("wxFRAME_FLOAT_ON_PARENT but no parent?") ); 
 294             hWndParent 
= GetHwndOf(pParent
); 
 297     //else: don't float on parent, must not be owned 
 300     // Now deal with the 2nd taskbar-related problem (see comments above in 
 303     if (HasFlag(wxFRAME_NO_TASKBAR
) && !hWndParent
) 
 308         hWndParent 
= wxTLWHiddenParentModule::GetHWND(); 
 310     return (WXHWND
)hWndParent
; 
 311 } // end of wxTopLevelWindowOS2::OS2GetParent 
 313 bool wxTopLevelWindowOS2::CreateDialog( 
 315 , const wxString
&                   rsTitle
 
 316 , const wxPoint
&                    rPos
 
 317 , const wxSize
&                     rSize
 
 320     wxWindow
*                       pParent 
= GetParent(); 
 323     // For the dialogs without wxDIALOG_NO_PARENT style, use the top level 
 324     // app window as parent - this avoids creating modal dialogs without 
 327     if (!pParent 
&& !(GetWindowStyleFlag() & wxDIALOG_NO_PARENT
)) 
 329         pParent 
= wxTheApp
->GetTopWindow(); 
 334             // Don't use transient windows as parents, this is dangerous as it 
 335             // can lead to a crash if the parent is destroyed before the child 
 337             // also don't use the window which is currently hidden as then the 
 338             // dialog would be hidden as well 
 339             if ((pParent
->GetExtraStyle() & wxWS_EX_TRANSIENT
) || 
 351         hWndOwner 
= GetHwndOf(pParent
); 
 353         hWndOwner 
= HWND_DESKTOP
; 
 355     hWndDlg 
= ::WinLoadDlg( HWND_DESKTOP
 
 359                            ,(ULONG
)ulDlgTemplate
 
 363     m_hWnd 
= (WXHWND
) hWndDlg
; 
 367         wxFAIL_MSG(wxT("Did you forget to include wx/os2/wx.rc in your resources?")); 
 369         wxLogSysError(wxT("Can't create dialog using template '%ld'"), ulDlgTemplate
); 
 375     // Move the dialog to its initial position without forcing repainting 
 382     if (!OS2GetCreateWindowCoords( rPos
 
 390         nX 
= nWidth 
= (int)CW_USEDEFAULT
; 
 394     // We can't use CW_USEDEFAULT here as we're not calling CreateWindow() 
 395     // and passing CW_USEDEFAULT to MoveWindow() results in resizing the 
 396     // window to (0, 0) size which breaks quite a lot of things, e.g. the 
 397     // sizer calculation in wxSizer::Fit() 
 399     if (nWidth 
== (int)CW_USEDEFAULT
) 
 402         // The exact number doesn't matter, the dialog will be resized 
 403         // again soon anyhow but it should be big enough to allow 
 404         // calculation relying on "totalSize - clientSize > 0" work, i.e. 
 405         // at least greater than the title bar height 
 407         nWidth 
= nHeight 
= 100; 
 409     if (nX 
== (int)CW_USEDEFAULT
) 
 412         // Centre it on the screen - what else can we do? 
 414         wxSize                      vSizeDpy 
= wxGetDisplaySize(); 
 416         nX 
= (vSizeDpy
.x 
- nWidth
) / 2; 
 417         nY 
= (vSizeDpy
.y 
- nHeight
) / 2; 
 419     m_backgroundColour
.Set(wxString("LIGHT GREY")); 
 421     LONG                            lColor 
= (LONG
)m_backgroundColour
.GetPixel(); 
 423     if (!::WinSetPresParam( m_hWnd
 
 432     ::WinSetWindowPos( GetHwnd() 
 438                       ,SWP_MOVE 
| SWP_SIZE 
| SWP_ZORDER 
| SWP_SHOW 
| SWP_ACTIVATE
 
 440     ::WinQueryWindowPos(GetHwnd(), GetSwp()); 
 444 } // end of wxTopLevelWindowOS2::CreateDialog 
 446 bool wxTopLevelWindowOS2::CreateFrame( 
 447   const wxString
&                   rsTitle
 
 448 , const wxPoint
&                    rPos
 
 449 , const wxSize
&                     rSize
 
 453     WXDWORD                         lFlags 
= OS2GetCreateWindowFlags(&lExflags
); 
 454     long                            lStyle 
= GetWindowStyleFlag(); 
 457     int                             nWidth 
= rSize
.x
; 
 458     int                             nHeight 
= rSize
.y
; 
 459     ULONG                           ulStyleFlags 
= 0L; 
 462     wxWindow
*                       pParent 
= GetParent(); 
 468         hParent 
= GetHwndOf(pParent
); 
 470         hParent 
= HWND_DESKTOP
; 
 472     if ((lStyle 
& wxMINIMIZE
) || (lStyle 
& wxICONIZE
)) 
 473         ulStyleFlags 
|= WS_MINIMIZED
; 
 474     if (lStyle 
& wxMAXIMIZE
) 
 475         ulStyleFlags 
|= WS_MAXIMIZED
; 
 478     // Clear the visible flag, we always call show 
 480     ulStyleFlags 
&= (unsigned long)~WS_VISIBLE
; 
 484     // Create the frame window:  We break ranks with other ports now 
 485     // and instead of calling down into the base wxWindow class' OS2Create 
 486     // we do all our own stuff here.  We will set the needed pieces 
 487     // of wxWindow manually, here. 
 490      hFrame 
= ::WinCreateStdWindow( hParent
 
 491                                    ,ulStyleFlags          
// frame-window style 
 492                                    ,(PULONG
)&lFlags       
// window style 
 493                                    ,(PSZ
)wxFrameClassName 
// class name 
 494                                    ,(PSZ
)rsTitle
.c_str()  // window title 
 495                                    ,0L                    // default client style 
 496                                    ,NULLHANDLE            
// resource in executable file 
 498                                    ,&hClient              
// receives client window handle 
 502         vError 
= ::WinGetLastError(vHabmain
); 
 503         sError 
= wxPMErrorToStr(vError
); 
 504         wxLogError("Error creating frame. Error: %s\n", sError
.c_str()); 
 509     // wxWindow class' m_hWnd set here and needed associations 
 513     wxAssociateWinWithHandle(m_hWnd
, this); 
 514     wxAssociateWinWithHandle(m_hFrame
, this); 
 516     m_backgroundColour
.Set(wxString("MEDIUM GREY")); 
 518     LONG                            lColor 
= (LONG
)m_backgroundColour
.GetPixel(); 
 520     if (!::WinSetPresParam( m_hWnd
 
 526         vError 
= ::WinGetLastError(vHabmain
); 
 527         sError 
= wxPMErrorToStr(vError
); 
 528         wxLogError("Error creating frame. Error: %s\n", sError
.c_str()); 
 533     // Now need to subclass window.  Instead of calling the SubClassWin in wxWindow 
 534     // we manually subclass here because we don't want to use the main wxWndProc 
 537     m_fnOldWndProc 
= (WXFARPROC
) ::WinSubclassWindow(m_hFrame
, (PFNWP
)wxFrameMainWndProc
); 
 540     // Now size everything.  If adding a menu the client will need to be resized. 
 545         nY 
= pParent
->GetSize().y 
- (nY 
+ nHeight
); 
 551         ::WinQueryWindowRect(HWND_DESKTOP
, &vRect
); 
 552         nY 
= vRect
.yTop 
- (nY 
+ nHeight
); 
 554     if (!::WinSetWindowPos( m_hFrame
 
 560                            ,SWP_SIZE 
| SWP_MOVE 
| SWP_ACTIVATE 
| SWP_ZORDER
 
 563         vError 
= ::WinGetLastError(vHabmain
); 
 564         sError 
= wxPMErrorToStr(vError
); 
 565         wxLogError("Error sizing frame. Error: %s\n", sError
.c_str()); 
 568     lStyle 
=  ::WinQueryWindowULong( m_hWnd
 
 571     lStyle 
|= WS_CLIPCHILDREN
; 
 572     ::WinSetWindowULong( m_hWnd
 
 577 } // end of wxTopLevelWindowOS2::CreateFrame 
 579 bool wxTopLevelWindowOS2::Create( 
 582 , const wxString
&                   rsTitle
 
 583 , const wxPoint
&                    rPos
 
 584 , const wxSize
&                     rSizeOrig
 
 586 , const wxString
&                   rsName
 
 593     m_windowStyle 
= lStyle
; 
 595     m_windowId 
= vId 
== -1 ? NewControlId() : vId
; 
 597     // always create a frame of some reasonable, even if arbitrary, size (at 
 598     // least for MSW compatibility) 
 599     wxSize rSize 
= rSizeOrig
; 
 600     if ( rSize
.x 
== -1 || rSize
.y 
== -1 ) 
 602         wxSize sizeDpy 
= wxGetDisplaySize(); 
 604             rSize
.x 
= sizeDpy
.x 
/ 3; 
 606             rSize
.y 
= sizeDpy
.y 
/ 5; 
 609     wxTopLevelWindows
.Append(this); 
 611         pParent
->AddChild(this); 
 613     if (GetExtraStyle() & wxTOPLEVEL_EX_DIALOG
) 
 616         // We have different dialog templates to allows creation of dialogs 
 617         // with & without captions under OS2indows, resizeable or not (but a 
 618         // resizeable dialog always has caption - otherwise it would look too 
 623         if (lStyle 
& wxRESIZE_BORDER
) 
 624             ulDlgTemplate 
= (ULONG
)kResizeableDialog
; 
 625         else if (lStyle 
& wxCAPTION
) 
 626             ulDlgTemplate 
= (ULONG
)kCaptionDialog
; 
 628             ulDlgTemplate 
= (ULONG
)kNoCaptionDialog
; 
 629         return CreateDialog( ulDlgTemplate
 
 637         return CreateFrame( rsTitle
 
 642 } // end of wxTopLevelWindowOS2::Create 
 644 wxTopLevelWindowOS2::~wxTopLevelWindowOS2() 
 646     if (wxModelessWindows
.Find(this)) 
 647         wxModelessWindows
.DeleteObject(this); 
 650     // After destroying an owned window, Windows activates the next top level 
 651     // window in Z order but it may be different from our owner (to reproduce 
 652     // this simply Alt-TAB to another application and back before closing the 
 653     // owned frame) whereas we always want to yield activation to our parent 
 655     if (HasFlag(wxFRAME_FLOAT_ON_PARENT
)) 
 657         wxWindow
*                   pParent 
= GetParent(); 
 661             ::WinSetWindowPos( GetHwndOf(pParent
) 
 668 } // end of wxTopLevelWindowOS2::~wxTopLevelWindowOS2 
 670 // ---------------------------------------------------------------------------- 
 671 // wxTopLevelWindowOS2 client size 
 672 // ---------------------------------------------------------------------------- 
 674 void wxTopLevelWindowOS2::DoSetClientSize( 
 680     // Call GetClientAreaOrigin() to take the toolbar into account 
 682     wxPoint                         vPt 
= GetClientAreaOrigin(); 
 687     wxWindow::DoSetClientSize( nWidth
 
 690 } // end of wxTopLevelWindowOS2::DoSetClientSize 
 692 void wxTopLevelWindowOS2::DoGetClientSize( 
 697     wxWindow::DoGetClientSize( pnX
 
 701     wxPoint                         vPt 
= GetClientAreaOrigin(); 
 708 } // end of wxTopLevelWindowOS2::DoGetClientSize 
 710 // ---------------------------------------------------------------------------- 
 711 // wxTopLevelWindowOS2 showing 
 712 // ---------------------------------------------------------------------------- 
 714 void wxTopLevelWindowOS2::DoShowWindow( 
 718     ::WinShowWindow(m_hFrame
, (BOOL
)(nShowCmd 
& SWP_SHOW
)); 
 721     // Need to artificially send a size event as wxApps often expect to do some 
 722     // final child control sizing 
 724     m_bIconized 
= nShowCmd 
== SWP_MINIMIZE
; 
 725 } // end of wxTopLevelWindowOS2::DoShowWindow 
 727 bool wxTopLevelWindowOS2::Show( 
 734     if (bShow 
!= IsShown() ) 
 744         if (m_bMaximizeOnShow
) 
 746             nShowCmd 
= SWP_MAXIMIZE
; 
 747             m_bMaximizeOnShow 
= FALSE
; 
 758     DoShowWindow(nShowCmd
); 
 762         wxActivateEvent             
vEvent(wxEVT_ACTIVATE
, TRUE
, m_windowId
); 
 764         ::WinQueryWindowPos(m_hFrame
, &vSwp
); 
 765         m_bIconized 
= vSwp
.fl 
& SWP_MINIMIZE
; 
 766         ::WinQueryWindowPos(m_hWnd
, &m_vSwpClient
); 
 767         ::WinSendMsg(m_hFrame
, WM_UPDATEFRAME
, (MPARAM
)~0, 0); 
 768         ::WinQueryWindowPos(m_hWnd
, &vSwp
); 
 769         ::WinEnableWindow(m_hFrame
, TRUE
); 
 772         // Deal with children 
 774         MoveChildren(m_vSwpClient
.cy 
- vSwp
.cy
); 
 775         vEvent
.SetEventObject(this); 
 776         GetEventHandler()->ProcessEvent(vEvent
); 
 781         // Try to highlight the correct window (the parent) 
 785             HWND                    hWndParent 
= GetHwndOf(GetParent()); 
 787             ::WinQueryWindowPos(hWndParent
, &vSwp
); 
 788             m_bIconized 
= vSwp
.fl 
& SWP_MINIMIZE
; 
 789             ::WinEnableWindow(hWndParent
, TRUE
); 
 793 } // end of wxTopLevelWindowOS2::Show 
 795 // ---------------------------------------------------------------------------- 
 796 // wxTopLevelWindowOS2 maximize/minimize 
 797 // ---------------------------------------------------------------------------- 
 799 void wxTopLevelWindowOS2::Maximize( 
 806         // Just maximize it directly 
 808         DoShowWindow(bMaximize 
? SWP_MAXIMIZE 
: SWP_RESTORE
); 
 813         // We can't maximize the hidden frame because it shows it as well, so 
 814         // just remember that we should do it later in this case 
 816         m_bMaximizeOnShow 
= bMaximize
; 
 818 } // end of wxTopLevelWindowOS2::Maximize 
 820 bool wxTopLevelWindowOS2::IsMaximized() const 
 823     ::WinQueryWindowPos(m_hFrame
, (PSWP
)&m_vSwp
); 
 824     return (m_vSwp
.fl 
& SWP_MAXIMIZE
); 
 825 } // end of wxTopLevelWindowOS2::IsMaximized 
 827 void wxTopLevelWindowOS2::Iconize( 
 831     DoShowWindow(bIconize 
? SWP_MINIMIZE 
: SWP_RESTORE
); 
 832 } // end of wxTopLevelWindowOS2::Iconize 
 834 bool wxTopLevelWindowOS2::IsIconized() const 
 836     // also update the current state 
 837     ::WinQueryWindowPos(m_hFrame
, (PSWP
)&m_vSwp
); 
 838     if (m_vSwp
.fl 
& SWP_MINIMIZE
) 
 839         ((wxTopLevelWindow
*)this)->m_bIconized 
= TRUE
; 
 841         ((wxTopLevelWindow
*)this)->m_bIconized 
= FALSE
; 
 843 } // end of wxTopLevelWindowOS2::IsIconized 
 845 void wxTopLevelWindowOS2::Restore() 
 847     DoShowWindow(SWP_RESTORE
); 
 848 } // end of wxTopLevelWindowOS2::Restore 
 850 // generate an artificial resize event 
 851 void wxTopLevelWindowOS2::SendSizeEvent() 
 855         RECTL                       vRect 
= wxGetWindowRect(GetHwnd()); 
 857         (void)::WinPostMsg( m_hFrame
 
 859                            ,MPFROM2SHORT(vRect
.xRight 
- vRect
.xLeft
, vRect
.yTop 
- vRect
.yBottom
) 
 860                            ,MPFROM2SHORT(vRect
.xRight 
- vRect
.xLeft
, vRect
.yTop 
- vRect
.yBottom
) 
 863 } // end of wxTopLevelWindowOS2::SendSizeEvent 
 865 // ---------------------------------------------------------------------------- 
 866 // wxTopLevelWindowOS2 fullscreen 
 867 // ---------------------------------------------------------------------------- 
 869 bool wxTopLevelWindowOS2::ShowFullScreen( 
 879         m_bFsIsShowing 
= TRUE
; 
 883         // Zap the frame borders 
 887         // Save the 'normal' window lStyle 
 889         m_lFsOldWindowStyle 
= ::WinQueryWindowULong( (HWND
)GetHWND() 
 894         // Save the old position, width & height, maximize state 
 896         m_vFsOldSize 
= GetRect(); 
 897         m_bFsIsMaximized 
= IsMaximized(); 
 900         // Decide which window lStyle flags to turn off 
 902         LONG                        lNewStyle 
= m_lFsOldWindowStyle
; 
 905         if (lStyle 
& wxFULLSCREEN_NOBORDER
) 
 906             lOffFlags 
|= FCF_BORDER
; 
 907         if (lStyle 
& wxFULLSCREEN_NOCAPTION
) 
 908             lOffFlags 
|= (FCF_TASKLIST 
| FCF_SYSMENU
); 
 910         lNewStyle 
&= (~lOffFlags
); 
 913         // Change our window style to be compatible with full-screen mode 
 915         ::WinSetWindowULong( (HWND
)GetHWND() 
 921         // Resize to the size of the desktop 
 925         RECTL                       vRect 
= wxGetWindowRect(HWND_DESKTOP
); 
 927         nWidth 
= vRect
.xRight 
- vRect
.xLeft
; 
 928         nHeight 
= vRect
.yTop 
- vRect
.yBottom
; 
 935         // Now flush the window style cache and actually go full-screen 
 937         ::WinSetWindowPos( m_hFrame
 
 946         wxSizeEvent                 
vEvent( wxSize( nWidth
 
 952         GetEventHandler()->ProcessEvent(vEvent
); 
 960         m_bFsIsShowing 
= FALSE
; 
 961         Maximize(m_bFsIsMaximized
); 
 962         ::WinSetWindowULong( (HWND
)GetHWND() 
 966         ::WinSetWindowPos( m_hFrame
 
 976 } // end of wxTopLevelWindowOS2::ShowFullScreen 
 978 // ---------------------------------------------------------------------------- 
 979 // wxTopLevelWindowOS2 misc 
 980 // ---------------------------------------------------------------------------- 
 982 void wxTopLevelWindowOS2::SetIcon( 
 986     SetIcons(wxIconBundle(rIcon
)); 
 987 } // end of wxTopLevelWindowOS2::SetIcon 
 989 void wxTopLevelWindowOS2::SetIcons( 
 990   const wxIconBundle
&               rIcons
 
 996     wxTopLevelWindowBase::SetIcons(rIcons
); 
 998     const wxIcon
&                   vIcon 
= rIcons
.GetIcon(wxSize(32, 32)); 
1000     if (vIcon
.Ok() && vIcon
.GetWidth() == 32 && vIcon
.GetHeight() == 32) 
1002         ::WinSendMsg( m_hFrame
 
1004                      ,(MPARAM
)((HPOINTER
)vIcon
.GetHICON()) 
1007         ::WinSendMsg( m_hFrame
 
1013 } // end of wxTopLevelWindowOS2::SetIcon 
1015 bool wxTopLevelWindowOS2::EnableCloseButton( 
1020     // Get system (a.k.a. window) menu 
1022     HMENU                           hMenu 
= ::WinWindowFromID(m_hFrame
, FID_SYSMENU
); 
1026         wxLogLastError(_T("GetSystemMenu")); 
1031     // Enabling/disabling the close item from it also automatically 
1032     // disables/enables the close title bar button 
1035         (void)::WinSendMsg( hMenu
 
1037                            ,MPFROM2SHORT(SC_CLOSE
, FALSE
) 
1038                            ,MPFROM2SHORT(MIA_DISABLED
, FALSE
) 
1041         (void)::WinSendMsg( hMenu
 
1043                            ,MPFROM2SHORT(SC_CLOSE
, FALSE
) 
1044                            ,MPFROM2SHORT(MIA_DISABLED
, MIA_DISABLED
) 
1048     // Update appearance immediately 
1050     ::WinSendMsg( m_hFrame
 
1056 } // end of wxTopLevelWindowOS2::EnableCloseButton 
1058 // ============================================================================ 
1059 // wxTLWHiddenParentModule implementation 
1060 // ============================================================================ 
1062 HWND          
wxTLWHiddenParentModule::m_shWnd 
= NULL
; 
1063 const wxChar
* wxTLWHiddenParentModule::m_szClassName 
= NULL
; 
1065 bool wxTLWHiddenParentModule::OnInit() 
1068     m_szClassName 
= NULL
; 
1070 } // end of wxTLWHiddenParentModule::OnInit 
1072 void wxTLWHiddenParentModule::OnExit() 
1076         if (!::WinDestroyWindow(m_shWnd
)) 
1078             wxLogLastError(_T("DestroyWindow(hidden TLW parent)")); 
1083     m_szClassName 
= NULL
; 
1084 } // end of wxTLWHiddenParentModule::OnExit 
1087 HWND 
wxTLWHiddenParentModule::GetHWND() 
1093             static const wxChar
*    zHIDDEN_PARENT_CLASS 
= _T("wxTLWHiddenParent"); 
1095             if (!::WinRegisterClass( wxGetInstance() 
1096                                     ,zHIDDEN_PARENT_CLASS
 
1102                 wxLogLastError(_T("RegisterClass(\"wxTLWHiddenParent\")")); 
1106                 m_szClassName 
= zHIDDEN_PARENT_CLASS
; 
1109         m_shWnd 
= ::WinCreateWindow( HWND_DESKTOP
 
1125             wxLogLastError(_T("CreateWindow(hidden TLW parent)")); 
1129 } // end of wxTLWHiddenParentModule::GetHWND