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 // License: 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"
41 #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
= (wxWindow
*)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(_T("focus"), _T("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(_T("focus"),
204 _T("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_VERT
)
250 lMsflags
|= FCF_TASKLIST
;
251 if (lStyle
& wxTINY_CAPTION_HORIZ
)
252 lMsflags
|= FCF_TASKLIST
;
254 if ((lStyle
& wxRESIZE_BORDER
) == 0)
255 lMsflags
|= FCF_BORDER
;
256 if (lStyle
& wxFRAME_TOOL_WINDOW
)
257 *pdwExflags
= kFrameToolWindow
;
259 if (lStyle
& wxSTAY_ON_TOP
)
260 lMsflags
|= FCF_SYSMODAL
;
263 } // end of wxTopLevelWindowOS2::OS2GetCreateWindowFlags
265 WXHWND
wxTopLevelWindowOS2::OS2GetParent() const
267 HWND hWndParent
= NULL
;
270 // For the frames without wxFRAME_FLOAT_ON_PARENT style we should use NULL
271 // parent HWND or it would be always on top of its parent which is not what
272 // we usually want (in fact, we only want it for frames with the
273 // wxFRAME_FLOAT_ON_PARENT flag)
275 if (HasFlag(wxFRAME_FLOAT_ON_PARENT
) )
277 const wxWindow
* pParent
= GetParent();
282 // This flag doesn't make sense then and will be ignored
284 wxFAIL_MSG( _T("wxFRAME_FLOAT_ON_PARENT but no parent?") );
288 hWndParent
= GetHwndOf(pParent
);
291 //else: don't float on parent, must not be owned
294 // Now deal with the 2nd taskbar-related problem (see comments above in
297 if (HasFlag(wxFRAME_NO_TASKBAR
) && !hWndParent
)
302 hWndParent
= wxTLWHiddenParentModule::GetHWND();
304 return (WXHWND
)hWndParent
;
305 } // end of wxTopLevelWindowOS2::OS2GetParent
308 bool wxTopLevelWindowOS2::CreateDialog( ULONG ulDlgTemplate
,
309 const wxString
& WXUNUSED(rsTitle
),
311 const wxSize
& rSize
)
313 wxWindow
* pParent
= GetParent();
316 // For the dialogs without wxDIALOG_NO_PARENT style, use the top level
317 // app window as parent - this avoids creating modal dialogs without
320 if (!pParent
&& !(GetWindowStyleFlag() & wxDIALOG_NO_PARENT
))
322 pParent
= wxTheApp
->GetTopWindow();
327 // Don't use transient windows as parents, this is dangerous as it
328 // can lead to a crash if the parent is destroyed before the child
330 // also don't use the window which is currently hidden as then the
331 // dialog would be hidden as well
332 if ((pParent
->GetExtraStyle() & wxWS_EX_TRANSIENT
) ||
344 hWndOwner
= GetHwndOf(pParent
);
346 hWndOwner
= HWND_DESKTOP
;
348 hWndDlg
= ::WinLoadDlg( HWND_DESKTOP
352 ,(ULONG
)ulDlgTemplate
356 m_hWnd
= (WXHWND
) hWndDlg
;
360 wxFAIL_MSG(wxT("Did you forget to include wx/os2/wx.rc in your resources?"));
362 wxLogSysError(wxT("Can't create dialog using template '%ld'"), ulDlgTemplate
);
368 // Move the dialog to its initial position without forcing repainting
375 if (!OS2GetCreateWindowCoords( rPos
383 nX
= nWidth
= (int)CW_USEDEFAULT
;
387 // We can't use CW_USEDEFAULT here as we're not calling CreateWindow()
388 // and passing CW_USEDEFAULT to MoveWindow() results in resizing the
389 // window to (0, 0) size which breaks quite a lot of things, e.g. the
390 // sizer calculation in wxSizer::Fit()
392 if (nWidth
== (int)CW_USEDEFAULT
)
395 // The exact number doesn't matter, the dialog will be resized
396 // again soon anyhow but it should be big enough to allow
397 // calculation relying on "totalSize - clientSize > 0" work, i.e.
398 // at least greater than the title bar height
400 nWidth
= nHeight
= 100;
402 if (nX
== (int)CW_USEDEFAULT
)
405 // Centre it on the screen - what else can we do?
407 wxSize vSizeDpy
= wxGetDisplaySize();
409 nX
= (vSizeDpy
.x
- nWidth
) / 2;
410 nY
= (vSizeDpy
.y
- nHeight
) / 2;
412 SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_APPWORKSPACE
));
414 LONG lColor
= (LONG
)m_backgroundColour
.GetPixel();
416 if (!::WinSetPresParam( m_hWnd
425 // Convert to OS/2 coordinates
426 nY
= GetOS2ParentHeight(pParent
) - nY
- nHeight
;
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( const wxString
& rsTitle
,
444 const wxSize
& rSize
)
447 WXDWORD lFlags
= OS2GetCreateWindowFlags(&lExflags
);
448 long lStyle
= GetWindowStyleFlag();
451 int nWidth
= rSize
.x
;
452 int nHeight
= rSize
.y
;
453 ULONG ulStyleFlags
= 0L;
456 wxWindow
* pParent
= GetParent();
462 hParent
= GetHwndOf(pParent
);
464 hParent
= HWND_DESKTOP
;
466 if ((lStyle
& wxMINIMIZE
) || (lStyle
& wxICONIZE
))
467 ulStyleFlags
|= WS_MINIMIZED
;
468 if (lStyle
& wxMAXIMIZE
)
469 ulStyleFlags
|= WS_MAXIMIZED
;
472 // Clear the visible flag, we always call show
474 ulStyleFlags
&= (unsigned long)~WS_VISIBLE
;
478 // Create the frame window: We break ranks with other ports now
479 // and instead of calling down into the base wxWindow class' OS2Create
480 // we do all our own stuff here. We will set the needed pieces
481 // of wxWindow manually, here.
484 hFrame
= ::WinCreateStdWindow( hParent
485 ,ulStyleFlags
// frame-window style
486 ,(PULONG
)&lFlags
// window style
487 ,(PSZ
)wxFrameClassName
// class name
488 ,(PSZ
)rsTitle
.c_str() // window title
489 ,0L // default client style
490 ,NULLHANDLE
// resource in executable file
492 ,&hClient
// receives client window handle
496 vError
= ::WinGetLastError(vHabmain
);
497 sError
= wxPMErrorToStr(vError
);
498 wxLogError(_T("Error creating frame. Error: %s\n"), sError
.c_str());
503 // wxWindow class' m_hWnd set here and needed associations
507 wxAssociateWinWithHandle(m_hWnd
, this);
508 wxAssociateWinWithHandle(m_hFrame
, this);
510 SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_APPWORKSPACE
));
512 LONG lColor
= (LONG
)m_backgroundColour
.GetPixel();
514 if (!::WinSetPresParam( m_hWnd
520 vError
= ::WinGetLastError(vHabmain
);
521 sError
= wxPMErrorToStr(vError
);
522 wxLogError(_T("Error creating frame. Error: %s\n"), sError
.c_str());
527 // Now need to subclass window. Instead of calling the SubClassWin in wxWindow
528 // we manually subclass here because we don't want to use the main wxWndProc
531 m_fnOldWndProc
= (WXFARPROC
) ::WinSubclassWindow(m_hFrame
, (PFNWP
)wxFrameMainWndProc
);
534 // Now size everything. If adding a menu the client will need to be resized.
537 if (!OS2GetCreateWindowCoords( rPos
545 nX
= nWidth
= (int)CW_USEDEFAULT
;
549 // We can't use CW_USEDEFAULT here as we're not calling CreateWindow()
550 // and passing CW_USEDEFAULT to MoveWindow() results in resizing the
551 // window to (0, 0) size which breaks quite a lot of things, e.g. the
552 // sizer calculation in wxSizer::Fit()
554 if (nWidth
== (int)CW_USEDEFAULT
)
557 // The exact number doesn't matter, the dialog will be resized
558 // again soon anyhow but it should be big enough to allow
559 // calculation relying on "totalSize - clientSize > 0" work, i.e.
560 // at least greater than the title bar height
562 nWidth
= nHeight
= 100;
564 if (nX
== (int)CW_USEDEFAULT
)
567 // Centre it on the screen for now - what else can we do?
568 // TODO: We could try FCF_SHELLPOSITION but it will require moving
569 // things around a bit.
571 wxSize vSizeDpy
= wxGetDisplaySize();
573 nX
= (vSizeDpy
.x
- nWidth
) / 2;
574 nY
= (vSizeDpy
.y
- nHeight
) / 2;
577 // Convert to OS/2 coordinates
578 nY
= GetOS2ParentHeight(pParent
) - nY
- nHeight
;
580 if (!::WinSetWindowPos( m_hFrame
586 ,SWP_SIZE
| SWP_MOVE
| SWP_ACTIVATE
| SWP_ZORDER
589 vError
= ::WinGetLastError(vHabmain
);
590 sError
= wxPMErrorToStr(vError
);
591 wxLogError(_T("Error sizing frame. Error: %s\n"), sError
.c_str());
594 lStyle
= ::WinQueryWindowULong( m_hWnd
597 lStyle
|= WS_CLIPCHILDREN
;
598 ::WinSetWindowULong( m_hWnd
603 } // end of wxTopLevelWindowOS2::CreateFrame
605 bool wxTopLevelWindowOS2::Create(
608 , const wxString
& rsTitle
609 , const wxPoint
& rPos
610 , const wxSize
& rSizeOrig
612 , const wxString
& rsName
619 m_windowStyle
= lStyle
;
621 m_windowId
= vId
== -1 ? NewControlId() : vId
;
623 // always create a frame of some reasonable, even if arbitrary, size (at
624 // least for MSW compatibility)
625 wxSize rSize
= rSizeOrig
;
626 if ( rSize
.x
== -1 || rSize
.y
== -1 )
628 wxSize sizeDpy
= wxGetDisplaySize();
630 rSize
.x
= sizeDpy
.x
/ 3;
632 rSize
.y
= sizeDpy
.y
/ 5;
635 wxTopLevelWindows
.Append(this);
637 pParent
->AddChild(this);
639 if (GetExtraStyle() & wxTOPLEVEL_EX_DIALOG
)
642 // We have different dialog templates to allow creation of dialogs
643 // with & without captions under OS2indows, resizeable or not (but a
644 // resizeable dialog always has caption - otherwise it would look too
649 if (lStyle
& wxRESIZE_BORDER
)
650 ulDlgTemplate
= (ULONG
)kResizeableDialog
;
651 else if (lStyle
& wxCAPTION
)
652 ulDlgTemplate
= (ULONG
)kCaptionDialog
;
654 ulDlgTemplate
= (ULONG
)kNoCaptionDialog
;
655 return CreateDialog( ulDlgTemplate
663 return CreateFrame( rsTitle
668 } // end of wxTopLevelWindowOS2::Create
670 wxTopLevelWindowOS2::~wxTopLevelWindowOS2()
673 // After destroying an owned window, Windows activates the next top level
674 // window in Z order but it may be different from our owner (to reproduce
675 // this simply Alt-TAB to another application and back before closing the
676 // owned frame) whereas we always want to yield activation to our parent
678 if (HasFlag(wxFRAME_FLOAT_ON_PARENT
))
680 wxWindow
* pParent
= GetParent();
684 ::WinSetWindowPos( GetHwndOf(pParent
)
691 } // end of wxTopLevelWindowOS2::~wxTopLevelWindowOS2
693 // ----------------------------------------------------------------------------
694 // wxTopLevelWindowOS2 client size
695 // ----------------------------------------------------------------------------
697 void wxTopLevelWindowOS2::DoSetClientSize(
703 // Call GetClientAreaOrigin() to take the toolbar into account
705 wxPoint vPt
= GetClientAreaOrigin();
710 wxWindow::DoSetClientSize( nWidth
713 } // end of wxTopLevelWindowOS2::DoSetClientSize
715 void wxTopLevelWindowOS2::DoGetClientSize(
720 wxWindow::DoGetClientSize( pnX
724 wxPoint vPt
= GetClientAreaOrigin();
731 } // end of wxTopLevelWindowOS2::DoGetClientSize
733 // ----------------------------------------------------------------------------
734 // wxTopLevelWindowOS2 showing
735 // ----------------------------------------------------------------------------
737 void wxTopLevelWindowOS2::DoShowWindow(
741 ::WinShowWindow(m_hFrame
, (BOOL
)(nShowCmd
& SWP_SHOW
));
744 // Need to artificially send a size event as wxApps often expect to do some
745 // final child control sizing
747 m_bIconized
= nShowCmd
== SWP_MINIMIZE
;
748 } // end of wxTopLevelWindowOS2::DoShowWindow
750 bool wxTopLevelWindowOS2::Show( bool bShow
)
755 if (bShow
!= IsShown() )
765 if (m_bMaximizeOnShow
)
767 nShowCmd
= SWP_MAXIMIZE
;
768 m_bMaximizeOnShow
= false;
779 DoShowWindow(nShowCmd
);
783 wxActivateEvent
vEvent(wxEVT_ACTIVATE
, true, m_windowId
);
785 ::WinQueryWindowPos(m_hFrame
, &vSwp
);
786 m_bIconized
= ( vSwp
.fl
& SWP_MINIMIZE
) == SWP_MINIMIZE
;
787 ::WinQueryWindowPos(m_hWnd
, &m_vSwpClient
);
788 ::WinSendMsg(m_hFrame
, WM_UPDATEFRAME
, (MPARAM
)~0, 0);
789 ::WinQueryWindowPos(m_hWnd
, &vSwp
);
790 ::WinEnableWindow(m_hFrame
, TRUE
);
792 vEvent
.SetEventObject(this);
793 GetEventHandler()->ProcessEvent(vEvent
);
798 // Try to highlight the correct window (the parent)
802 HWND hWndParent
= GetHwndOf(GetParent());
804 ::WinQueryWindowPos(hWndParent
, &vSwp
);
805 m_bIconized
= (vSwp
.fl
& SWP_MINIMIZE
)==SWP_MINIMIZE
;
806 ::WinEnableWindow(hWndParent
, TRUE
);
810 } // end of wxTopLevelWindowOS2::Show
812 // ----------------------------------------------------------------------------
813 // wxTopLevelWindowOS2 maximize/minimize
814 // ----------------------------------------------------------------------------
816 void wxTopLevelWindowOS2::Maximize(
823 // Just maximize it directly
825 DoShowWindow(bMaximize
? SWP_MAXIMIZE
: SWP_RESTORE
);
830 // We can't maximize the hidden frame because it shows it as well, so
831 // just remember that we should do it later in this case
833 m_bMaximizeOnShow
= bMaximize
;
835 } // end of wxTopLevelWindowOS2::Maximize
837 bool wxTopLevelWindowOS2::IsMaximized() const
839 ::WinQueryWindowPos(m_hFrame
, (PSWP
)&m_vSwp
);
840 return (m_vSwp
.fl
& SWP_MAXIMIZE
) == SWP_MAXIMIZE
;
841 } // end of wxTopLevelWindowOS2::IsMaximized
843 void wxTopLevelWindowOS2::SetTitle( const wxString
& title
)
848 wxString
wxTopLevelWindowOS2::GetTitle() const
853 void wxTopLevelWindowOS2::Iconize( bool bIconize
)
855 DoShowWindow(bIconize
? SWP_MINIMIZE
: SWP_RESTORE
);
856 } // end of wxTopLevelWindowOS2::Iconize
858 bool wxTopLevelWindowOS2::IsIconized() const
860 // also update the current state
861 ::WinQueryWindowPos(m_hFrame
, (PSWP
)&m_vSwp
);
862 if (m_vSwp
.fl
& SWP_MINIMIZE
)
863 ((wxTopLevelWindow
*)this)->m_bIconized
= true;
865 ((wxTopLevelWindow
*)this)->m_bIconized
= false;
867 } // end of wxTopLevelWindowOS2::IsIconized
869 void wxTopLevelWindowOS2::Restore()
871 DoShowWindow(SWP_RESTORE
);
872 } // end of wxTopLevelWindowOS2::Restore
874 // generate an artificial resize event
875 void wxTopLevelWindowOS2::SendSizeEvent()
879 RECTL vRect
= wxGetWindowRect(GetHwnd());
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
)
887 } // end of wxTopLevelWindowOS2::SendSizeEvent
889 // ----------------------------------------------------------------------------
890 // wxTopLevelWindowOS2 fullscreen
891 // ----------------------------------------------------------------------------
893 bool wxTopLevelWindowOS2::ShowFullScreen( bool bShow
,
901 m_bFsIsShowing
= true;
905 // Zap the frame borders
909 // Save the 'normal' window lStyle
911 m_lFsOldWindowStyle
= ::WinQueryWindowULong( (HWND
)GetHWND()
916 // Save the old position, width & height, maximize state
918 m_vFsOldSize
= GetRect();
919 m_bFsIsMaximized
= IsMaximized();
922 // Decide which window lStyle flags to turn off
924 LONG lNewStyle
= m_lFsOldWindowStyle
;
927 if (lStyle
& wxFULLSCREEN_NOBORDER
)
928 lOffFlags
|= FCF_BORDER
;
929 if (lStyle
& wxFULLSCREEN_NOCAPTION
)
930 lOffFlags
|= (FCF_TASKLIST
| FCF_SYSMENU
);
932 lNewStyle
&= (~lOffFlags
);
935 // Change our window style to be compatible with full-screen mode
937 ::WinSetWindowULong( (HWND
)GetHWND()
943 // Resize to the size of the desktop
947 RECTL vRect
= wxGetWindowRect(HWND_DESKTOP
);
949 nWidth
= vRect
.xRight
- vRect
.xLeft
;
950 nHeight
= vRect
.yTop
- vRect
.yBottom
;
952 SetSize( nWidth
, nHeight
);
955 // Now flush the window style cache and actually go full-screen
957 ::WinSetWindowPos( m_hFrame
966 wxSize
full( nWidth
, nHeight
);
967 wxSizeEvent
vEvent( full
, GetId() );
968 GetEventHandler()->ProcessEvent(vEvent
);
976 m_bFsIsShowing
= false;
977 Maximize(m_bFsIsMaximized
);
978 ::WinSetWindowULong( (HWND
)GetHWND()
982 ::WinSetWindowPos( m_hFrame
992 } // end of wxTopLevelWindowOS2::ShowFullScreen
994 // ----------------------------------------------------------------------------
995 // wxTopLevelWindowOS2 misc
996 // ----------------------------------------------------------------------------
998 void wxTopLevelWindowOS2::SetIcon(
1002 SetIcons(wxIconBundle(rIcon
));
1003 } // end of wxTopLevelWindowOS2::SetIcon
1005 void wxTopLevelWindowOS2::SetIcons(
1006 const wxIconBundle
& rIcons
1012 wxTopLevelWindowBase::SetIcons(rIcons
);
1014 const wxIcon
& vIcon
= rIcons
.GetIcon(wxSize(32, 32));
1016 if (vIcon
.Ok() && vIcon
.GetWidth() == 32 && vIcon
.GetHeight() == 32)
1018 ::WinSendMsg( m_hFrame
1020 ,(MPARAM
)((HPOINTER
)vIcon
.GetHICON())
1023 ::WinSendMsg( m_hFrame
1029 } // end of wxTopLevelWindowOS2::SetIcon
1031 bool wxTopLevelWindowOS2::EnableCloseButton( bool bEnable
)
1034 // Get system (a.k.a. window) menu
1036 HMENU hMenu
= ::WinWindowFromID(m_hFrame
, FID_SYSMENU
);
1040 wxLogLastError(_T("GetSystemMenu"));
1045 // Enabling/disabling the close item from it also automatically
1046 // disables/enables the close title bar button
1049 (void)::WinSendMsg( hMenu
1051 ,MPFROM2SHORT(SC_CLOSE
, FALSE
)
1052 ,MPFROM2SHORT(MIA_DISABLED
, FALSE
)
1055 (void)::WinSendMsg( hMenu
1057 ,MPFROM2SHORT(SC_CLOSE
, FALSE
)
1058 ,MPFROM2SHORT(MIA_DISABLED
, MIA_DISABLED
)
1062 // Update appearance immediately
1064 ::WinSendMsg( m_hFrame
1070 } // end of wxTopLevelWindowOS2::EnableCloseButton
1072 // ============================================================================
1073 // wxTLWHiddenParentModule implementation
1074 // ============================================================================
1076 HWND
wxTLWHiddenParentModule::m_shWnd
= NULL
;
1077 const wxChar
* wxTLWHiddenParentModule::m_szClassName
= NULL
;
1079 bool wxTLWHiddenParentModule::OnInit()
1082 m_szClassName
= NULL
;
1084 } // end of wxTLWHiddenParentModule::OnInit
1086 void wxTLWHiddenParentModule::OnExit()
1090 if (!::WinDestroyWindow(m_shWnd
))
1092 wxLogLastError(_T("DestroyWindow(hidden TLW parent)"));
1097 m_szClassName
= NULL
;
1098 } // end of wxTLWHiddenParentModule::OnExit
1101 HWND
wxTLWHiddenParentModule::GetHWND()
1107 static const wxChar
* zHIDDEN_PARENT_CLASS
= _T("wxTLWHiddenParent");
1109 if (!::WinRegisterClass( wxGetInstance()
1110 ,(PSZ
)zHIDDEN_PARENT_CLASS
1116 wxLogLastError(_T("RegisterClass(\"wxTLWHiddenParent\")"));
1120 m_szClassName
= zHIDDEN_PARENT_CLASS
;
1123 m_shWnd
= ::WinCreateWindow( HWND_DESKTOP
,
1138 wxLogLastError(_T("CreateWindow(hidden TLW parent)"));
1142 } // end of wxTLWHiddenParentModule::GetHWND