]>
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 
 310 bool wxTopLevelWindowOS2::CreateDialog( 
 312 , const wxString
&                   rsTitle
 
 313 , const wxPoint
&                    rPos
 
 314 , const wxSize
&                     rSize
 
 317     wxWindow
*                       pParent 
= GetParent(); 
 320     // For the dialogs without wxDIALOG_NO_PARENT style, use the top level 
 321     // app window as parent - this avoids creating modal dialogs without 
 324     if (!pParent 
&& !(GetWindowStyleFlag() & wxDIALOG_NO_PARENT
)) 
 326         pParent 
= wxTheApp
->GetTopWindow(); 
 331             // Don't use transient windows as parents, this is dangerous as it 
 332             // can lead to a crash if the parent is destroyed before the child 
 334             // also don't use the window which is currently hidden as then the 
 335             // dialog would be hidden as well 
 336             if ((pParent
->GetExtraStyle() & wxWS_EX_TRANSIENT
) || 
 348         hWndOwner 
= GetHwndOf(pParent
); 
 350         hWndOwner 
= HWND_DESKTOP
; 
 352     hWndDlg 
= ::WinLoadDlg( HWND_DESKTOP
 
 356                            ,(ULONG
)ulDlgTemplate
 
 360     m_hWnd 
= (WXHWND
) hWndDlg
; 
 364         wxFAIL_MSG(wxT("Did you forget to include wx/os2/wx.rc in your resources?")); 
 366         wxLogSysError(wxT("Can't create dialog using template '%ld'"), ulDlgTemplate
); 
 372     // Move the dialog to its initial position without forcing repainting 
 379     if (!OS2GetCreateWindowCoords( rPos
 
 387         nX 
= nWidth 
= (int)CW_USEDEFAULT
; 
 391     // We can't use CW_USEDEFAULT here as we're not calling CreateWindow() 
 392     // and passing CW_USEDEFAULT to MoveWindow() results in resizing the 
 393     // window to (0, 0) size which breaks quite a lot of things, e.g. the 
 394     // sizer calculation in wxSizer::Fit() 
 396     if (nWidth 
== (int)CW_USEDEFAULT
) 
 399         // The exact number doesn't matter, the dialog will be resized 
 400         // again soon anyhow but it should be big enough to allow 
 401         // calculation relying on "totalSize - clientSize > 0" work, i.e. 
 402         // at least greater than the title bar height 
 404         nWidth 
= nHeight 
= 100; 
 406     if (nX 
== (int)CW_USEDEFAULT
) 
 409         // Centre it on the screen - what else can we do? 
 411         wxSize                      vSizeDpy 
= wxGetDisplaySize(); 
 413         nX 
= (vSizeDpy
.x 
- nWidth
) / 2; 
 414         nY 
= (vSizeDpy
.y 
- nHeight
) / 2; 
 416     m_backgroundColour
.Set(wxString("LIGHT GREY")); 
 418     LONG                            lColor 
= (LONG
)m_backgroundColour
.GetPixel(); 
 420     if (!::WinSetPresParam( m_hWnd
 
 429     ::WinSetWindowPos( GetHwnd() 
 435                       ,SWP_MOVE 
| SWP_SIZE 
| SWP_ZORDER 
| SWP_SHOW 
| SWP_ACTIVATE
 
 437     ::WinQueryWindowPos(GetHwnd(), GetSwp()); 
 441 } // end of wxTopLevelWindowOS2::CreateDialog 
 443 bool wxTopLevelWindowOS2::CreateFrame( 
 444   const wxString
&                   rsTitle
 
 445 , const wxPoint
&                    rPos
 
 446 , const wxSize
&                     rSize
 
 450     WXDWORD                         lFlags 
= OS2GetCreateWindowFlags(&lExflags
); 
 451     long                            lStyle 
= GetWindowStyleFlag(); 
 454     int                             nWidth 
= rSize
.x
; 
 455     int                             nHeight 
= rSize
.y
; 
 456     ULONG                           ulStyleFlags 
= 0L; 
 459     wxWindow
*                       pParent 
= GetParent(); 
 465         hParent 
= GetHwndOf(pParent
); 
 467         hParent 
= HWND_DESKTOP
; 
 469     if ((lStyle 
& wxMINIMIZE
) || (lStyle 
& wxICONIZE
)) 
 470         ulStyleFlags 
|= WS_MINIMIZED
; 
 471     if (lStyle 
& wxMAXIMIZE
) 
 472         ulStyleFlags 
|= WS_MAXIMIZED
; 
 475     // Clear the visible flag, we always call show 
 477     ulStyleFlags 
&= (unsigned long)~WS_VISIBLE
; 
 481     // Create the frame window:  We break ranks with other ports now 
 482     // and instead of calling down into the base wxWindow class' OS2Create 
 483     // we do all our own stuff here.  We will set the needed pieces 
 484     // of wxWindow manually, here. 
 487      hFrame 
= ::WinCreateStdWindow( hParent
 
 488                                    ,ulStyleFlags          
// frame-window style 
 489                                    ,(PULONG
)&lFlags       
// window style 
 490                                    ,(PSZ
)wxFrameClassName 
// class name 
 491                                    ,(PSZ
)rsTitle
.c_str()  // window title 
 492                                    ,0L                    // default client style 
 493                                    ,NULLHANDLE            
// resource in executable file 
 495                                    ,&hClient              
// receives client window handle 
 499         vError 
= ::WinGetLastError(vHabmain
); 
 500         sError 
= wxPMErrorToStr(vError
); 
 501         wxLogError("Error creating frame. Error: %s\n", sError
.c_str()); 
 506     // wxWindow class' m_hWnd set here and needed associations 
 510     wxAssociateWinWithHandle(m_hWnd
, this); 
 511     wxAssociateWinWithHandle(m_hFrame
, this); 
 513     m_backgroundColour
.Set(wxString("MEDIUM GREY")); 
 515     LONG                            lColor 
= (LONG
)m_backgroundColour
.GetPixel(); 
 517     if (!::WinSetPresParam( m_hWnd
 
 523         vError 
= ::WinGetLastError(vHabmain
); 
 524         sError 
= wxPMErrorToStr(vError
); 
 525         wxLogError("Error creating frame. Error: %s\n", sError
.c_str()); 
 530     // Now need to subclass window.  Instead of calling the SubClassWin in wxWindow 
 531     // we manually subclass here because we don't want to use the main wxWndProc 
 534     m_fnOldWndProc 
= (WXFARPROC
) ::WinSubclassWindow(m_hFrame
, (PFNWP
)wxFrameMainWndProc
); 
 537     // Now size everything.  If adding a menu the client will need to be resized. 
 542         nY 
= pParent
->GetSize().y 
- (nY 
+ nHeight
); 
 548         ::WinQueryWindowRect(HWND_DESKTOP
, &vRect
); 
 549         nY 
= vRect
.yTop 
- (nY 
+ nHeight
); 
 551     if (!::WinSetWindowPos( m_hFrame
 
 557                            ,SWP_SIZE 
| SWP_MOVE 
| SWP_ACTIVATE 
| SWP_ZORDER
 
 560         vError 
= ::WinGetLastError(vHabmain
); 
 561         sError 
= wxPMErrorToStr(vError
); 
 562         wxLogError("Error sizing frame. Error: %s\n", sError
.c_str()); 
 565     lStyle 
=  ::WinQueryWindowULong( m_hWnd
 
 568     lStyle 
|= WS_CLIPCHILDREN
; 
 569     ::WinSetWindowULong( m_hWnd
 
 574 } // end of wxTopLevelWindowOS2::CreateFrame 
 576 bool wxTopLevelWindowOS2::Create( 
 579 , const wxString
&                   rsTitle
 
 580 , const wxPoint
&                    rPos
 
 581 , const wxSize
&                     rSizeOrig
 
 583 , const wxString
&                   rsName
 
 590     m_windowStyle 
= lStyle
; 
 592     m_windowId 
= vId 
== -1 ? NewControlId() : vId
; 
 594     // always create a frame of some reasonable, even if arbitrary, size (at 
 595     // least for MSW compatibility) 
 596     wxSize rSize 
= rSizeOrig
; 
 597     if ( rSize
.x 
== -1 || rSize
.y 
== -1 ) 
 599         wxSize sizeDpy 
= wxGetDisplaySize(); 
 601             rSize
.x 
= sizeDpy
.x 
/ 3; 
 603             rSize
.y 
= sizeDpy
.y 
/ 5; 
 606     wxTopLevelWindows
.Append(this); 
 608         pParent
->AddChild(this); 
 610     if (GetExtraStyle() & wxTOPLEVEL_EX_DIALOG
) 
 613         // We have different dialog templates to allows creation of dialogs 
 614         // with & without captions under OS2indows, resizeable or not (but a 
 615         // resizeable dialog always has caption - otherwise it would look too 
 620         if (lStyle 
& wxRESIZE_BORDER
) 
 621             ulDlgTemplate 
= (ULONG
)kResizeableDialog
; 
 622         else if (lStyle 
& wxCAPTION
) 
 623             ulDlgTemplate 
= (ULONG
)kCaptionDialog
; 
 625             ulDlgTemplate 
= (ULONG
)kNoCaptionDialog
; 
 626         return CreateDialog( ulDlgTemplate
 
 634         return CreateFrame( rsTitle
 
 639 } // end of wxTopLevelWindowOS2::Create 
 641 wxTopLevelWindowOS2::~wxTopLevelWindowOS2() 
 644     // After destroying an owned window, Windows activates the next top level 
 645     // window in Z order but it may be different from our owner (to reproduce 
 646     // this simply Alt-TAB to another application and back before closing the 
 647     // owned frame) whereas we always want to yield activation to our parent 
 649     if (HasFlag(wxFRAME_FLOAT_ON_PARENT
)) 
 651         wxWindow
*                   pParent 
= GetParent(); 
 655             ::WinSetWindowPos( GetHwndOf(pParent
) 
 662 } // end of wxTopLevelWindowOS2::~wxTopLevelWindowOS2 
 664 // ---------------------------------------------------------------------------- 
 665 // wxTopLevelWindowOS2 client size 
 666 // ---------------------------------------------------------------------------- 
 668 void wxTopLevelWindowOS2::DoSetClientSize( 
 674     // Call GetClientAreaOrigin() to take the toolbar into account 
 676     wxPoint                         vPt 
= GetClientAreaOrigin(); 
 681     wxWindow::DoSetClientSize( nWidth
 
 684 } // end of wxTopLevelWindowOS2::DoSetClientSize 
 686 void wxTopLevelWindowOS2::DoGetClientSize( 
 691     wxWindow::DoGetClientSize( pnX
 
 695     wxPoint                         vPt 
= GetClientAreaOrigin(); 
 702 } // end of wxTopLevelWindowOS2::DoGetClientSize 
 704 // ---------------------------------------------------------------------------- 
 705 // wxTopLevelWindowOS2 showing 
 706 // ---------------------------------------------------------------------------- 
 708 void wxTopLevelWindowOS2::DoShowWindow( 
 712     ::WinShowWindow(m_hFrame
, (BOOL
)(nShowCmd 
& SWP_SHOW
)); 
 715     // Need to artificially send a size event as wxApps often expect to do some 
 716     // final child control sizing 
 718     m_bIconized 
= nShowCmd 
== SWP_MINIMIZE
; 
 719 } // end of wxTopLevelWindowOS2::DoShowWindow 
 721 bool wxTopLevelWindowOS2::Show( 
 728     if (bShow 
!= IsShown() ) 
 738         if (m_bMaximizeOnShow
) 
 740             nShowCmd 
= SWP_MAXIMIZE
; 
 741             m_bMaximizeOnShow 
= FALSE
; 
 752     DoShowWindow(nShowCmd
); 
 756         wxActivateEvent             
vEvent(wxEVT_ACTIVATE
, TRUE
, m_windowId
); 
 758         ::WinQueryWindowPos(m_hFrame
, &vSwp
); 
 759         m_bIconized 
= vSwp
.fl 
& SWP_MINIMIZE
; 
 760         ::WinQueryWindowPos(m_hWnd
, &m_vSwpClient
); 
 761         ::WinSendMsg(m_hFrame
, WM_UPDATEFRAME
, (MPARAM
)~0, 0); 
 762         ::WinQueryWindowPos(m_hWnd
, &vSwp
); 
 763         ::WinEnableWindow(m_hFrame
, TRUE
); 
 766         // Deal with children 
 768         MoveChildren(m_vSwpClient
.cy 
- vSwp
.cy
); 
 769         vEvent
.SetEventObject(this); 
 770         GetEventHandler()->ProcessEvent(vEvent
); 
 775         // Try to highlight the correct window (the parent) 
 779             HWND                    hWndParent 
= GetHwndOf(GetParent()); 
 781             ::WinQueryWindowPos(hWndParent
, &vSwp
); 
 782             m_bIconized 
= vSwp
.fl 
& SWP_MINIMIZE
; 
 783             ::WinEnableWindow(hWndParent
, TRUE
); 
 787 } // end of wxTopLevelWindowOS2::Show 
 789 // ---------------------------------------------------------------------------- 
 790 // wxTopLevelWindowOS2 maximize/minimize 
 791 // ---------------------------------------------------------------------------- 
 793 void wxTopLevelWindowOS2::Maximize( 
 800         // Just maximize it directly 
 802         DoShowWindow(bMaximize 
? SWP_MAXIMIZE 
: SWP_RESTORE
); 
 807         // We can't maximize the hidden frame because it shows it as well, so 
 808         // just remember that we should do it later in this case 
 810         m_bMaximizeOnShow 
= bMaximize
; 
 812 } // end of wxTopLevelWindowOS2::Maximize 
 814 bool wxTopLevelWindowOS2::IsMaximized() const 
 817     ::WinQueryWindowPos(m_hFrame
, (PSWP
)&m_vSwp
); 
 818     return (m_vSwp
.fl 
& SWP_MAXIMIZE
); 
 819 } // end of wxTopLevelWindowOS2::IsMaximized 
 821 void wxTopLevelWindowOS2::Iconize( 
 825     DoShowWindow(bIconize 
? SWP_MINIMIZE 
: SWP_RESTORE
); 
 826 } // end of wxTopLevelWindowOS2::Iconize 
 828 bool wxTopLevelWindowOS2::IsIconized() const 
 830     // also update the current state 
 831     ::WinQueryWindowPos(m_hFrame
, (PSWP
)&m_vSwp
); 
 832     if (m_vSwp
.fl 
& SWP_MINIMIZE
) 
 833         ((wxTopLevelWindow
*)this)->m_bIconized 
= TRUE
; 
 835         ((wxTopLevelWindow
*)this)->m_bIconized 
= FALSE
; 
 837 } // end of wxTopLevelWindowOS2::IsIconized 
 839 void wxTopLevelWindowOS2::Restore() 
 841     DoShowWindow(SWP_RESTORE
); 
 842 } // end of wxTopLevelWindowOS2::Restore 
 844 // generate an artificial resize event 
 845 void wxTopLevelWindowOS2::SendSizeEvent() 
 849         RECTL                       vRect 
= wxGetWindowRect(GetHwnd()); 
 851         (void)::WinPostMsg( m_hFrame
 
 853                            ,MPFROM2SHORT(vRect
.xRight 
- vRect
.xLeft
, vRect
.yTop 
- vRect
.yBottom
) 
 854                            ,MPFROM2SHORT(vRect
.xRight 
- vRect
.xLeft
, vRect
.yTop 
- vRect
.yBottom
) 
 857 } // end of wxTopLevelWindowOS2::SendSizeEvent 
 859 // ---------------------------------------------------------------------------- 
 860 // wxTopLevelWindowOS2 fullscreen 
 861 // ---------------------------------------------------------------------------- 
 863 bool wxTopLevelWindowOS2::ShowFullScreen( 
 873         m_bFsIsShowing 
= TRUE
; 
 877         // Zap the frame borders 
 881         // Save the 'normal' window lStyle 
 883         m_lFsOldWindowStyle 
= ::WinQueryWindowULong( (HWND
)GetHWND() 
 888         // Save the old position, width & height, maximize state 
 890         m_vFsOldSize 
= GetRect(); 
 891         m_bFsIsMaximized 
= IsMaximized(); 
 894         // Decide which window lStyle flags to turn off 
 896         LONG                        lNewStyle 
= m_lFsOldWindowStyle
; 
 899         if (lStyle 
& wxFULLSCREEN_NOBORDER
) 
 900             lOffFlags 
|= FCF_BORDER
; 
 901         if (lStyle 
& wxFULLSCREEN_NOCAPTION
) 
 902             lOffFlags 
|= (FCF_TASKLIST 
| FCF_SYSMENU
); 
 904         lNewStyle 
&= (~lOffFlags
); 
 907         // Change our window style to be compatible with full-screen mode 
 909         ::WinSetWindowULong( (HWND
)GetHWND() 
 915         // Resize to the size of the desktop 
 919         RECTL                       vRect 
= wxGetWindowRect(HWND_DESKTOP
); 
 921         nWidth 
= vRect
.xRight 
- vRect
.xLeft
; 
 922         nHeight 
= vRect
.yTop 
- vRect
.yBottom
; 
 929         // Now flush the window style cache and actually go full-screen 
 931         ::WinSetWindowPos( m_hFrame
 
 940         wxSizeEvent                 
vEvent( wxSize( nWidth
 
 946         GetEventHandler()->ProcessEvent(vEvent
); 
 954         m_bFsIsShowing 
= FALSE
; 
 955         Maximize(m_bFsIsMaximized
); 
 956         ::WinSetWindowULong( (HWND
)GetHWND() 
 960         ::WinSetWindowPos( m_hFrame
 
 970 } // end of wxTopLevelWindowOS2::ShowFullScreen 
 972 // ---------------------------------------------------------------------------- 
 973 // wxTopLevelWindowOS2 misc 
 974 // ---------------------------------------------------------------------------- 
 976 void wxTopLevelWindowOS2::SetIcon( 
 980     SetIcons(wxIconBundle(rIcon
)); 
 981 } // end of wxTopLevelWindowOS2::SetIcon 
 983 void wxTopLevelWindowOS2::SetIcons( 
 984   const wxIconBundle
&               rIcons
 
 990     wxTopLevelWindowBase::SetIcons(rIcons
); 
 992     const wxIcon
&                   vIcon 
= rIcons
.GetIcon(wxSize(32, 32)); 
 994     if (vIcon
.Ok() && vIcon
.GetWidth() == 32 && vIcon
.GetHeight() == 32) 
 996         ::WinSendMsg( m_hFrame
 
 998                      ,(MPARAM
)((HPOINTER
)vIcon
.GetHICON()) 
1001         ::WinSendMsg( m_hFrame
 
1007 } // end of wxTopLevelWindowOS2::SetIcon 
1009 bool wxTopLevelWindowOS2::EnableCloseButton( 
1014     // Get system (a.k.a. window) menu 
1016     HMENU                           hMenu 
= ::WinWindowFromID(m_hFrame
, FID_SYSMENU
); 
1020         wxLogLastError(_T("GetSystemMenu")); 
1025     // Enabling/disabling the close item from it also automatically 
1026     // disables/enables the close title bar button 
1029         (void)::WinSendMsg( hMenu
 
1031                            ,MPFROM2SHORT(SC_CLOSE
, FALSE
) 
1032                            ,MPFROM2SHORT(MIA_DISABLED
, FALSE
) 
1035         (void)::WinSendMsg( hMenu
 
1037                            ,MPFROM2SHORT(SC_CLOSE
, FALSE
) 
1038                            ,MPFROM2SHORT(MIA_DISABLED
, MIA_DISABLED
) 
1042     // Update appearance immediately 
1044     ::WinSendMsg( m_hFrame
 
1050 } // end of wxTopLevelWindowOS2::EnableCloseButton 
1052 // ============================================================================ 
1053 // wxTLWHiddenParentModule implementation 
1054 // ============================================================================ 
1056 HWND          
wxTLWHiddenParentModule::m_shWnd 
= NULL
; 
1057 const wxChar
* wxTLWHiddenParentModule::m_szClassName 
= NULL
; 
1059 bool wxTLWHiddenParentModule::OnInit() 
1062     m_szClassName 
= NULL
; 
1064 } // end of wxTLWHiddenParentModule::OnInit 
1066 void wxTLWHiddenParentModule::OnExit() 
1070         if (!::WinDestroyWindow(m_shWnd
)) 
1072             wxLogLastError(_T("DestroyWindow(hidden TLW parent)")); 
1077     m_szClassName 
= NULL
; 
1078 } // end of wxTLWHiddenParentModule::OnExit 
1081 HWND 
wxTLWHiddenParentModule::GetHWND() 
1087             static const wxChar
*    zHIDDEN_PARENT_CLASS 
= _T("wxTLWHiddenParent"); 
1089             if (!::WinRegisterClass( wxGetInstance() 
1090                                     ,zHIDDEN_PARENT_CLASS
 
1096                 wxLogLastError(_T("RegisterClass(\"wxTLWHiddenParent\")")); 
1100                 m_szClassName 
= zHIDDEN_PARENT_CLASS
; 
1103         m_shWnd 
= ::WinCreateWindow( HWND_DESKTOP
 
1119             wxLogLastError(_T("CreateWindow(hidden TLW parent)")); 
1123 } // end of wxTLWHiddenParentModule::GetHWND