1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: src/os2/toplevel.cpp
3 // Purpose: implements wxTopLevelWindow for OS/2
4 // Author: Vadim Zeitlin
7 // Copyright: (c) 2001 SciTech Software, Inc. (www.scitechsoft.com)
8 // Licence: wxWindows licence
9 ///////////////////////////////////////////////////////////////////////////////
11 // ============================================================================
13 // ============================================================================
15 // ----------------------------------------------------------------------------
17 // ----------------------------------------------------------------------------
19 // For compilers that support precompilation, includes "wx.h".
20 #include "wx/wxprec.h"
26 #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"
38 #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
= 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(wxT("focus"), wxT("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(wxT("focus"),
203 wxT("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
& wxRESIZE_BORDER
)
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
)
249 lMsflags
|= FCF_TASKLIST
;
251 if ((lStyle
& wxRESIZE_BORDER
) == 0)
252 lMsflags
|= FCF_BORDER
;
253 if (lStyle
& wxFRAME_TOOL_WINDOW
)
254 *pdwExflags
= kFrameToolWindow
;
256 if (lStyle
& wxSTAY_ON_TOP
)
257 lMsflags
|= FCF_SYSMODAL
;
260 } // end of wxTopLevelWindowOS2::OS2GetCreateWindowFlags
262 WXHWND
wxTopLevelWindowOS2::OS2GetParent() const
264 HWND hWndParent
= NULL
;
267 // For the frames without wxFRAME_FLOAT_ON_PARENT style we should use NULL
268 // parent HWND or it would be always on top of its parent which is not what
269 // we usually want (in fact, we only want it for frames with the
270 // wxFRAME_FLOAT_ON_PARENT flag)
272 if (HasFlag(wxFRAME_FLOAT_ON_PARENT
) )
274 const wxWindow
* pParent
= GetParent();
279 // This flag doesn't make sense then and will be ignored
281 wxFAIL_MSG( wxT("wxFRAME_FLOAT_ON_PARENT but no parent?") );
285 hWndParent
= GetHwndOf(pParent
);
288 //else: don't float on parent, must not be owned
291 // Now deal with the 2nd taskbar-related problem (see comments above in
294 if (HasFlag(wxFRAME_NO_TASKBAR
) && !hWndParent
)
299 hWndParent
= wxTLWHiddenParentModule::GetHWND();
301 return (WXHWND
)hWndParent
;
302 } // end of wxTopLevelWindowOS2::OS2GetParent
305 bool wxTopLevelWindowOS2::CreateDialog( ULONG ulDlgTemplate
,
306 const wxString
& WXUNUSED(rsTitle
),
308 const wxSize
& rSize
)
310 wxWindow
* pParent
= GetParent();
313 // For the dialogs without wxDIALOG_NO_PARENT style, use the top level
314 // app window as parent - this avoids creating modal dialogs without
317 if (!pParent
&& !(GetWindowStyleFlag() & wxDIALOG_NO_PARENT
))
319 pParent
= wxTheApp
->GetTopWindow();
324 // Don't use transient windows as parents, this is dangerous as it
325 // can lead to a crash if the parent is destroyed before the child
327 // also don't use the window which is currently hidden as then the
328 // dialog would be hidden as well
329 if ((pParent
->GetExtraStyle() & wxWS_EX_TRANSIENT
) ||
341 hWndOwner
= GetHwndOf(pParent
);
343 hWndOwner
= HWND_DESKTOP
;
345 hWndDlg
= ::WinLoadDlg( HWND_DESKTOP
349 ,(ULONG
)ulDlgTemplate
353 m_hWnd
= (WXHWND
) hWndDlg
;
357 wxFAIL_MSG(wxT("Did you forget to include wx/os2/wx.rc in your resources?"));
359 wxLogSysError(wxT("Can't create dialog using template '%ld'"), ulDlgTemplate
);
365 // Move the dialog to its initial position without forcing repainting
372 if (!OS2GetCreateWindowCoords( rPos
380 nX
= nWidth
= (int)CW_USEDEFAULT
;
384 // We can't use CW_USEDEFAULT here as we're not calling CreateWindow()
385 // and passing CW_USEDEFAULT to MoveWindow() results in resizing the
386 // window to (0, 0) size which breaks quite a lot of things, e.g. the
387 // sizer calculation in wxSizer::Fit()
389 if (nWidth
== (int)CW_USEDEFAULT
)
392 // The exact number doesn't matter, the dialog will be resized
393 // again soon anyhow but it should be big enough to allow
394 // calculation relying on "totalSize - clientSize > 0" work, i.e.
395 // at least greater than the title bar height
397 nWidth
= nHeight
= 100;
399 if (nX
== (int)CW_USEDEFAULT
)
402 // Centre it on the screen - what else can we do?
404 wxSize vSizeDpy
= wxGetDisplaySize();
406 nX
= (vSizeDpy
.x
- nWidth
) / 2;
407 nY
= (vSizeDpy
.y
- nHeight
) / 2;
409 SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_APPWORKSPACE
));
411 LONG lColor
= (LONG
)m_backgroundColour
.GetPixel();
413 if (!::WinSetPresParam( m_hWnd
422 // Convert to OS/2 coordinates
423 nY
= GetOS2ParentHeight(pParent
) - nY
- nHeight
;
425 ::WinSetWindowPos( GetHwnd()
431 ,SWP_MOVE
| SWP_SIZE
| SWP_ZORDER
| SWP_SHOW
| SWP_ACTIVATE
433 ::WinQueryWindowPos(GetHwnd(), GetSwp());
437 } // end of wxTopLevelWindowOS2::CreateDialog
439 bool wxTopLevelWindowOS2::CreateFrame( const wxString
& rsTitle
,
441 const wxSize
& rSize
)
444 WXDWORD lFlags
= OS2GetCreateWindowFlags(&lExflags
);
445 long lStyle
= GetWindowStyleFlag();
448 int nWidth
= rSize
.x
;
449 int nHeight
= rSize
.y
;
450 ULONG ulStyleFlags
= 0L;
453 wxWindow
* pParent
= GetParent();
459 hParent
= GetHwndOf(pParent
);
461 hParent
= HWND_DESKTOP
;
463 if ((lStyle
& wxMINIMIZE
) || (lStyle
& wxICONIZE
))
464 ulStyleFlags
|= WS_MINIMIZED
;
465 if (lStyle
& wxMAXIMIZE
)
466 ulStyleFlags
|= WS_MAXIMIZED
;
469 // Clear the visible flag, we always call show
471 ulStyleFlags
&= (unsigned long)~WS_VISIBLE
;
475 // Create the frame window: We break ranks with other ports now
476 // and instead of calling down into the base wxWindow class' OS2Create
477 // we do all our own stuff here. We will set the needed pieces
478 // of wxWindow manually, here.
481 hFrame
= ::WinCreateStdWindow( hParent
482 ,ulStyleFlags
// frame-window style
483 ,(PULONG
)&lFlags
// window style
484 ,wxString(wxFrameClassName
).c_str() // class name
485 ,rsTitle
.c_str() // window title
486 ,0L // default client style
487 ,NULLHANDLE
// resource in executable file
489 ,&hClient
// receives client window handle
493 vError
= ::WinGetLastError(vHabmain
);
494 sError
= wxPMErrorToStr(vError
);
495 wxLogError(wxT("Error creating frame. Error: %s\n"), sError
.c_str());
500 // wxWindow class' m_hWnd set here and needed associations
504 wxAssociateWinWithHandle(m_hWnd
, this);
505 wxAssociateWinWithHandle(m_hFrame
, this);
507 SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_APPWORKSPACE
));
509 LONG lColor
= (LONG
)m_backgroundColour
.GetPixel();
511 if (!::WinSetPresParam( m_hWnd
517 vError
= ::WinGetLastError(vHabmain
);
518 sError
= wxPMErrorToStr(vError
);
519 wxLogError(wxT("Error creating frame. Error: %s\n"), sError
.c_str());
524 // Now need to subclass window. Instead of calling the SubClassWin in wxWindow
525 // we manually subclass here because we don't want to use the main wxWndProc
528 m_fnOldWndProc
= (WXFARPROC
) ::WinSubclassWindow(m_hFrame
, (PFNWP
)wxFrameMainWndProc
);
531 // Now size everything. If adding a menu the client will need to be resized.
534 if (!OS2GetCreateWindowCoords( rPos
542 nX
= nWidth
= (int)CW_USEDEFAULT
;
546 // We can't use CW_USEDEFAULT here as we're not calling CreateWindow()
547 // and passing CW_USEDEFAULT to MoveWindow() results in resizing the
548 // window to (0, 0) size which breaks quite a lot of things, e.g. the
549 // sizer calculation in wxSizer::Fit()
551 if (nWidth
== (int)CW_USEDEFAULT
)
554 // The exact number doesn't matter, the dialog will be resized
555 // again soon anyhow but it should be big enough to allow
556 // calculation relying on "totalSize - clientSize > 0" work, i.e.
557 // at least greater than the title bar height
559 nWidth
= nHeight
= 100;
561 if (nX
== (int)CW_USEDEFAULT
)
564 // Centre it on the screen for now - what else can we do?
565 // TODO: We could try FCF_SHELLPOSITION but it will require moving
566 // things around a bit.
568 wxSize vSizeDpy
= wxGetDisplaySize();
570 nX
= (vSizeDpy
.x
- nWidth
) / 2;
571 nY
= (vSizeDpy
.y
- nHeight
) / 2;
574 // Convert to OS/2 coordinates
575 nY
= GetOS2ParentHeight(pParent
) - nY
- nHeight
;
577 if (!::WinSetWindowPos( m_hFrame
583 ,SWP_SIZE
| SWP_MOVE
| SWP_ACTIVATE
| SWP_ZORDER
586 vError
= ::WinGetLastError(vHabmain
);
587 sError
= wxPMErrorToStr(vError
);
588 wxLogError(wxT("Error sizing frame. Error: %s\n"), sError
.c_str());
591 lStyle
= ::WinQueryWindowULong( m_hWnd
594 lStyle
|= WS_CLIPCHILDREN
;
595 ::WinSetWindowULong( m_hWnd
600 } // end of wxTopLevelWindowOS2::CreateFrame
602 bool wxTopLevelWindowOS2::Create(
605 , const wxString
& rsTitle
606 , const wxPoint
& rPos
607 , const wxSize
& rSizeOrig
609 , const wxString
& rsName
616 m_windowStyle
= lStyle
;
618 m_windowId
= vId
== -1 ? NewControlId() : vId
;
620 // always create a frame of some reasonable, even if arbitrary, size (at
621 // least for MSW compatibility)
622 wxSize rSize
= rSizeOrig
;
623 if ( rSize
.x
== -1 || rSize
.y
== -1 )
625 wxSize sizeDpy
= wxGetDisplaySize();
627 rSize
.x
= sizeDpy
.x
/ 3;
629 rSize
.y
= sizeDpy
.y
/ 5;
632 wxTopLevelWindows
.Append(this);
634 pParent
->AddChild(this);
636 if (GetExtraStyle() & wxTOPLEVEL_EX_DIALOG
)
639 // We have different dialog templates to allow creation of dialogs
640 // with & without captions under OS2indows, resizable or not (but a
641 // resizable dialog always has caption - otherwise it would look too
646 if (lStyle
& wxRESIZE_BORDER
)
647 ulDlgTemplate
= (ULONG
)kResizeableDialog
;
648 else if (lStyle
& wxCAPTION
)
649 ulDlgTemplate
= (ULONG
)kCaptionDialog
;
651 ulDlgTemplate
= (ULONG
)kNoCaptionDialog
;
652 return CreateDialog( ulDlgTemplate
660 return CreateFrame( rsTitle
665 } // end of wxTopLevelWindowOS2::Create
667 wxTopLevelWindowOS2::~wxTopLevelWindowOS2()
670 // After destroying an owned window, Windows activates the next top level
671 // window in Z order but it may be different from our owner (to reproduce
672 // this simply Alt-TAB to another application and back before closing the
673 // owned frame) whereas we always want to yield activation to our parent
675 if (HasFlag(wxFRAME_FLOAT_ON_PARENT
))
677 wxWindow
* pParent
= GetParent();
681 ::WinSetWindowPos( GetHwndOf(pParent
)
688 } // end of wxTopLevelWindowOS2::~wxTopLevelWindowOS2
690 // ----------------------------------------------------------------------------
691 // wxTopLevelWindowOS2 client size
692 // ----------------------------------------------------------------------------
694 void wxTopLevelWindowOS2::DoSetClientSize(
700 // Call GetClientAreaOrigin() to take the toolbar into account
702 wxPoint vPt
= GetClientAreaOrigin();
707 wxWindow::DoSetClientSize( nWidth
710 } // end of wxTopLevelWindowOS2::DoSetClientSize
712 void wxTopLevelWindowOS2::DoGetClientSize(
717 wxWindow::DoGetClientSize( pnX
721 wxPoint vPt
= GetClientAreaOrigin();
728 } // end of wxTopLevelWindowOS2::DoGetClientSize
730 // ----------------------------------------------------------------------------
731 // wxTopLevelWindowOS2 showing
732 // ----------------------------------------------------------------------------
734 void wxTopLevelWindowOS2::DoShowWindow(
738 ::WinShowWindow(m_hFrame
, (BOOL
)(nShowCmd
& SWP_SHOW
));
741 // Need to artificially send a size event as wxApps often expect to do some
742 // final child control sizing
744 m_bIconized
= nShowCmd
== SWP_MINIMIZE
;
745 } // end of wxTopLevelWindowOS2::DoShowWindow
747 bool wxTopLevelWindowOS2::Show( bool bShow
)
752 if (bShow
!= IsShown() )
762 if (m_bMaximizeOnShow
)
764 nShowCmd
= SWP_MAXIMIZE
;
765 m_bMaximizeOnShow
= false;
776 DoShowWindow(nShowCmd
);
780 wxActivateEvent
vEvent(wxEVT_ACTIVATE
, true, m_windowId
);
782 ::WinQueryWindowPos(m_hFrame
, &vSwp
);
783 m_bIconized
= ( vSwp
.fl
& SWP_MINIMIZE
) == SWP_MINIMIZE
;
784 ::WinQueryWindowPos(m_hWnd
, &m_vSwpClient
);
785 ::WinSendMsg(m_hFrame
, WM_UPDATEFRAME
, (MPARAM
)~0, 0);
786 ::WinQueryWindowPos(m_hWnd
, &vSwp
);
787 ::WinEnableWindow(m_hFrame
, TRUE
);
789 vEvent
.SetEventObject(this);
790 HandleWindowEvent(vEvent
);
795 // Try to highlight the correct window (the parent)
799 HWND hWndParent
= GetHwndOf(GetParent());
801 ::WinQueryWindowPos(hWndParent
, &vSwp
);
802 m_bIconized
= (vSwp
.fl
& SWP_MINIMIZE
)==SWP_MINIMIZE
;
803 ::WinEnableWindow(hWndParent
, TRUE
);
807 } // end of wxTopLevelWindowOS2::Show
809 // ----------------------------------------------------------------------------
810 // wxTopLevelWindowOS2 maximize/minimize
811 // ----------------------------------------------------------------------------
813 void wxTopLevelWindowOS2::Maximize(
820 // Just maximize it directly
822 DoShowWindow(bMaximize
? SWP_MAXIMIZE
: SWP_RESTORE
);
827 // We can't maximize the hidden frame because it shows it as well, so
828 // just remember that we should do it later in this case
830 m_bMaximizeOnShow
= bMaximize
;
832 } // end of wxTopLevelWindowOS2::Maximize
834 bool wxTopLevelWindowOS2::IsMaximized() const
836 ::WinQueryWindowPos(m_hFrame
, (PSWP
)&m_vSwp
);
837 return (m_vSwp
.fl
& SWP_MAXIMIZE
) == SWP_MAXIMIZE
;
838 } // end of wxTopLevelWindowOS2::IsMaximized
840 void wxTopLevelWindowOS2::SetTitle( const wxString
& title
)
845 wxString
wxTopLevelWindowOS2::GetTitle() const
850 void wxTopLevelWindowOS2::Iconize( bool bIconize
)
852 DoShowWindow(bIconize
? SWP_MINIMIZE
: SWP_RESTORE
);
853 } // end of wxTopLevelWindowOS2::Iconize
855 bool wxTopLevelWindowOS2::IsIconized() const
857 // also update the current state
858 ::WinQueryWindowPos(m_hFrame
, (PSWP
)&m_vSwp
);
859 if (m_vSwp
.fl
& SWP_MINIMIZE
)
860 ((wxTopLevelWindow
*)this)->m_bIconized
= true;
862 ((wxTopLevelWindow
*)this)->m_bIconized
= false;
864 } // end of wxTopLevelWindowOS2::IsIconized
866 void wxTopLevelWindowOS2::Restore()
868 DoShowWindow(SWP_RESTORE
);
869 } // end of wxTopLevelWindowOS2::Restore
871 // generate an artificial resize event
872 void wxTopLevelWindowOS2::SendSizeEvent(int flags
)
876 RECTL vRect
= wxGetWindowRect(GetHwnd());
878 if ( flags
& wxSEND_EVENT_POST
)
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
)
888 (void)::WinSendMsg( m_hFrame
890 ,MPFROM2SHORT(vRect
.xRight
- vRect
.xLeft
, vRect
.yTop
- vRect
.yBottom
)
891 ,MPFROM2SHORT(vRect
.xRight
- vRect
.xLeft
, vRect
.yTop
- vRect
.yBottom
)
895 } // end of wxTopLevelWindowOS2::SendSizeEvent
897 // ----------------------------------------------------------------------------
898 // wxTopLevelWindowOS2 fullscreen
899 // ----------------------------------------------------------------------------
901 bool wxTopLevelWindowOS2::ShowFullScreen( bool bShow
,
909 m_bFsIsShowing
= true;
913 // Zap the frame borders
917 // Save the 'normal' window lStyle
919 m_lFsOldWindowStyle
= ::WinQueryWindowULong( (HWND
)GetHWND()
924 // Save the old position, width & height, maximize state
926 m_vFsOldSize
= GetRect();
927 m_bFsIsMaximized
= IsMaximized();
930 // Decide which window lStyle flags to turn off
932 LONG lNewStyle
= m_lFsOldWindowStyle
;
935 if (lStyle
& wxFULLSCREEN_NOBORDER
)
936 lOffFlags
|= FCF_BORDER
;
937 if (lStyle
& wxFULLSCREEN_NOCAPTION
)
938 lOffFlags
|= (FCF_TASKLIST
| FCF_SYSMENU
);
940 lNewStyle
&= (~lOffFlags
);
943 // Change our window style to be compatible with full-screen mode
945 ::WinSetWindowULong( (HWND
)GetHWND()
951 // Resize to the size of the desktop
955 RECTL vRect
= wxGetWindowRect(HWND_DESKTOP
);
957 nWidth
= vRect
.xRight
- vRect
.xLeft
;
958 nHeight
= vRect
.yTop
- vRect
.yBottom
;
960 SetSize( nWidth
, nHeight
);
963 // Now flush the window style cache and actually go full-screen
965 ::WinSetWindowPos( m_hFrame
974 wxSize
full( nWidth
, nHeight
);
975 wxSizeEvent
vEvent( full
, GetId() );
976 HandleWindowEvent(vEvent
);
984 m_bFsIsShowing
= false;
985 Maximize(m_bFsIsMaximized
);
986 ::WinSetWindowULong( (HWND
)GetHWND()
990 ::WinSetWindowPos( m_hFrame
1000 } // end of wxTopLevelWindowOS2::ShowFullScreen
1002 // ----------------------------------------------------------------------------
1003 // wxTopLevelWindowOS2 misc
1004 // ----------------------------------------------------------------------------
1006 void wxTopLevelWindowOS2::SetIcons(
1007 const wxIconBundle
& rIcons
1013 wxTopLevelWindowBase::SetIcons(rIcons
);
1015 const wxIcon
& vIcon
= rIcons
.GetIconOfExactSize(32);
1019 ::WinSendMsg( m_hFrame
1021 ,(MPARAM
)((HPOINTER
)vIcon
.GetHICON())
1024 ::WinSendMsg( m_hFrame
1030 } // end of wxTopLevelWindowOS2::SetIcon
1032 bool wxTopLevelWindowOS2::EnableCloseButton( bool bEnable
)
1035 // Get system (a.k.a. window) menu
1037 HMENU hMenu
= ::WinWindowFromID(m_hFrame
, FID_SYSMENU
);
1041 wxLogLastError(wxT("GetSystemMenu"));
1046 // Enabling/disabling the close item from it also automatically
1047 // disables/enables the close title bar button
1050 (void)::WinSendMsg( hMenu
1052 ,MPFROM2SHORT(SC_CLOSE
, FALSE
)
1053 ,MPFROM2SHORT(MIA_DISABLED
, FALSE
)
1056 (void)::WinSendMsg( hMenu
1058 ,MPFROM2SHORT(SC_CLOSE
, FALSE
)
1059 ,MPFROM2SHORT(MIA_DISABLED
, MIA_DISABLED
)
1063 // Update appearance immediately
1065 ::WinSendMsg( m_hFrame
1071 } // end of wxTopLevelWindowOS2::EnableCloseButton
1073 // ============================================================================
1074 // wxTLWHiddenParentModule implementation
1075 // ============================================================================
1077 HWND
wxTLWHiddenParentModule::m_shWnd
= NULL
;
1078 const wxChar
* wxTLWHiddenParentModule::m_szClassName
= NULL
;
1080 bool wxTLWHiddenParentModule::OnInit()
1083 m_szClassName
= NULL
;
1085 } // end of wxTLWHiddenParentModule::OnInit
1087 void wxTLWHiddenParentModule::OnExit()
1091 if (!::WinDestroyWindow(m_shWnd
))
1093 wxLogLastError(wxT("DestroyWindow(hidden TLW parent)"));
1098 m_szClassName
= NULL
;
1099 } // end of wxTLWHiddenParentModule::OnExit
1102 HWND
wxTLWHiddenParentModule::GetHWND()
1108 static const wxChar
* zHIDDEN_PARENT_CLASS
= wxT("wxTLWHiddenParent");
1110 if (!::WinRegisterClass( wxGetInstance()
1111 ,(PSZ
)zHIDDEN_PARENT_CLASS
1117 wxLogLastError(wxT("RegisterClass(\"wxTLWHiddenParent\")"));
1121 m_szClassName
= zHIDDEN_PARENT_CLASS
;
1124 m_shWnd
= ::WinCreateWindow( HWND_DESKTOP
,
1139 wxLogLastError(wxT("CreateWindow(hidden TLW parent)"));
1143 } // end of wxTLWHiddenParentModule::GetHWND