1 /////////////////////////////////////////////////////////////////////////////// 
   2 // Name:        src/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 // Licence:     wxWindows licence 
  10 /////////////////////////////////////////////////////////////////////////////// 
  12 // ============================================================================ 
  14 // ============================================================================ 
  16 // ---------------------------------------------------------------------------- 
  18 // ---------------------------------------------------------------------------- 
  20 // For compilers that support precompilation, includes "wx.h". 
  21 #include "wx/wxprec.h" 
  27 #include "wx/toplevel.h" 
  31     #include "wx/dialog.h" 
  32     #include "wx/string.h" 
  36     #include "wx/control.h" 
  37     #include "wx/containr.h"        // wxSetFocusToChild() 
  38     #include "wx/settings.h" 
  39     #include "wx/module.h"        // wxSetFocusToChild() 
  42 #include "wx/os2/private.h" 
  44 // ---------------------------------------------------------------------------- 
  45 // stubs for missing functions under MicroWindows 
  46 // ---------------------------------------------------------------------------- 
  49 // ---------------------------------------------------------------------------- 
  51 // ---------------------------------------------------------------------------- 
  53 // the name of the default wxWidgets class 
  54 extern void wxAssociateWinWithHandle( HWND hWnd
, wxWindowOS2
* pWin 
); 
  56 bool wxTopLevelWindowOS2::m_sbInitialized 
= false; 
  57 wxWindow
* wxTopLevelWindowOS2::m_spHiddenParent 
= NULL
; 
  59 // ============================================================================ 
  60 // wxTopLevelWindowOS2 implementation 
  61 // ============================================================================ 
  63 BEGIN_EVENT_TABLE(wxTopLevelWindowOS2
, wxTopLevelWindowBase
) 
  64     EVT_ACTIVATE(wxTopLevelWindowOS2::OnActivate
) 
  67 // ============================================================================ 
  68 // wxTopLevelWindowMSW implementation 
  69 // ============================================================================ 
  72 MRESULT EXPENTRY 
wxDlgProc( HWND 
WXUNUSED(hWnd
) 
  74                            ,void * WXUNUSED(wParam
) 
  75                            ,void * WXUNUSED(lParam
) 
  82             // For this message, returning TRUE tells system to set focus to 
  83             // the first control in the dialog box, but we set the focus 
  84             // ourselves, however in OS/2 we must return true to enable the dialog 
  89             // For all the other ones, FALSE means that we didn't process the 
  92             return (MRESULT
)FALSE
; 
  96 // ---------------------------------------------------------------------------- 
  97 // wxTLWHiddenParentModule: used to manage the hidden parent window (we need a 
  98 // module to ensure that the window is always deleted) 
  99 // ---------------------------------------------------------------------------- 
 101 class wxTLWHiddenParentModule 
: public wxModule
 
 105     // Module init/finalize 
 107     virtual bool OnInit(void); 
 108     virtual void OnExit(void); 
 111     // Get the hidden window (creates on demand) 
 113     static HWND 
GetHWND(void); 
 117     // The HWND of the hidden parent 
 122     // The class used to create it 
 124     static const wxChar
* m_szClassName
; 
 125     DECLARE_DYNAMIC_CLASS(wxTLWHiddenParentModule
) 
 126 }; // end of CLASS wxTLWHiddenParentModule 
 128 IMPLEMENT_DYNAMIC_CLASS(wxTLWHiddenParentModule
, wxModule
) 
 130 // ---------------------------------------------------------------------------- 
 131 // wxTopLevelWindowOS2 creation 
 132 // ---------------------------------------------------------------------------- 
 134 void wxTopLevelWindowOS2::Init() 
 136     m_bIconized 
= m_bMaximizeOnShow 
= false; 
 139     // Unlike (almost?) all other windows, frames are created hidden 
 144     // Data to save/restore when calling ShowFullScreen 
 146     m_lFsOldWindowStyle 
= 0; 
 147     m_bFsIsMaximized    
= false; 
 148     m_bFsIsShowing      
= false; 
 150     m_hFrame    
= NULLHANDLE
; 
 151     memset(&m_vSwp
, 0, sizeof(SWP
)); 
 152     memset(&m_vSwpClient
, 0, sizeof(SWP
)); 
 153     m_pWinLastFocused 
= NULL
; 
 154 } // end of wxTopLevelWindowIOS2::Init 
 156 void wxTopLevelWindowOS2::OnActivate( 
 157   wxActivateEvent
&                  rEvent
 
 160     if (rEvent
.GetActive()) 
 163         // Restore focus to the child which was last focused 
 165         wxLogTrace(wxT("focus"), wxT("wxTLW %08lx activated."), m_hWnd
); 
 167         wxWindow
*                   pParent 
= m_pWinLastFocused 
? m_pWinLastFocused
->GetParent() 
 174         wxSetFocusToChild( pParent
 
 181         // Remember the last focused child if it is our child 
 183         m_pWinLastFocused 
= FindFocus(); 
 186         // So we NULL it out if it's a child from some other frame 
 188         wxWindow
*                   pWin 
= m_pWinLastFocused
; 
 192             if (pWin
->IsTopLevel()) 
 196                     m_pWinLastFocused 
= NULL
; 
 200             pWin 
= pWin
->GetParent(); 
 203         wxLogTrace(wxT("focus"), 
 204                    wxT("wxTLW %08lx deactivated, last focused: %08lx."), 
 206                    m_pWinLastFocused 
? GetHwndOf(m_pWinLastFocused
) 
 210 } // end of wxTopLevelWindowOS2::OnActivate 
 212 WXDWORD 
wxTopLevelWindowOS2::OS2GetStyle( 
 214 , WXDWORD
*                          pdwExflags
 
 217     long                            lMsflags 
= wxWindow::OS2GetStyle( (lStyle 
& ~wxBORDER_MASK
) | wxBORDER_NONE
 
 221     if ((lStyle 
& wxDEFAULT_FRAME_STYLE
) == wxDEFAULT_FRAME_STYLE
) 
 222         lMsflags 
|= FCF_SIZEBORDER 
| FCF_TITLEBAR 
| FCF_SYSMENU 
| 
 223                     FCF_MINMAX 
| FCF_TASKLIST
; 
 225     if ((lStyle 
& wxCAPTION
) == wxCAPTION
) 
 226         lMsflags 
|= FCF_TASKLIST
; 
 228         lMsflags 
|= FCF_NOMOVEWITHOWNER
; 
 230     if ((lStyle 
& wxVSCROLL
) == wxVSCROLL
) 
 231         lMsflags 
|= FCF_VERTSCROLL
; 
 232     if ((lStyle 
& wxHSCROLL
) == wxHSCROLL
) 
 233         lMsflags 
|= FCF_HORZSCROLL
; 
 234     if (lStyle 
& wxMINIMIZE_BOX
) 
 235         lMsflags 
|= FCF_MINBUTTON
; 
 236     if (lStyle 
& wxMAXIMIZE_BOX
) 
 237         lMsflags 
|= FCF_MAXBUTTON
; 
 238     if (lStyle 
& wxRESIZE_BORDER
) 
 239         lMsflags 
|= FCF_DLGBORDER
; 
 240     if (lStyle 
& wxSYSTEM_MENU
) 
 241         lMsflags 
|= FCF_SYSMENU
; 
 242     if (lStyle 
& wxCAPTION
) 
 243         lMsflags 
|= FCF_TASKLIST
; 
 244     if (lStyle 
& wxCLIP_CHILDREN
) 
 246         // Invalid for frame windows under PM 
 249     if (lStyle 
& wxTINY_CAPTION
) 
 250         lMsflags 
|= FCF_TASKLIST
; 
 252     if ((lStyle 
& wxRESIZE_BORDER
) == 0) 
 253         lMsflags 
|= FCF_BORDER
; 
 254     if (lStyle 
& wxFRAME_TOOL_WINDOW
) 
 255         *pdwExflags 
= kFrameToolWindow
; 
 257     if (lStyle 
& wxSTAY_ON_TOP
) 
 258         lMsflags 
|= FCF_SYSMODAL
; 
 261 } // end of wxTopLevelWindowOS2::OS2GetCreateWindowFlags 
 263 WXHWND 
wxTopLevelWindowOS2::OS2GetParent() const 
 265     HWND                            hWndParent 
= NULL
; 
 268     // For the frames without wxFRAME_FLOAT_ON_PARENT style we should use NULL 
 269     // parent HWND or it would be always on top of its parent which is not what 
 270     // we usually want (in fact, we only want it for frames with the 
 271     // wxFRAME_FLOAT_ON_PARENT flag) 
 273     if (HasFlag(wxFRAME_FLOAT_ON_PARENT
) ) 
 275         const wxWindow
*             pParent 
= GetParent(); 
 280             // This flag doesn't make sense then and will be ignored 
 282             wxFAIL_MSG( wxT("wxFRAME_FLOAT_ON_PARENT but no parent?") ); 
 286             hWndParent 
= GetHwndOf(pParent
); 
 289     //else: don't float on parent, must not be owned 
 292     // Now deal with the 2nd taskbar-related problem (see comments above in 
 295     if (HasFlag(wxFRAME_NO_TASKBAR
) && !hWndParent
) 
 300         hWndParent 
= wxTLWHiddenParentModule::GetHWND(); 
 302     return (WXHWND
)hWndParent
; 
 303 } // end of wxTopLevelWindowOS2::OS2GetParent 
 306 bool wxTopLevelWindowOS2::CreateDialog( ULONG           ulDlgTemplate
, 
 307                                         const wxString
& WXUNUSED(rsTitle
), 
 309                                         const wxSize
&   rSize 
) 
 311     wxWindow
*                       pParent 
= GetParent(); 
 314     // For the dialogs without wxDIALOG_NO_PARENT style, use the top level 
 315     // app window as parent - this avoids creating modal dialogs without 
 318     if (!pParent 
&& !(GetWindowStyleFlag() & wxDIALOG_NO_PARENT
)) 
 320         pParent 
= wxTheApp
->GetTopWindow(); 
 325             // Don't use transient windows as parents, this is dangerous as it 
 326             // can lead to a crash if the parent is destroyed before the child 
 328             // also don't use the window which is currently hidden as then the 
 329             // dialog would be hidden as well 
 330             if ((pParent
->GetExtraStyle() & wxWS_EX_TRANSIENT
) || 
 342         hWndOwner 
= GetHwndOf(pParent
); 
 344         hWndOwner 
= HWND_DESKTOP
; 
 346     hWndDlg 
= ::WinLoadDlg( HWND_DESKTOP
 
 350                            ,(ULONG
)ulDlgTemplate
 
 354     m_hWnd 
= (WXHWND
) hWndDlg
; 
 358         wxFAIL_MSG(wxT("Did you forget to include wx/os2/wx.rc in your resources?")); 
 360         wxLogSysError(wxT("Can't create dialog using template '%ld'"), ulDlgTemplate
); 
 366     // Move the dialog to its initial position without forcing repainting 
 373     if (!OS2GetCreateWindowCoords( rPos
 
 381         nX 
= nWidth 
= (int)CW_USEDEFAULT
; 
 385     // We can't use CW_USEDEFAULT here as we're not calling CreateWindow() 
 386     // and passing CW_USEDEFAULT to MoveWindow() results in resizing the 
 387     // window to (0, 0) size which breaks quite a lot of things, e.g. the 
 388     // sizer calculation in wxSizer::Fit() 
 390     if (nWidth 
== (int)CW_USEDEFAULT
) 
 393         // The exact number doesn't matter, the dialog will be resized 
 394         // again soon anyhow but it should be big enough to allow 
 395         // calculation relying on "totalSize - clientSize > 0" work, i.e. 
 396         // at least greater than the title bar height 
 398         nWidth 
= nHeight 
= 100; 
 400     if (nX 
== (int)CW_USEDEFAULT
) 
 403         // Centre it on the screen - what else can we do? 
 405         wxSize                      vSizeDpy 
= wxGetDisplaySize(); 
 407         nX 
= (vSizeDpy
.x 
- nWidth
) / 2; 
 408         nY 
= (vSizeDpy
.y 
- nHeight
) / 2; 
 410     SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_APPWORKSPACE
)); 
 412     LONG                            lColor 
= (LONG
)m_backgroundColour
.GetPixel(); 
 414     if (!::WinSetPresParam( m_hWnd
 
 423     // Convert to OS/2 coordinates 
 424     nY 
= GetOS2ParentHeight(pParent
) - nY 
- nHeight
; 
 426     ::WinSetWindowPos( GetHwnd() 
 432                       ,SWP_MOVE 
| SWP_SIZE 
| SWP_ZORDER 
| SWP_SHOW 
| SWP_ACTIVATE
 
 434     ::WinQueryWindowPos(GetHwnd(), GetSwp()); 
 438 } // end of wxTopLevelWindowOS2::CreateDialog 
 440 bool wxTopLevelWindowOS2::CreateFrame( const wxString
& rsTitle
, 
 442                                        const wxSize
& rSize 
) 
 445     WXDWORD    lFlags 
= OS2GetCreateWindowFlags(&lExflags
); 
 446     long       lStyle 
= GetWindowStyleFlag(); 
 449     int        nWidth 
= rSize
.x
; 
 450     int        nHeight 
= rSize
.y
; 
 451     ULONG      ulStyleFlags 
= 0L; 
 454     wxWindow
*  pParent 
= GetParent(); 
 460         hParent 
= GetHwndOf(pParent
); 
 462         hParent 
= HWND_DESKTOP
; 
 464     if ((lStyle 
& wxMINIMIZE
) || (lStyle 
& wxICONIZE
)) 
 465         ulStyleFlags 
|= WS_MINIMIZED
; 
 466     if (lStyle 
& wxMAXIMIZE
) 
 467         ulStyleFlags 
|= WS_MAXIMIZED
; 
 470     // Clear the visible flag, we always call show 
 472     ulStyleFlags 
&= (unsigned long)~WS_VISIBLE
; 
 476     // Create the frame window:  We break ranks with other ports now 
 477     // and instead of calling down into the base wxWindow class' OS2Create 
 478     // we do all our own stuff here.  We will set the needed pieces 
 479     // of wxWindow manually, here. 
 482      hFrame 
= ::WinCreateStdWindow( hParent
 
 483                                    ,ulStyleFlags          
// frame-window style 
 484                                    ,(PULONG
)&lFlags       
// window style 
 485                                    ,wxString(wxFrameClassName
).c_str() // class name 
 486                                    ,rsTitle
.c_str()       // window title 
 487                                    ,0L                    // default client style 
 488                                    ,NULLHANDLE            
// resource in executable file 
 490                                    ,&hClient              
// receives client window handle 
 494         vError 
= ::WinGetLastError(vHabmain
); 
 495         sError 
= wxPMErrorToStr(vError
); 
 496         wxLogError(wxT("Error creating frame. Error: %s\n"), sError
.c_str()); 
 501     // wxWindow class' m_hWnd set here and needed associations 
 505     wxAssociateWinWithHandle(m_hWnd
, this); 
 506     wxAssociateWinWithHandle(m_hFrame
, this); 
 508     SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_APPWORKSPACE
)); 
 510     LONG                            lColor 
= (LONG
)m_backgroundColour
.GetPixel(); 
 512     if (!::WinSetPresParam( m_hWnd
 
 518         vError 
= ::WinGetLastError(vHabmain
); 
 519         sError 
= wxPMErrorToStr(vError
); 
 520         wxLogError(wxT("Error creating frame. Error: %s\n"), sError
.c_str()); 
 525     // Now need to subclass window.  Instead of calling the SubClassWin in wxWindow 
 526     // we manually subclass here because we don't want to use the main wxWndProc 
 529     m_fnOldWndProc 
= (WXFARPROC
) ::WinSubclassWindow(m_hFrame
, (PFNWP
)wxFrameMainWndProc
); 
 532     // Now size everything.  If adding a menu the client will need to be resized. 
 535     if (!OS2GetCreateWindowCoords( rPos
 
 543         nX 
= nWidth 
= (int)CW_USEDEFAULT
; 
 547     // We can't use CW_USEDEFAULT here as we're not calling CreateWindow() 
 548     // and passing CW_USEDEFAULT to MoveWindow() results in resizing the 
 549     // window to (0, 0) size which breaks quite a lot of things, e.g. the 
 550     // sizer calculation in wxSizer::Fit() 
 552     if (nWidth 
== (int)CW_USEDEFAULT
) 
 555         // The exact number doesn't matter, the dialog will be resized 
 556         // again soon anyhow but it should be big enough to allow 
 557         // calculation relying on "totalSize - clientSize > 0" work, i.e. 
 558         // at least greater than the title bar height 
 560         nWidth 
= nHeight 
= 100; 
 562     if (nX 
== (int)CW_USEDEFAULT
) 
 565         // Centre it on the screen for now - what else can we do? 
 566         // TODO: We could try FCF_SHELLPOSITION but it will require moving 
 567         //       things around a bit. 
 569         wxSize                      vSizeDpy 
= wxGetDisplaySize(); 
 571         nX 
= (vSizeDpy
.x 
- nWidth
) / 2; 
 572         nY 
= (vSizeDpy
.y 
- nHeight
) / 2; 
 575     // Convert to OS/2 coordinates 
 576     nY 
= GetOS2ParentHeight(pParent
) - nY 
- nHeight
; 
 578     if (!::WinSetWindowPos( m_hFrame
 
 584                            ,SWP_SIZE 
| SWP_MOVE 
| SWP_ACTIVATE 
| SWP_ZORDER
 
 587         vError 
= ::WinGetLastError(vHabmain
); 
 588         sError 
= wxPMErrorToStr(vError
); 
 589         wxLogError(wxT("Error sizing frame. Error: %s\n"), sError
.c_str()); 
 592     lStyle 
=  ::WinQueryWindowULong( m_hWnd
 
 595     lStyle 
|= WS_CLIPCHILDREN
; 
 596     ::WinSetWindowULong( m_hWnd
 
 601 } // end of wxTopLevelWindowOS2::CreateFrame 
 603 bool wxTopLevelWindowOS2::Create( 
 606 , const wxString
&                   rsTitle
 
 607 , const wxPoint
&                    rPos
 
 608 , const wxSize
&                     rSizeOrig
 
 610 , const wxString
&                   rsName
 
 617     m_windowStyle 
= lStyle
; 
 619     m_windowId 
= vId 
== -1 ? NewControlId() : vId
; 
 621     // always create a frame of some reasonable, even if arbitrary, size (at 
 622     // least for MSW compatibility) 
 623     wxSize rSize 
= rSizeOrig
; 
 624     if ( rSize
.x 
== -1 || rSize
.y 
== -1 ) 
 626         wxSize sizeDpy 
= wxGetDisplaySize(); 
 628             rSize
.x 
= sizeDpy
.x 
/ 3; 
 630             rSize
.y 
= sizeDpy
.y 
/ 5; 
 633     wxTopLevelWindows
.Append(this); 
 635         pParent
->AddChild(this); 
 637     if (GetExtraStyle() & wxTOPLEVEL_EX_DIALOG
) 
 640         // We have different dialog templates to allow creation of dialogs 
 641         // with & without captions under OS2indows, resizable or not (but a 
 642         // resizable dialog always has caption - otherwise it would look too 
 647         if (lStyle 
& wxRESIZE_BORDER
) 
 648             ulDlgTemplate 
= (ULONG
)kResizeableDialog
; 
 649         else if (lStyle 
& wxCAPTION
) 
 650             ulDlgTemplate 
= (ULONG
)kCaptionDialog
; 
 652             ulDlgTemplate 
= (ULONG
)kNoCaptionDialog
; 
 653         return CreateDialog( ulDlgTemplate
 
 661         return CreateFrame( rsTitle
 
 666 } // end of wxTopLevelWindowOS2::Create 
 668 wxTopLevelWindowOS2::~wxTopLevelWindowOS2() 
 671     // After destroying an owned window, Windows activates the next top level 
 672     // window in Z order but it may be different from our owner (to reproduce 
 673     // this simply Alt-TAB to another application and back before closing the 
 674     // owned frame) whereas we always want to yield activation to our parent 
 676     if (HasFlag(wxFRAME_FLOAT_ON_PARENT
)) 
 678         wxWindow
*                   pParent 
= GetParent(); 
 682             ::WinSetWindowPos( GetHwndOf(pParent
) 
 689 } // end of wxTopLevelWindowOS2::~wxTopLevelWindowOS2 
 691 // ---------------------------------------------------------------------------- 
 692 // wxTopLevelWindowOS2 client size 
 693 // ---------------------------------------------------------------------------- 
 695 void wxTopLevelWindowOS2::DoSetClientSize( 
 701     // Call GetClientAreaOrigin() to take the toolbar into account 
 703     wxPoint                         vPt 
= GetClientAreaOrigin(); 
 708     wxWindow::DoSetClientSize( nWidth
 
 711 } // end of wxTopLevelWindowOS2::DoSetClientSize 
 713 void wxTopLevelWindowOS2::DoGetClientSize( 
 718     wxWindow::DoGetClientSize( pnX
 
 722     wxPoint                         vPt 
= GetClientAreaOrigin(); 
 729 } // end of wxTopLevelWindowOS2::DoGetClientSize 
 731 // ---------------------------------------------------------------------------- 
 732 // wxTopLevelWindowOS2 showing 
 733 // ---------------------------------------------------------------------------- 
 735 void wxTopLevelWindowOS2::DoShowWindow( 
 739     ::WinShowWindow(m_hFrame
, (BOOL
)(nShowCmd 
& SWP_SHOW
)); 
 742     // Need to artificially send a size event as wxApps often expect to do some 
 743     // final child control sizing 
 745     m_bIconized 
= nShowCmd 
== SWP_MINIMIZE
; 
 746 } // end of wxTopLevelWindowOS2::DoShowWindow 
 748 bool wxTopLevelWindowOS2::Show( bool bShow 
) 
 753     if (bShow 
!= IsShown() ) 
 763         if (m_bMaximizeOnShow
) 
 765             nShowCmd 
= SWP_MAXIMIZE
; 
 766             m_bMaximizeOnShow 
= false; 
 777     DoShowWindow(nShowCmd
); 
 781         wxActivateEvent 
vEvent(wxEVT_ACTIVATE
, true, m_windowId
); 
 783         ::WinQueryWindowPos(m_hFrame
, &vSwp
); 
 784         m_bIconized 
= ( vSwp
.fl 
& SWP_MINIMIZE 
) == SWP_MINIMIZE 
; 
 785         ::WinQueryWindowPos(m_hWnd
, &m_vSwpClient
); 
 786         ::WinSendMsg(m_hFrame
, WM_UPDATEFRAME
, (MPARAM
)~0, 0); 
 787         ::WinQueryWindowPos(m_hWnd
, &vSwp
); 
 788         ::WinEnableWindow(m_hFrame
, TRUE
); 
 790         vEvent
.SetEventObject(this); 
 791         HandleWindowEvent(vEvent
); 
 796         // Try to highlight the correct window (the parent) 
 800             HWND hWndParent 
= GetHwndOf(GetParent()); 
 802             ::WinQueryWindowPos(hWndParent
, &vSwp
); 
 803             m_bIconized 
= (vSwp
.fl 
& SWP_MINIMIZE
)==SWP_MINIMIZE
; 
 804             ::WinEnableWindow(hWndParent
, TRUE
); 
 808 } // end of wxTopLevelWindowOS2::Show 
 810 // ---------------------------------------------------------------------------- 
 811 // wxTopLevelWindowOS2 maximize/minimize 
 812 // ---------------------------------------------------------------------------- 
 814 void wxTopLevelWindowOS2::Maximize( 
 821         // Just maximize it directly 
 823         DoShowWindow(bMaximize 
? SWP_MAXIMIZE 
: SWP_RESTORE
); 
 828         // We can't maximize the hidden frame because it shows it as well, so 
 829         // just remember that we should do it later in this case 
 831         m_bMaximizeOnShow 
= bMaximize
; 
 833 } // end of wxTopLevelWindowOS2::Maximize 
 835 bool wxTopLevelWindowOS2::IsMaximized() const 
 837     ::WinQueryWindowPos(m_hFrame
, (PSWP
)&m_vSwp
); 
 838     return (m_vSwp
.fl 
& SWP_MAXIMIZE
) == SWP_MAXIMIZE
; 
 839 } // end of wxTopLevelWindowOS2::IsMaximized 
 841 void wxTopLevelWindowOS2::SetTitle( const wxString
& title
) 
 846 wxString 
wxTopLevelWindowOS2::GetTitle() const 
 851 void wxTopLevelWindowOS2::Iconize( bool bIconize 
) 
 853     DoShowWindow(bIconize 
? SWP_MINIMIZE 
: SWP_RESTORE
); 
 854 } // end of wxTopLevelWindowOS2::Iconize 
 856 bool wxTopLevelWindowOS2::IsIconized() const 
 858     // also update the current state 
 859     ::WinQueryWindowPos(m_hFrame
, (PSWP
)&m_vSwp
); 
 860     if (m_vSwp
.fl 
& SWP_MINIMIZE
) 
 861         ((wxTopLevelWindow
*)this)->m_bIconized 
= true; 
 863         ((wxTopLevelWindow
*)this)->m_bIconized 
= false; 
 865 } // end of wxTopLevelWindowOS2::IsIconized 
 867 void wxTopLevelWindowOS2::Restore() 
 869     DoShowWindow(SWP_RESTORE
); 
 870 } // end of wxTopLevelWindowOS2::Restore 
 872 // generate an artificial resize event 
 873 void wxTopLevelWindowOS2::SendSizeEvent(int flags
) 
 877         RECTL                       vRect 
= wxGetWindowRect(GetHwnd()); 
 879         if ( flags 
& wxSEND_EVENT_POST 
) 
 881             (void)::WinPostMsg( m_hFrame
 
 883                                ,MPFROM2SHORT(vRect
.xRight 
- vRect
.xLeft
, vRect
.yTop 
- vRect
.yBottom
) 
 884                                ,MPFROM2SHORT(vRect
.xRight 
- vRect
.xLeft
, vRect
.yTop 
- vRect
.yBottom
) 
 889             (void)::WinSendMsg( m_hFrame
 
 891                                ,MPFROM2SHORT(vRect
.xRight 
- vRect
.xLeft
, vRect
.yTop 
- vRect
.yBottom
) 
 892                                ,MPFROM2SHORT(vRect
.xRight 
- vRect
.xLeft
, vRect
.yTop 
- vRect
.yBottom
) 
 896 } // end of wxTopLevelWindowOS2::SendSizeEvent 
 898 // ---------------------------------------------------------------------------- 
 899 // wxTopLevelWindowOS2 fullscreen 
 900 // ---------------------------------------------------------------------------- 
 902 bool wxTopLevelWindowOS2::ShowFullScreen( bool bShow
, 
 910         m_bFsIsShowing 
= true; 
 914         // Zap the frame borders 
 918         // Save the 'normal' window lStyle 
 920         m_lFsOldWindowStyle 
= ::WinQueryWindowULong( (HWND
)GetHWND() 
 925         // Save the old position, width & height, maximize state 
 927         m_vFsOldSize 
= GetRect(); 
 928         m_bFsIsMaximized 
= IsMaximized(); 
 931         // Decide which window lStyle flags to turn off 
 933         LONG lNewStyle 
= m_lFsOldWindowStyle
; 
 936         if (lStyle 
& wxFULLSCREEN_NOBORDER
) 
 937             lOffFlags 
|= FCF_BORDER
; 
 938         if (lStyle 
& wxFULLSCREEN_NOCAPTION
) 
 939             lOffFlags 
|= (FCF_TASKLIST 
| FCF_SYSMENU
); 
 941         lNewStyle 
&= (~lOffFlags
); 
 944         // Change our window style to be compatible with full-screen mode 
 946         ::WinSetWindowULong( (HWND
)GetHWND() 
 952         // Resize to the size of the desktop 
 956         RECTL vRect 
= wxGetWindowRect(HWND_DESKTOP
); 
 958         nWidth 
= vRect
.xRight 
- vRect
.xLeft
; 
 959         nHeight 
= vRect
.yTop 
- vRect
.yBottom
; 
 961         SetSize( nWidth
, nHeight 
); 
 964         // Now flush the window style cache and actually go full-screen 
 966         ::WinSetWindowPos( m_hFrame
 
 975         wxSize 
full( nWidth
, nHeight 
); 
 976         wxSizeEvent 
vEvent( full
, GetId() ); 
 977         HandleWindowEvent(vEvent
); 
 985         m_bFsIsShowing 
= false; 
 986         Maximize(m_bFsIsMaximized
); 
 987         ::WinSetWindowULong( (HWND
)GetHWND() 
 991         ::WinSetWindowPos( m_hFrame
 
1001 } // end of wxTopLevelWindowOS2::ShowFullScreen 
1003 // ---------------------------------------------------------------------------- 
1004 // wxTopLevelWindowOS2 misc 
1005 // ---------------------------------------------------------------------------- 
1007 void wxTopLevelWindowOS2::SetIcons( 
1008   const wxIconBundle
&               rIcons
 
1014     wxTopLevelWindowBase::SetIcons(rIcons
); 
1016     const wxIcon
& vIcon 
= rIcons
.GetIconOfExactSize(32); 
1020         ::WinSendMsg( m_hFrame
 
1022                      ,(MPARAM
)((HPOINTER
)vIcon
.GetHICON()) 
1025         ::WinSendMsg( m_hFrame
 
1031 } // end of wxTopLevelWindowOS2::SetIcon 
1033 bool wxTopLevelWindowOS2::EnableCloseButton( bool bEnable 
) 
1036     // Get system (a.k.a. window) menu 
1038     HMENU hMenu 
= ::WinWindowFromID(m_hFrame
, FID_SYSMENU
); 
1042         wxLogLastError(wxT("GetSystemMenu")); 
1047     // Enabling/disabling the close item from it also automatically 
1048     // disables/enables the close title bar button 
1051         (void)::WinSendMsg( hMenu
 
1053                            ,MPFROM2SHORT(SC_CLOSE
, FALSE
) 
1054                            ,MPFROM2SHORT(MIA_DISABLED
, FALSE
) 
1057         (void)::WinSendMsg( hMenu
 
1059                            ,MPFROM2SHORT(SC_CLOSE
, FALSE
) 
1060                            ,MPFROM2SHORT(MIA_DISABLED
, MIA_DISABLED
) 
1064     // Update appearance immediately 
1066     ::WinSendMsg( m_hFrame
 
1072 } // end of wxTopLevelWindowOS2::EnableCloseButton 
1074 // ============================================================================ 
1075 // wxTLWHiddenParentModule implementation 
1076 // ============================================================================ 
1078 HWND          
wxTLWHiddenParentModule::m_shWnd 
= NULL
; 
1079 const wxChar
* wxTLWHiddenParentModule::m_szClassName 
= NULL
; 
1081 bool wxTLWHiddenParentModule::OnInit() 
1084     m_szClassName 
= NULL
; 
1086 } // end of wxTLWHiddenParentModule::OnInit 
1088 void wxTLWHiddenParentModule::OnExit() 
1092         if (!::WinDestroyWindow(m_shWnd
)) 
1094             wxLogLastError(wxT("DestroyWindow(hidden TLW parent)")); 
1099     m_szClassName 
= NULL
; 
1100 } // end of wxTLWHiddenParentModule::OnExit 
1103 HWND 
wxTLWHiddenParentModule::GetHWND() 
1109             static const wxChar
*    zHIDDEN_PARENT_CLASS 
= wxT("wxTLWHiddenParent"); 
1111             if (!::WinRegisterClass( wxGetInstance() 
1112                                     ,(PSZ
)zHIDDEN_PARENT_CLASS
 
1118                 wxLogLastError(wxT("RegisterClass(\"wxTLWHiddenParent\")")); 
1122                 m_szClassName 
= zHIDDEN_PARENT_CLASS
; 
1125         m_shWnd 
= ::WinCreateWindow( HWND_DESKTOP
, 
1140             wxLogLastError(wxT("CreateWindow(hidden TLW parent)")); 
1144 } // end of wxTLWHiddenParentModule::GetHWND