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"
29 #include "wx/toplevel.h"
30 #include "wx/dialog.h"
31 #include "wx/string.h"
35 #include "wx/control.h"
36 #include "wx/containr.h" // wxSetFocusToChild()
37 #include "wx/settings.h"
40 #include "wx/module.h" // wxSetFocusToChild()
41 #include "wx/os2/private.h"
43 // ----------------------------------------------------------------------------
44 // stubs for missing functions under MicroWindows
45 // ----------------------------------------------------------------------------
48 // ----------------------------------------------------------------------------
50 // ----------------------------------------------------------------------------
52 // the name of the default wxWidgets class
53 extern void wxAssociateWinWithHandle( HWND hWnd
, wxWindowOS2
* pWin
);
55 bool wxTopLevelWindowOS2::m_sbInitialized
= false;
56 wxWindow
* wxTopLevelWindowOS2::m_spHiddenParent
= NULL
;
58 // ============================================================================
59 // wxTopLevelWindowOS2 implementation
60 // ============================================================================
62 BEGIN_EVENT_TABLE(wxTopLevelWindowOS2
, wxTopLevelWindowBase
)
63 EVT_ACTIVATE(wxTopLevelWindowOS2::OnActivate
)
66 // ============================================================================
67 // wxTopLevelWindowMSW implementation
68 // ============================================================================
71 MRESULT EXPENTRY
wxDlgProc( HWND
WXUNUSED(hWnd
)
73 ,void * WXUNUSED(wParam
)
74 ,void * WXUNUSED(lParam
)
81 // For this message, returning TRUE tells system to set focus to
82 // the first control in the dialog box, but we set the focus
83 // ourselves, however in OS/2 we must return true to enable the dialog
88 // For all the other ones, FALSE means that we didn't process the
91 return (MRESULT
)FALSE
;
95 // ----------------------------------------------------------------------------
96 // wxTLWHiddenParentModule: used to manage the hidden parent window (we need a
97 // module to ensure that the window is always deleted)
98 // ----------------------------------------------------------------------------
100 class wxTLWHiddenParentModule
: public wxModule
104 // Module init/finalize
106 virtual bool OnInit(void);
107 virtual void OnExit(void);
110 // Get the hidden window (creates on demand)
112 static HWND
GetHWND(void);
116 // The HWND of the hidden parent
121 // The class used to create it
123 static const wxChar
* m_szClassName
;
124 DECLARE_DYNAMIC_CLASS(wxTLWHiddenParentModule
)
125 }; // end of CLASS wxTLWHiddenParentModule
127 IMPLEMENT_DYNAMIC_CLASS(wxTLWHiddenParentModule
, wxModule
)
129 // ----------------------------------------------------------------------------
130 // wxTopLevelWindowOS2 creation
131 // ----------------------------------------------------------------------------
133 void wxTopLevelWindowOS2::Init()
135 m_bIconized
= m_bMaximizeOnShow
= false;
138 // Unlike (almost?) all other windows, frames are created hidden
143 // Data to save/restore when calling ShowFullScreen
145 m_lFsOldWindowStyle
= 0;
146 m_bFsIsMaximized
= false;
147 m_bFsIsShowing
= false;
149 m_hFrame
= NULLHANDLE
;
150 memset(&m_vSwp
, 0, sizeof(SWP
));
151 memset(&m_vSwpClient
, 0, sizeof(SWP
));
152 m_pWinLastFocused
= (wxWindow
*)NULL
;
153 } // end of wxTopLevelWindowIOS2::Init
155 void wxTopLevelWindowOS2::OnActivate(
156 wxActivateEvent
& rEvent
159 if (rEvent
.GetActive())
162 // Restore focus to the child which was last focused
164 wxLogTrace(_T("focus"), _T("wxTLW %08lx activated."), m_hWnd
);
166 wxWindow
* pParent
= m_pWinLastFocused
? m_pWinLastFocused
->GetParent()
173 wxSetFocusToChild( pParent
180 // Remember the last focused child if it is our child
182 m_pWinLastFocused
= FindFocus();
185 // So we NULL it out if it's a child from some other frame
187 wxWindow
* pWin
= m_pWinLastFocused
;
191 if (pWin
->IsTopLevel())
195 m_pWinLastFocused
= NULL
;
199 pWin
= pWin
->GetParent();
202 wxLogTrace(_T("focus"),
203 _T("wxTLW %08lx deactivated, last focused: %08lx."),
205 m_pWinLastFocused
? GetHwndOf(m_pWinLastFocused
)
209 } // end of wxTopLevelWindowOS2::OnActivate
211 WXDWORD
wxTopLevelWindowOS2::OS2GetStyle(
213 , WXDWORD
* pdwExflags
216 long lMsflags
= wxWindow::OS2GetStyle( (lStyle
& ~wxBORDER_MASK
) | wxBORDER_NONE
220 if ((lStyle
& wxDEFAULT_FRAME_STYLE
) == wxDEFAULT_FRAME_STYLE
)
221 lMsflags
|= FCF_SIZEBORDER
| FCF_TITLEBAR
| FCF_SYSMENU
|
222 FCF_MINMAX
| FCF_TASKLIST
;
224 if ((lStyle
& wxCAPTION
) == wxCAPTION
)
225 lMsflags
|= FCF_TASKLIST
;
227 lMsflags
|= FCF_NOMOVEWITHOWNER
;
229 if ((lStyle
& wxVSCROLL
) == wxVSCROLL
)
230 lMsflags
|= FCF_VERTSCROLL
;
231 if ((lStyle
& wxHSCROLL
) == wxHSCROLL
)
232 lMsflags
|= FCF_HORZSCROLL
;
233 if (lStyle
& wxMINIMIZE_BOX
)
234 lMsflags
|= FCF_MINBUTTON
;
235 if (lStyle
& wxMAXIMIZE_BOX
)
236 lMsflags
|= FCF_MAXBUTTON
;
237 if (lStyle
& wxTHICK_FRAME
)
238 lMsflags
|= FCF_DLGBORDER
;
239 if (lStyle
& wxSYSTEM_MENU
)
240 lMsflags
|= FCF_SYSMENU
;
241 if (lStyle
& wxCAPTION
)
242 lMsflags
|= FCF_TASKLIST
;
243 if (lStyle
& wxCLIP_CHILDREN
)
245 // Invalid for frame windows under PM
248 if (lStyle
& wxTINY_CAPTION_VERT
)
249 lMsflags
|= FCF_TASKLIST
;
250 if (lStyle
& wxTINY_CAPTION_HORIZ
)
251 lMsflags
|= FCF_TASKLIST
;
253 if ((lStyle
& wxTHICK_FRAME
) == 0)
254 lMsflags
|= FCF_BORDER
;
255 if (lStyle
& wxFRAME_TOOL_WINDOW
)
256 *pdwExflags
= kFrameToolWindow
;
258 if (lStyle
& wxSTAY_ON_TOP
)
259 lMsflags
|= FCF_SYSMODAL
;
262 } // end of wxTopLevelWindowOS2::OS2GetCreateWindowFlags
264 WXHWND
wxTopLevelWindowOS2::OS2GetParent() const
266 HWND hWndParent
= NULL
;
269 // For the frames without wxFRAME_FLOAT_ON_PARENT style we should use NULL
270 // parent HWND or it would be always on top of its parent which is not what
271 // we usually want (in fact, we only want it for frames with the
272 // wxFRAME_FLOAT_ON_PARENT flag)
274 if (HasFlag(wxFRAME_FLOAT_ON_PARENT
) )
276 const wxWindow
* pParent
= GetParent();
281 // This flag doesn't make sense then and will be ignored
283 wxFAIL_MSG( _T("wxFRAME_FLOAT_ON_PARENT but no parent?") );
287 hWndParent
= GetHwndOf(pParent
);
290 //else: don't float on parent, must not be owned
293 // Now deal with the 2nd taskbar-related problem (see comments above in
296 if (HasFlag(wxFRAME_NO_TASKBAR
) && !hWndParent
)
301 hWndParent
= wxTLWHiddenParentModule::GetHWND();
303 return (WXHWND
)hWndParent
;
304 } // end of wxTopLevelWindowOS2::OS2GetParent
307 bool wxTopLevelWindowOS2::CreateDialog( ULONG ulDlgTemplate
,
308 const wxString
& WXUNUSED(rsTitle
),
310 const wxSize
& rSize
)
312 wxWindow
* pParent
= GetParent();
315 // For the dialogs without wxDIALOG_NO_PARENT style, use the top level
316 // app window as parent - this avoids creating modal dialogs without
319 if (!pParent
&& !(GetWindowStyleFlag() & wxDIALOG_NO_PARENT
))
321 pParent
= wxTheApp
->GetTopWindow();
326 // Don't use transient windows as parents, this is dangerous as it
327 // can lead to a crash if the parent is destroyed before the child
329 // also don't use the window which is currently hidden as then the
330 // dialog would be hidden as well
331 if ((pParent
->GetExtraStyle() & wxWS_EX_TRANSIENT
) ||
343 hWndOwner
= GetHwndOf(pParent
);
345 hWndOwner
= HWND_DESKTOP
;
347 hWndDlg
= ::WinLoadDlg( HWND_DESKTOP
351 ,(ULONG
)ulDlgTemplate
355 m_hWnd
= (WXHWND
) hWndDlg
;
359 wxFAIL_MSG(wxT("Did you forget to include wx/os2/wx.rc in your resources?"));
361 wxLogSysError(wxT("Can't create dialog using template '%ld'"), ulDlgTemplate
);
367 // Move the dialog to its initial position without forcing repainting
374 if (!OS2GetCreateWindowCoords( rPos
382 nX
= nWidth
= (int)CW_USEDEFAULT
;
386 // We can't use CW_USEDEFAULT here as we're not calling CreateWindow()
387 // and passing CW_USEDEFAULT to MoveWindow() results in resizing the
388 // window to (0, 0) size which breaks quite a lot of things, e.g. the
389 // sizer calculation in wxSizer::Fit()
391 if (nWidth
== (int)CW_USEDEFAULT
)
394 // The exact number doesn't matter, the dialog will be resized
395 // again soon anyhow but it should be big enough to allow
396 // calculation relying on "totalSize - clientSize > 0" work, i.e.
397 // at least greater than the title bar height
399 nWidth
= nHeight
= 100;
401 if (nX
== (int)CW_USEDEFAULT
)
404 // Centre it on the screen - what else can we do?
406 wxSize vSizeDpy
= wxGetDisplaySize();
408 nX
= (vSizeDpy
.x
- nWidth
) / 2;
409 nY
= (vSizeDpy
.y
- nHeight
) / 2;
411 SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_APPWORKSPACE
));
413 LONG lColor
= (LONG
)m_backgroundColour
.GetPixel();
415 if (!::WinSetPresParam( m_hWnd
424 // Convert to OS/2 coordinates
425 nY
= GetOS2ParentHeight(pParent
) - nY
- nHeight
;
427 ::WinSetWindowPos( GetHwnd()
433 ,SWP_MOVE
| SWP_SIZE
| SWP_ZORDER
| SWP_SHOW
| SWP_ACTIVATE
435 ::WinQueryWindowPos(GetHwnd(), GetSwp());
439 } // end of wxTopLevelWindowOS2::CreateDialog
441 bool wxTopLevelWindowOS2::CreateFrame( const wxString
& rsTitle
,
443 const wxSize
& rSize
)
446 WXDWORD lFlags
= OS2GetCreateWindowFlags(&lExflags
);
447 long lStyle
= GetWindowStyleFlag();
450 int nWidth
= rSize
.x
;
451 int nHeight
= rSize
.y
;
452 ULONG ulStyleFlags
= 0L;
455 wxWindow
* pParent
= GetParent();
461 hParent
= GetHwndOf(pParent
);
463 hParent
= HWND_DESKTOP
;
465 if ((lStyle
& wxMINIMIZE
) || (lStyle
& wxICONIZE
))
466 ulStyleFlags
|= WS_MINIMIZED
;
467 if (lStyle
& wxMAXIMIZE
)
468 ulStyleFlags
|= WS_MAXIMIZED
;
471 // Clear the visible flag, we always call show
473 ulStyleFlags
&= (unsigned long)~WS_VISIBLE
;
477 // Create the frame window: We break ranks with other ports now
478 // and instead of calling down into the base wxWindow class' OS2Create
479 // we do all our own stuff here. We will set the needed pieces
480 // of wxWindow manually, here.
483 hFrame
= ::WinCreateStdWindow( hParent
484 ,ulStyleFlags
// frame-window style
485 ,(PULONG
)&lFlags
// window style
486 ,(PSZ
)wxFrameClassName
// class name
487 ,(PSZ
)rsTitle
.c_str() // window title
488 ,0L // default client style
489 ,NULLHANDLE
// resource in executable file
491 ,&hClient
// receives client window handle
495 vError
= ::WinGetLastError(vHabmain
);
496 sError
= wxPMErrorToStr(vError
);
497 wxLogError(_T("Error creating frame. Error: %s\n"), sError
.c_str());
502 // wxWindow class' m_hWnd set here and needed associations
506 wxAssociateWinWithHandle(m_hWnd
, this);
507 wxAssociateWinWithHandle(m_hFrame
, this);
509 SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_APPWORKSPACE
));
511 LONG lColor
= (LONG
)m_backgroundColour
.GetPixel();
513 if (!::WinSetPresParam( m_hWnd
519 vError
= ::WinGetLastError(vHabmain
);
520 sError
= wxPMErrorToStr(vError
);
521 wxLogError(_T("Error creating frame. Error: %s\n"), sError
.c_str());
526 // Now need to subclass window. Instead of calling the SubClassWin in wxWindow
527 // we manually subclass here because we don't want to use the main wxWndProc
530 m_fnOldWndProc
= (WXFARPROC
) ::WinSubclassWindow(m_hFrame
, (PFNWP
)wxFrameMainWndProc
);
533 // Now size everything. If adding a menu the client will need to be resized.
536 if (!OS2GetCreateWindowCoords( rPos
544 nX
= nWidth
= (int)CW_USEDEFAULT
;
548 // We can't use CW_USEDEFAULT here as we're not calling CreateWindow()
549 // and passing CW_USEDEFAULT to MoveWindow() results in resizing the
550 // window to (0, 0) size which breaks quite a lot of things, e.g. the
551 // sizer calculation in wxSizer::Fit()
553 if (nWidth
== (int)CW_USEDEFAULT
)
556 // The exact number doesn't matter, the dialog will be resized
557 // again soon anyhow but it should be big enough to allow
558 // calculation relying on "totalSize - clientSize > 0" work, i.e.
559 // at least greater than the title bar height
561 nWidth
= nHeight
= 100;
563 if (nX
== (int)CW_USEDEFAULT
)
566 // Centre it on the screen for now - what else can we do?
567 // TODO: We could try FCF_SHELLPOSITION but it will require moving
568 // things around a bit.
570 wxSize vSizeDpy
= wxGetDisplaySize();
572 nX
= (vSizeDpy
.x
- nWidth
) / 2;
573 nY
= (vSizeDpy
.y
- nHeight
) / 2;
576 // Convert to OS/2 coordinates
577 nY
= GetOS2ParentHeight(pParent
) - nY
- nHeight
;
579 if (!::WinSetWindowPos( m_hFrame
585 ,SWP_SIZE
| SWP_MOVE
| SWP_ACTIVATE
| SWP_ZORDER
588 vError
= ::WinGetLastError(vHabmain
);
589 sError
= wxPMErrorToStr(vError
);
590 wxLogError(_T("Error sizing frame. Error: %s\n"), sError
.c_str());
593 lStyle
= ::WinQueryWindowULong( m_hWnd
596 lStyle
|= WS_CLIPCHILDREN
;
597 ::WinSetWindowULong( m_hWnd
602 } // end of wxTopLevelWindowOS2::CreateFrame
604 bool wxTopLevelWindowOS2::Create(
607 , const wxString
& rsTitle
608 , const wxPoint
& rPos
609 , const wxSize
& rSizeOrig
611 , const wxString
& rsName
618 m_windowStyle
= lStyle
;
620 m_windowId
= vId
== -1 ? NewControlId() : vId
;
622 // always create a frame of some reasonable, even if arbitrary, size (at
623 // least for MSW compatibility)
624 wxSize rSize
= rSizeOrig
;
625 if ( rSize
.x
== -1 || rSize
.y
== -1 )
627 wxSize sizeDpy
= wxGetDisplaySize();
629 rSize
.x
= sizeDpy
.x
/ 3;
631 rSize
.y
= sizeDpy
.y
/ 5;
634 wxTopLevelWindows
.Append(this);
636 pParent
->AddChild(this);
638 if (GetExtraStyle() & wxTOPLEVEL_EX_DIALOG
)
641 // We have different dialog templates to allow creation of dialogs
642 // with & without captions under OS2indows, resizeable or not (but a
643 // resizeable dialog always has caption - otherwise it would look too
648 if (lStyle
& wxRESIZE_BORDER
)
649 ulDlgTemplate
= (ULONG
)kResizeableDialog
;
650 else if (lStyle
& wxCAPTION
)
651 ulDlgTemplate
= (ULONG
)kCaptionDialog
;
653 ulDlgTemplate
= (ULONG
)kNoCaptionDialog
;
654 return CreateDialog( ulDlgTemplate
662 return CreateFrame( rsTitle
667 } // end of wxTopLevelWindowOS2::Create
669 wxTopLevelWindowOS2::~wxTopLevelWindowOS2()
672 // After destroying an owned window, Windows activates the next top level
673 // window in Z order but it may be different from our owner (to reproduce
674 // this simply Alt-TAB to another application and back before closing the
675 // owned frame) whereas we always want to yield activation to our parent
677 if (HasFlag(wxFRAME_FLOAT_ON_PARENT
))
679 wxWindow
* pParent
= GetParent();
683 ::WinSetWindowPos( GetHwndOf(pParent
)
690 } // end of wxTopLevelWindowOS2::~wxTopLevelWindowOS2
692 // ----------------------------------------------------------------------------
693 // wxTopLevelWindowOS2 client size
694 // ----------------------------------------------------------------------------
696 void wxTopLevelWindowOS2::DoSetClientSize(
702 // Call GetClientAreaOrigin() to take the toolbar into account
704 wxPoint vPt
= GetClientAreaOrigin();
709 wxWindow::DoSetClientSize( nWidth
712 } // end of wxTopLevelWindowOS2::DoSetClientSize
714 void wxTopLevelWindowOS2::DoGetClientSize(
719 wxWindow::DoGetClientSize( pnX
723 wxPoint vPt
= GetClientAreaOrigin();
730 } // end of wxTopLevelWindowOS2::DoGetClientSize
732 // ----------------------------------------------------------------------------
733 // wxTopLevelWindowOS2 showing
734 // ----------------------------------------------------------------------------
736 void wxTopLevelWindowOS2::DoShowWindow(
740 ::WinShowWindow(m_hFrame
, (BOOL
)(nShowCmd
& SWP_SHOW
));
743 // Need to artificially send a size event as wxApps often expect to do some
744 // final child control sizing
746 m_bIconized
= nShowCmd
== SWP_MINIMIZE
;
747 } // end of wxTopLevelWindowOS2::DoShowWindow
749 bool wxTopLevelWindowOS2::Show( bool bShow
)
754 if (bShow
!= IsShown() )
764 if (m_bMaximizeOnShow
)
766 nShowCmd
= SWP_MAXIMIZE
;
767 m_bMaximizeOnShow
= false;
778 DoShowWindow(nShowCmd
);
782 wxActivateEvent
vEvent(wxEVT_ACTIVATE
, true, m_windowId
);
784 ::WinQueryWindowPos(m_hFrame
, &vSwp
);
785 m_bIconized
= ( vSwp
.fl
& SWP_MINIMIZE
) == SWP_MINIMIZE
;
786 ::WinQueryWindowPos(m_hWnd
, &m_vSwpClient
);
787 ::WinSendMsg(m_hFrame
, WM_UPDATEFRAME
, (MPARAM
)~0, 0);
788 ::WinQueryWindowPos(m_hWnd
, &vSwp
);
789 ::WinEnableWindow(m_hFrame
, TRUE
);
791 vEvent
.SetEventObject(this);
792 GetEventHandler()->ProcessEvent(vEvent
);
797 // Try to highlight the correct window (the parent)
801 HWND hWndParent
= GetHwndOf(GetParent());
803 ::WinQueryWindowPos(hWndParent
, &vSwp
);
804 m_bIconized
= (vSwp
.fl
& SWP_MINIMIZE
)==SWP_MINIMIZE
;
805 ::WinEnableWindow(hWndParent
, TRUE
);
809 } // end of wxTopLevelWindowOS2::Show
811 // ----------------------------------------------------------------------------
812 // wxTopLevelWindowOS2 maximize/minimize
813 // ----------------------------------------------------------------------------
815 void wxTopLevelWindowOS2::Maximize(
822 // Just maximize it directly
824 DoShowWindow(bMaximize
? SWP_MAXIMIZE
: SWP_RESTORE
);
829 // We can't maximize the hidden frame because it shows it as well, so
830 // just remember that we should do it later in this case
832 m_bMaximizeOnShow
= bMaximize
;
834 } // end of wxTopLevelWindowOS2::Maximize
836 bool wxTopLevelWindowOS2::IsMaximized() const
838 ::WinQueryWindowPos(m_hFrame
, (PSWP
)&m_vSwp
);
839 return (m_vSwp
.fl
& SWP_MAXIMIZE
) == SWP_MAXIMIZE
;
840 } // end of wxTopLevelWindowOS2::IsMaximized
842 void wxTopLevelWindowOS2::SetTitle( const wxString
& title
)
847 wxString
wxTopLevelWindowOS2::GetTitle() const
852 void wxTopLevelWindowOS2::Iconize( bool bIconize
)
854 DoShowWindow(bIconize
? SWP_MINIMIZE
: SWP_RESTORE
);
855 } // end of wxTopLevelWindowOS2::Iconize
857 bool wxTopLevelWindowOS2::IsIconized() const
859 // also update the current state
860 ::WinQueryWindowPos(m_hFrame
, (PSWP
)&m_vSwp
);
861 if (m_vSwp
.fl
& SWP_MINIMIZE
)
862 ((wxTopLevelWindow
*)this)->m_bIconized
= true;
864 ((wxTopLevelWindow
*)this)->m_bIconized
= false;
866 } // end of wxTopLevelWindowOS2::IsIconized
868 void wxTopLevelWindowOS2::Restore()
870 DoShowWindow(SWP_RESTORE
);
871 } // end of wxTopLevelWindowOS2::Restore
873 // generate an artificial resize event
874 void wxTopLevelWindowOS2::SendSizeEvent()
878 RECTL vRect
= wxGetWindowRect(GetHwnd());
880 (void)::WinPostMsg( m_hFrame
882 ,MPFROM2SHORT(vRect
.xRight
- vRect
.xLeft
, vRect
.yTop
- vRect
.yBottom
)
883 ,MPFROM2SHORT(vRect
.xRight
- vRect
.xLeft
, vRect
.yTop
- vRect
.yBottom
)
886 } // end of wxTopLevelWindowOS2::SendSizeEvent
888 // ----------------------------------------------------------------------------
889 // wxTopLevelWindowOS2 fullscreen
890 // ----------------------------------------------------------------------------
892 bool wxTopLevelWindowOS2::ShowFullScreen( bool bShow
,
900 m_bFsIsShowing
= true;
904 // Zap the frame borders
908 // Save the 'normal' window lStyle
910 m_lFsOldWindowStyle
= ::WinQueryWindowULong( (HWND
)GetHWND()
915 // Save the old position, width & height, maximize state
917 m_vFsOldSize
= GetRect();
918 m_bFsIsMaximized
= IsMaximized();
921 // Decide which window lStyle flags to turn off
923 LONG lNewStyle
= m_lFsOldWindowStyle
;
926 if (lStyle
& wxFULLSCREEN_NOBORDER
)
927 lOffFlags
|= FCF_BORDER
;
928 if (lStyle
& wxFULLSCREEN_NOCAPTION
)
929 lOffFlags
|= (FCF_TASKLIST
| FCF_SYSMENU
);
931 lNewStyle
&= (~lOffFlags
);
934 // Change our window style to be compatible with full-screen mode
936 ::WinSetWindowULong( (HWND
)GetHWND()
942 // Resize to the size of the desktop
946 RECTL vRect
= wxGetWindowRect(HWND_DESKTOP
);
948 nWidth
= vRect
.xRight
- vRect
.xLeft
;
949 nHeight
= vRect
.yTop
- vRect
.yBottom
;
951 SetSize( nWidth
, nHeight
);
954 // Now flush the window style cache and actually go full-screen
956 ::WinSetWindowPos( m_hFrame
965 wxSize
full( nWidth
, nHeight
);
966 wxSizeEvent
vEvent( full
, GetId() );
967 GetEventHandler()->ProcessEvent(vEvent
);
975 m_bFsIsShowing
= false;
976 Maximize(m_bFsIsMaximized
);
977 ::WinSetWindowULong( (HWND
)GetHWND()
981 ::WinSetWindowPos( m_hFrame
991 } // end of wxTopLevelWindowOS2::ShowFullScreen
993 // ----------------------------------------------------------------------------
994 // wxTopLevelWindowOS2 misc
995 // ----------------------------------------------------------------------------
997 void wxTopLevelWindowOS2::SetIcon(
1001 SetIcons(wxIconBundle(rIcon
));
1002 } // end of wxTopLevelWindowOS2::SetIcon
1004 void wxTopLevelWindowOS2::SetIcons(
1005 const wxIconBundle
& rIcons
1011 wxTopLevelWindowBase::SetIcons(rIcons
);
1013 const wxIcon
& vIcon
= rIcons
.GetIcon(wxSize(32, 32));
1015 if (vIcon
.Ok() && vIcon
.GetWidth() == 32 && vIcon
.GetHeight() == 32)
1017 ::WinSendMsg( m_hFrame
1019 ,(MPARAM
)((HPOINTER
)vIcon
.GetHICON())
1022 ::WinSendMsg( m_hFrame
1028 } // end of wxTopLevelWindowOS2::SetIcon
1030 bool wxTopLevelWindowOS2::EnableCloseButton( bool bEnable
)
1033 // Get system (a.k.a. window) menu
1035 HMENU hMenu
= ::WinWindowFromID(m_hFrame
, FID_SYSMENU
);
1039 wxLogLastError(_T("GetSystemMenu"));
1044 // Enabling/disabling the close item from it also automatically
1045 // disables/enables the close title bar button
1048 (void)::WinSendMsg( hMenu
1050 ,MPFROM2SHORT(SC_CLOSE
, FALSE
)
1051 ,MPFROM2SHORT(MIA_DISABLED
, FALSE
)
1054 (void)::WinSendMsg( hMenu
1056 ,MPFROM2SHORT(SC_CLOSE
, FALSE
)
1057 ,MPFROM2SHORT(MIA_DISABLED
, MIA_DISABLED
)
1061 // Update appearance immediately
1063 ::WinSendMsg( m_hFrame
1069 } // end of wxTopLevelWindowOS2::EnableCloseButton
1071 // ============================================================================
1072 // wxTLWHiddenParentModule implementation
1073 // ============================================================================
1075 HWND
wxTLWHiddenParentModule::m_shWnd
= NULL
;
1076 const wxChar
* wxTLWHiddenParentModule::m_szClassName
= NULL
;
1078 bool wxTLWHiddenParentModule::OnInit()
1081 m_szClassName
= NULL
;
1083 } // end of wxTLWHiddenParentModule::OnInit
1085 void wxTLWHiddenParentModule::OnExit()
1089 if (!::WinDestroyWindow(m_shWnd
))
1091 wxLogLastError(_T("DestroyWindow(hidden TLW parent)"));
1096 m_szClassName
= NULL
;
1097 } // end of wxTLWHiddenParentModule::OnExit
1100 HWND
wxTLWHiddenParentModule::GetHWND()
1106 static const wxChar
* zHIDDEN_PARENT_CLASS
= _T("wxTLWHiddenParent");
1108 if (!::WinRegisterClass( wxGetInstance()
1109 ,(PSZ
)zHIDDEN_PARENT_CLASS
1115 wxLogLastError(_T("RegisterClass(\"wxTLWHiddenParent\")"));
1119 m_szClassName
= zHIDDEN_PARENT_CLASS
;
1122 m_shWnd
= ::WinCreateWindow( HWND_DESKTOP
,
1137 wxLogLastError(_T("CreateWindow(hidden TLW parent)"));
1141 } // end of wxTLWHiddenParentModule::GetHWND