1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: msw/toplevel.cpp
3 // Purpose: implements wxTopLevelWindow for MSW
4 // Author: Vadim Zeitlin
8 // Copyright: (c) 2001 SciTech Software, Inc. (www.scitechsoft.com)
9 // License: wxWindows license
10 ///////////////////////////////////////////////////////////////////////////////
12 // ============================================================================
14 // ============================================================================
16 // ----------------------------------------------------------------------------
18 // ----------------------------------------------------------------------------
21 #pragma implementation "toplevel.h"
24 // For compilers that support precompilation, includes "wx.h".
25 #include "wx/wxprec.h"
33 #include "wx/toplevel.h"
34 #include "wx/string.h"
38 #include "wx/control.h"
39 #include "wx/containr.h" // wxSetFocusToChild()
42 #include "wx/os2/private.h"
44 // ----------------------------------------------------------------------------
45 // stubs for missing functions under MicroWindows
46 // ----------------------------------------------------------------------------
49 // ----------------------------------------------------------------------------
51 // ----------------------------------------------------------------------------
53 // list of all frames and modeless dialogs
54 wxWindowList wxModelessWindows
;
56 // the name of the default wxWindows class
57 extern void wxAssociateWinWithHandle( HWND hWnd
60 bool wxTopLevelWindowOS2::m_sbInitialized
= FALSE
;
61 wxWindow
* wxTopLevelWindowOS2::m_spHiddenParent
= NULL
;
63 // ============================================================================
64 // wxTopLevelWindowOS2 implementation
65 // ============================================================================
67 BEGIN_EVENT_TABLE(wxTopLevelWindowOS2
, wxTopLevelWindowBase
)
68 EVT_ACTIVATE(wxTopLevelWindowOS2::OnActivate
)
71 // ============================================================================
72 // wxTopLevelWindowMSW implementation
73 // ============================================================================
76 MRESULT EXPENTRY
wxDlgProc( HWND
WXUNUSED(hWnd
)
78 ,MPARAM
WXUNUSED(wParam
)
79 ,MPARAM
WXUNUSED(lParam
)
86 // For this message, returning TRUE tells system to set focus to
87 // the first control in the dialog box, but we set the focus
88 // ourselves, however in OS/2 we must return true to enable the dialog
93 // For all the other ones, FALSE means that we didn't process the
96 return (MRESULT
)FALSE
;
100 // ----------------------------------------------------------------------------
101 // wxTLWHiddenParentModule: used to manage the hidden parent window (we need a
102 // module to ensure that the window is always deleted)
103 // ----------------------------------------------------------------------------
105 class wxTLWHiddenParentModule
: public wxModule
109 // Module init/finalize
111 virtual bool OnInit(void);
112 virtual void OnExit(void);
115 // Get the hidden window (creates on demand)
117 static HWND
GetHWND(void);
121 // The HWND of the hidden parent
126 // The class used to create it
128 static const wxChar
* m_szClassName
;
129 DECLARE_DYNAMIC_CLASS(wxTLWHiddenParentModule
)
130 }; // end of CLASS wxTLWHiddenParentModule
132 IMPLEMENT_DYNAMIC_CLASS(wxTLWHiddenParentModule
, wxModule
)
134 // ----------------------------------------------------------------------------
135 // wxTopLevelWindowOS2 creation
136 // ----------------------------------------------------------------------------
138 void wxTopLevelWindowOS2::Init()
140 m_bIconized
= m_bMaximizeOnShow
= FALSE
;
143 // Unlike (almost?) all other windows, frames are created hidden
148 // Data to save/restore when calling ShowFullScreen
150 m_lFsOldWindowStyle
= 0;
151 m_bFsIsMaximized
= FALSE
;
152 m_bFsIsShowing
= FALSE
;
154 m_hFrame
= NULLHANDLE
;
155 memset(&m_vSwp
, 0, sizeof(SWP
));
156 memset(&m_vSwpClient
, 0, sizeof(SWP
));
157 m_pWinLastFocused
= (wxWindow
*)NULL
;
158 } // end of wxTopLevelWindowIOS2::Init
160 void wxTopLevelWindowOS2::OnActivate(
161 wxActivateEvent
& rEvent
164 if (rEvent
.GetActive())
167 // Restore focus to the child which was last focused
169 wxLogTrace(_T("focus"), _T("wxTLW %08x activated."), m_hWnd
);
171 wxWindow
* pParent
= m_pWinLastFocused
? m_pWinLastFocused
->GetParent()
178 wxSetFocusToChild( pParent
185 // Remember the last focused child if it is our child
187 m_pWinLastFocused
= FindFocus();
190 // So we NULL it out if it's a child from some other frame
192 wxWindow
* pWin
= m_pWinLastFocused
;
196 if (pWin
->IsTopLevel())
200 m_pWinLastFocused
= NULL
;
204 pWin
= pWin
->GetParent();
207 wxLogTrace(_T("focus"),
208 _T("wxTLW %08x deactivated, last focused: %08x."),
210 m_pWinLastFocused
? GetHwndOf(m_pWinLastFocused
)
214 } // end of wxTopLevelWindowOS2::OnActivate
216 WXDWORD
wxTopLevelWindowOS2::OS2GetStyle(
218 , WXDWORD
* pdwExflags
221 long lMsflags
= wxWindow::OS2GetStyle( (lStyle
& ~wxBORDER_MASK
) | wxBORDER_NONE
225 if (lStyle
== wxDEFAULT_FRAME_STYLE
)
226 lMsflags
|= FCF_SIZEBORDER
| FCF_TITLEBAR
| FCF_SYSMENU
|
227 FCF_MINMAX
| FCF_TASKLIST
;
230 if ((lStyle
& wxCAPTION
) == wxCAPTION
)
231 lMsflags
|= FCF_TASKLIST
;
233 lMsflags
|= FCF_NOMOVEWITHOWNER
;
235 if ((lStyle
& wxVSCROLL
) == wxVSCROLL
)
236 lMsflags
|= FCF_VERTSCROLL
;
237 if ((lStyle
& wxHSCROLL
) == wxHSCROLL
)
238 lMsflags
|= FCF_HORZSCROLL
;
239 if (lStyle
& wxMINIMIZE_BOX
)
240 lMsflags
|= FCF_MINBUTTON
;
241 if (lStyle
& wxMAXIMIZE_BOX
)
242 lMsflags
|= FCF_MAXBUTTON
;
243 if (lStyle
& wxTHICK_FRAME
)
244 lMsflags
|= FCF_DLGBORDER
;
245 if (lStyle
& wxSYSTEM_MENU
)
246 lMsflags
|= FCF_SYSMENU
;
247 if (lStyle
& wxCAPTION
)
248 lMsflags
|= FCF_TASKLIST
;
249 if (lStyle
& wxCLIP_CHILDREN
)
251 // Invalid for frame windows under PM
254 if (lStyle
& wxTINY_CAPTION_VERT
)
255 lMsflags
|= FCF_TASKLIST
;
256 if (lStyle
& wxTINY_CAPTION_HORIZ
)
257 lMsflags
|= FCF_TASKLIST
;
259 if ((lStyle
& wxTHICK_FRAME
) == 0)
260 lMsflags
|= FCF_BORDER
;
261 if (lStyle
& wxFRAME_TOOL_WINDOW
)
262 *pdwExflags
= kFrameToolWindow
;
264 if (lStyle
& wxSTAY_ON_TOP
)
265 lMsflags
|= FCF_SYSMODAL
;
268 } // end of wxTopLevelWindowOS2::OS2GetCreateWindowFlags
270 WXHWND
wxTopLevelWindowOS2::OS2GetParent() const
272 HWND hWndParent
= NULL
;
275 // For the frames without wxFRAME_FLOAT_ON_PARENT style we should use NULL
276 // parent HWND or it would be always on top of its parent which is not what
277 // we usually want (in fact, we only want it for frames with the
278 // wxFRAME_FLOAT_ON_PARENT flag)
280 if (HasFlag(wxFRAME_FLOAT_ON_PARENT
) )
282 const wxWindow
* pParent
= GetParent();
287 // This flag doesn't make sense then and will be ignored
289 wxFAIL_MSG( _T("wxFRAME_FLOAT_ON_PARENT but no parent?") );
293 hWndParent
= GetHwndOf(pParent
);
296 //else: don't float on parent, must not be owned
299 // Now deal with the 2nd taskbar-related problem (see comments above in
302 if (HasFlag(wxFRAME_NO_TASKBAR
) && !hWndParent
)
307 hWndParent
= wxTLWHiddenParentModule::GetHWND();
309 return (WXHWND
)hWndParent
;
310 } // end of wxTopLevelWindowOS2::OS2GetParent
312 bool wxTopLevelWindowOS2::CreateDialog(
314 , const wxString
& rsTitle
315 , const wxPoint
& rPos
316 , const wxSize
& rSize
319 wxWindow
* pParent
= GetParent();
322 // For the dialogs without wxDIALOG_NO_PARENT style, use the top level
323 // app window as parent - this avoids creating modal dialogs without
326 if (!pParent
&& !(GetWindowStyleFlag() & wxDIALOG_NO_PARENT
))
328 pParent
= wxTheApp
->GetTopWindow();
333 // Don't use transient windows as parents, this is dangerous as it
334 // can lead to a crash if the parent is destroyed before the child
336 // also don't use the window which is currently hidden as then the
337 // dialog would be hidden as well
338 if ((pParent
->GetExtraStyle() & wxWS_EX_TRANSIENT
) ||
350 hWndOwner
= GetHwndOf(pParent
);
352 hWndOwner
= HWND_DESKTOP
;
354 hWndDlg
= ::WinLoadDlg( HWND_DESKTOP
358 ,(ULONG
)ulDlgTemplate
362 m_hWnd
= (WXHWND
) hWndDlg
;
366 wxFAIL_MSG(_("Did you forget to include wx/os2/wx.rc in your resources?"));
368 wxLogSysError(_("Can't create dialog using template '%ul'"), ulDlgTemplate
);
374 // Move the dialog to its initial position without forcing repainting
381 if (!OS2GetCreateWindowCoords( rPos
389 nX
= nWidth
= (int)CW_USEDEFAULT
;
393 // We can't use CW_USEDEFAULT here as we're not calling CreateWindow()
394 // and passing CW_USEDEFAULT to MoveWindow() results in resizing the
395 // window to (0, 0) size which breaks quite a lot of things, e.g. the
396 // sizer calculation in wxSizer::Fit()
398 if (nWidth
== (int)CW_USEDEFAULT
)
401 // The exact number doesn't matter, the dialog will be resized
402 // again soon anyhow but it should be big enough to allow
403 // calculation relying on "totalSize - clientSize > 0" work, i.e.
404 // at least greater than the title bar height
406 nWidth
= nHeight
= 100;
408 if (nX
== (int)CW_USEDEFAULT
)
411 // Centre it on the screen - what else can we do?
413 wxSize vSizeDpy
= wxGetDisplaySize();
415 nX
= (vSizeDpy
.x
- nWidth
) / 2;
416 nY
= (vSizeDpy
.y
- nHeight
) / 2;
418 m_backgroundColour
.Set(wxString("LIGHT GREY"));
420 LONG lColor
= (LONG
)m_backgroundColour
.GetPixel();
422 if (!::WinSetPresParam( m_hWnd
431 ::WinSetWindowPos( GetHwnd()
437 ,SWP_MOVE
| SWP_SIZE
| SWP_ZORDER
| SWP_SHOW
| SWP_ACTIVATE
439 ::WinQueryWindowPos(GetHwnd(), GetSwp());
443 } // end of wxTopLevelWindowOS2::CreateDialog
445 bool wxTopLevelWindowOS2::CreateFrame(
446 const wxString
& rsTitle
447 , const wxPoint
& rPos
448 , const wxSize
& rSize
452 WXDWORD lFlags
= OS2GetCreateWindowFlags(&lExflags
);
453 long lStyle
= GetWindowStyleFlag();
456 int nWidth
= rSize
.x
;
457 int nHeight
= rSize
.y
;
458 ULONG ulStyleFlags
= 0L;
461 wxWindow
* pParent
= GetParent();
467 hParent
= GetHwndOf(pParent
);
469 hParent
= HWND_DESKTOP
;
471 if ((lStyle
& wxMINIMIZE
) || (lStyle
& wxICONIZE
))
472 ulStyleFlags
|= WS_MINIMIZED
;
473 if (lStyle
& wxMAXIMIZE
)
474 ulStyleFlags
|= WS_MAXIMIZED
;
477 // Clear the visible flag, we always call show
479 ulStyleFlags
&= (unsigned long)~WS_VISIBLE
;
483 // Create the frame window: We break ranks with other ports now
484 // and instead of calling down into the base wxWindow class' OS2Create
485 // we do all our own stuff here. We will set the needed pieces
486 // of wxWindow manually, here.
489 hFrame
= ::WinCreateStdWindow( hParent
490 ,ulStyleFlags
// frame-window style
491 ,(PULONG
)&lFlags
// window style
492 ,(PSZ
)wxFrameClassName
// class name
493 ,(PSZ
)rsTitle
.c_str() // window title
494 ,0L // default client style
495 ,NULLHANDLE
// resource in executable file
497 ,&hClient
// receives client window handle
501 vError
= ::WinGetLastError(vHabmain
);
502 sError
= wxPMErrorToStr(vError
);
503 wxLogError("Error creating frame. Error: %s\n", sError
);
508 // wxWindow class' m_hWnd set here and needed associations
512 wxAssociateWinWithHandle(m_hWnd
, this);
513 wxAssociateWinWithHandle(m_hFrame
, this);
515 m_backgroundColour
.Set(wxString("MEDIUM GREY"));
517 LONG lColor
= (LONG
)m_backgroundColour
.GetPixel();
519 if (!::WinSetPresParam( m_hWnd
525 vError
= ::WinGetLastError(vHabmain
);
526 sError
= wxPMErrorToStr(vError
);
527 wxLogError("Error creating frame. Error: %s\n", sError
);
532 // Now need to subclass window. Instead of calling the SubClassWin in wxWindow
533 // we manually subclass here because we don't want to use the main wxWndProc
536 m_fnOldWndProc
= (WXFARPROC
) ::WinSubclassWindow(m_hFrame
, (PFNWP
)wxFrameMainWndProc
);
539 // Now size everything. If adding a menu the client will need to be resized.
544 nY
= pParent
->GetSize().y
- (nY
+ nHeight
);
550 ::WinQueryWindowRect(HWND_DESKTOP
, &vRect
);
551 nY
= vRect
.yTop
- (nY
+ nHeight
);
553 if (!::WinSetWindowPos( m_hFrame
559 ,SWP_SIZE
| SWP_MOVE
| SWP_ACTIVATE
| SWP_ZORDER
562 vError
= ::WinGetLastError(vHabmain
);
563 sError
= wxPMErrorToStr(vError
);
564 wxLogError("Error sizing frame. Error: %s\n", sError
);
567 lStyle
= ::WinQueryWindowULong( m_hWnd
570 lStyle
|= WS_CLIPCHILDREN
;
571 ::WinSetWindowULong( m_hWnd
576 } // end of wxTopLevelWindowOS2::CreateFrame
578 bool wxTopLevelWindowOS2::Create(
581 , const wxString
& rsTitle
582 , const wxPoint
& rPos
583 , const wxSize
& rSize
585 , const wxString
& rsName
592 m_windowStyle
= lStyle
;
594 m_windowId
= vId
== -1 ? NewControlId() : vId
;
595 wxTopLevelWindows
.Append(this);
597 pParent
->AddChild(this);
599 if (GetExtraStyle() & wxTOPLEVEL_EX_DIALOG
)
602 // We have different dialog templates to allows creation of dialogs
603 // with & without captions under OS2indows, resizeable or not (but a
604 // resizeable dialog always has caption - otherwise it would look too
609 if (lStyle
& wxRESIZE_BORDER
)
610 ulDlgTemplate
= (ULONG
)kResizeableDialog
;
611 else if (lStyle
& wxCAPTION
)
612 ulDlgTemplate
= (ULONG
)kCaptionDialog
;
614 ulDlgTemplate
= (ULONG
)kNoCaptionDialog
;
615 return CreateDialog( ulDlgTemplate
623 return CreateFrame( rsTitle
628 } // end of wxTopLevelWindowOS2::Create
630 wxTopLevelWindowOS2::~wxTopLevelWindowOS2()
632 if (wxModelessWindows
.Find(this))
633 wxModelessWindows
.DeleteObject(this);
636 // After destroying an owned window, Windows activates the next top level
637 // window in Z order but it may be different from our owner (to reproduce
638 // this simply Alt-TAB to another application and back before closing the
639 // owned frame) whereas we always want to yield activation to our parent
641 if (HasFlag(wxFRAME_FLOAT_ON_PARENT
))
643 wxWindow
* pParent
= GetParent();
647 ::WinSetWindowPos( GetHwndOf(pParent
)
654 } // end of wxTopLevelWindowOS2::~wxTopLevelWindowOS2
656 // ----------------------------------------------------------------------------
657 // wxTopLevelWindowOS2 client size
658 // ----------------------------------------------------------------------------
660 void wxTopLevelWindowOS2::DoSetClientSize(
666 // Call GetClientAreaOrigin() to take the toolbar into account
668 wxPoint vPt
= GetClientAreaOrigin();
673 wxWindow::DoSetClientSize( nWidth
676 } // end of wxTopLevelWindowOS2::DoSetClientSize
678 void wxTopLevelWindowOS2::DoGetClientSize(
683 wxWindow::DoGetClientSize( pnX
687 wxPoint vPt
= GetClientAreaOrigin();
694 } // end of wxTopLevelWindowOS2::DoGetClientSize
696 // ----------------------------------------------------------------------------
697 // wxTopLevelWindowOS2 showing
698 // ----------------------------------------------------------------------------
700 void wxTopLevelWindowOS2::DoShowWindow(
704 ::WinShowWindow(m_hFrame
, (BOOL
)(nShowCmd
& SWP_SHOW
));
707 // Need to artificially send a size event as wxApps often expect to do some
708 // final child control sizing
710 m_bIconized
= nShowCmd
== SWP_MINIMIZE
;
711 } // end of wxTopLevelWindowOS2::DoShowWindow
713 bool wxTopLevelWindowOS2::Show(
721 if (bShow
!= IsShown() )
731 if (m_bMaximizeOnShow
)
733 nShowCmd
= SWP_MAXIMIZE
;
734 m_bMaximizeOnShow
= FALSE
;
745 DoShowWindow(nShowCmd
);
749 wxActivateEvent
vEvent(wxEVT_ACTIVATE
, TRUE
, m_windowId
);
751 ::WinQueryWindowPos(m_hFrame
, &vSwp
);
752 m_bIconized
= vSwp
.fl
& SWP_MINIMIZE
;
753 ::WinQueryWindowPos(m_hWnd
, &m_vSwpClient
);
754 ::WinSendMsg(m_hFrame
, WM_UPDATEFRAME
, (MPARAM
)~0, 0);
755 ::WinQueryWindowPos(m_hWnd
, &vSwp
);
756 ::WinEnableWindow(m_hFrame
, TRUE
);
759 // Deal with children
761 MoveChildren(m_vSwpClient
.cy
- vSwp
.cy
);
762 vEvent
.SetEventObject(this);
763 GetEventHandler()->ProcessEvent(vEvent
);
768 // Try to highlight the correct window (the parent)
772 HWND hWndParent
= GetHwndOf(GetParent());
774 ::WinQueryWindowPos(hWndParent
, &vSwp
);
775 m_bIconized
= vSwp
.fl
& SWP_MINIMIZE
;
776 ::WinEnableWindow(hWndParent
, TRUE
);
780 } // end of wxTopLevelWindowOS2::Show
782 // ----------------------------------------------------------------------------
783 // wxTopLevelWindowOS2 maximize/minimize
784 // ----------------------------------------------------------------------------
786 void wxTopLevelWindowOS2::Maximize(
793 // Just maximize it directly
795 DoShowWindow(bMaximize
? SWP_MAXIMIZE
: SWP_RESTORE
);
800 // We can't maximize the hidden frame because it shows it as well, so
801 // just remember that we should do it later in this case
803 m_bMaximizeOnShow
= TRUE
;
805 } // end of wxTopLevelWindowOS2::Maximize
807 bool wxTopLevelWindowOS2::IsMaximized() const
811 ::WinQueryWindowPos(m_hFrame
, (PSWP
)&m_vSwp
);
812 return (m_vSwp
.fl
& SWP_MAXIMIZE
);
813 } // end of wxTopLevelWindowOS2::IsMaximized
815 void wxTopLevelWindowOS2::Iconize(
819 DoShowWindow(bIconize
? SWP_MINIMIZE
: SWP_RESTORE
);
820 } // end of wxTopLevelWindowOS2::Iconize
822 bool wxTopLevelWindowOS2::IsIconized() const
824 // also update the current state
825 ::WinQueryWindowPos(m_hFrame
, (PSWP
)&m_vSwp
);
826 if (m_vSwp
.fl
& SWP_MINIMIZE
)
827 ((wxTopLevelWindow
*)this)->m_bIconized
= TRUE
;
829 ((wxTopLevelWindow
*)this)->m_bIconized
= FALSE
;
831 } // end of wxTopLevelWindowOS2::IsIconized
833 void wxTopLevelWindowOS2::Restore()
835 DoShowWindow(SWP_RESTORE
);
836 } // end of wxTopLevelWindowOS2::Restore
838 // generate an artificial resize event
839 void wxTopLevelWindowOS2::SendSizeEvent()
843 RECTL vRect
= wxGetWindowRect(GetHwnd());
845 (void)::WinPostMsg( m_hFrame
847 ,MPFROM2SHORT(vRect
.xRight
- vRect
.xLeft
, vRect
.yTop
- vRect
.yBottom
)
848 ,MPFROM2SHORT(vRect
.xRight
- vRect
.xLeft
, vRect
.yTop
- vRect
.yBottom
)
851 } // end of wxTopLevelWindowOS2::SendSizeEvent
853 // ----------------------------------------------------------------------------
854 // wxTopLevelWindowOS2 fullscreen
855 // ----------------------------------------------------------------------------
857 bool wxTopLevelWindowOS2::ShowFullScreen(
867 m_bFsIsShowing
= TRUE
;
871 // Zap the frame borders
875 // Save the 'normal' window lStyle
877 m_lFsOldWindowStyle
= ::WinQueryWindowULong( (HWND
)GetHWND()
882 // Save the old position, width & height, maximize state
884 m_vFsOldSize
= GetRect();
885 m_bFsIsMaximized
= IsMaximized();
888 // Decide which window lStyle flags to turn off
890 LONG lNewStyle
= m_lFsOldWindowStyle
;
893 if (lStyle
& wxFULLSCREEN_NOBORDER
)
894 lOffFlags
|= FCF_BORDER
;
895 if (lStyle
& wxFULLSCREEN_NOCAPTION
)
896 lOffFlags
|= (FCF_TASKLIST
| FCF_SYSMENU
);
898 lNewStyle
&= (~lOffFlags
);
901 // Change our window style to be compatible with full-screen mode
903 ::WinSetWindowULong( (HWND
)GetHWND()
909 // Resize to the size of the desktop
913 RECTL vRect
= wxGetWindowRect(HWND_DESKTOP
);
915 nWidth
= vRect
.xRight
- vRect
.xLeft
;
916 nHeight
= vRect
.yTop
- vRect
.yBottom
;
923 // Now flush the window style cache and actually go full-screen
925 ::WinSetWindowPos( m_hFrame
934 wxSizeEvent
vEvent( wxSize( nWidth
940 GetEventHandler()->ProcessEvent(vEvent
);
948 m_bFsIsShowing
= FALSE
;
949 Maximize(m_bFsIsMaximized
);
950 ::WinSetWindowULong( (HWND
)GetHWND()
954 ::WinSetWindowPos( m_hFrame
964 } // end of wxTopLevelWindowOS2::ShowFullScreen
966 // ----------------------------------------------------------------------------
967 // wxTopLevelWindowOS2 misc
968 // ----------------------------------------------------------------------------
970 void wxTopLevelWindowOS2::SetIcon(
974 SetIcons(wxIconBundle(rIcon
));
975 } // end of wxTopLevelWindowOS2::SetIcon
977 void wxTopLevelWindowOS2::SetIcons(
978 const wxIconBundle
& rIcons
984 wxTopLevelWindowBase::SetIcons(rIcons
);
986 const wxIcon
& vIcon
= rIcons
.GetIcon(wxSize(32, 32));
988 if (vIcon
.Ok() && vIcon
.GetWidth() == 32 && vIcon
.GetHeight() == 32)
990 ::WinSendMsg( m_hFrame
992 ,(MPARAM
)((HPOINTER
)vIcon
.GetHICON())
995 ::WinSendMsg( m_hFrame
1001 } // end of wxTopLevelWindowOS2::SetIcon
1003 bool wxTopLevelWindowOS2::EnableCloseButton(
1008 // Get system (a.k.a. window) menu
1010 HMENU hMenu
= ::WinWindowFromID(m_hFrame
, FID_SYSMENU
);
1014 wxLogLastError(_T("GetSystemMenu"));
1019 // Enabling/disabling the close item from it also automatically
1020 // disables/enables the close title bar button
1023 (void)::WinSendMsg( hMenu
1025 ,MPFROM2SHORT(SC_CLOSE
, FALSE
)
1026 ,MPFROM2SHORT(MIA_DISABLED
, FALSE
)
1029 (void)::WinSendMsg( hMenu
1031 ,MPFROM2SHORT(SC_CLOSE
, FALSE
)
1032 ,MPFROM2SHORT(MIA_DISABLED
, MIA_DISABLED
)
1036 // Update appearance immediately
1038 ::WinSendMsg( m_hFrame
1044 } // end of wxTopLevelWindowOS2::EnableCloseButton
1046 // ============================================================================
1047 // wxTLWHiddenParentModule implementation
1048 // ============================================================================
1050 HWND
wxTLWHiddenParentModule::m_shWnd
= NULL
;
1051 const wxChar
* wxTLWHiddenParentModule::m_szClassName
= NULL
;
1053 bool wxTLWHiddenParentModule::OnInit()
1056 m_szClassName
= NULL
;
1058 } // end of wxTLWHiddenParentModule::OnInit
1060 void wxTLWHiddenParentModule::OnExit()
1064 if (!::WinDestroyWindow(m_shWnd
))
1066 wxLogLastError(_T("DestroyWindow(hidden TLW parent)"));
1071 m_szClassName
= NULL
;
1072 } // end of wxTLWHiddenParentModule::OnExit
1075 HWND
wxTLWHiddenParentModule::GetHWND()
1081 static const wxChar
* zHIDDEN_PARENT_CLASS
= _T("wxTLWHiddenParent");
1083 if (!::WinRegisterClass( wxGetInstance()
1084 ,zHIDDEN_PARENT_CLASS
1090 wxLogLastError(_T("RegisterClass(\"wxTLWHiddenParent\")"));
1094 m_szClassName
= zHIDDEN_PARENT_CLASS
;
1097 m_shWnd
= ::WinCreateWindow( HWND_DESKTOP
1113 wxLogLastError(_T("CreateWindow(hidden TLW parent)"));
1117 } // end of wxTLWHiddenParentModule::GetHWND