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 licence
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()
40 #include "wx/module.h" // wxSetFocusToChild()
43 #include "wx/os2/private.h"
45 // ----------------------------------------------------------------------------
46 // stubs for missing functions under MicroWindows
47 // ----------------------------------------------------------------------------
50 // ----------------------------------------------------------------------------
52 // ----------------------------------------------------------------------------
54 // list of all frames and modeless dialogs
55 wxWindowList wxModelessWindows
;
57 // the name of the default wxWindows class
58 extern void wxAssociateWinWithHandle( HWND hWnd
61 bool wxTopLevelWindowOS2::m_sbInitialized
= FALSE
;
62 wxWindow
* wxTopLevelWindowOS2::m_spHiddenParent
= NULL
;
64 // ============================================================================
65 // wxTopLevelWindowOS2 implementation
66 // ============================================================================
68 BEGIN_EVENT_TABLE(wxTopLevelWindowOS2
, wxTopLevelWindowBase
)
69 EVT_ACTIVATE(wxTopLevelWindowOS2::OnActivate
)
72 // ============================================================================
73 // wxTopLevelWindowMSW implementation
74 // ============================================================================
77 MRESULT EXPENTRY
wxDlgProc( HWND
WXUNUSED(hWnd
)
79 ,MPARAM
WXUNUSED(wParam
)
80 ,MPARAM
WXUNUSED(lParam
)
87 // For this message, returning TRUE tells system to set focus to
88 // the first control in the dialog box, but we set the focus
89 // ourselves, however in OS/2 we must return true to enable the dialog
94 // For all the other ones, FALSE means that we didn't process the
97 return (MRESULT
)FALSE
;
101 // ----------------------------------------------------------------------------
102 // wxTLWHiddenParentModule: used to manage the hidden parent window (we need a
103 // module to ensure that the window is always deleted)
104 // ----------------------------------------------------------------------------
106 class wxTLWHiddenParentModule
: public wxModule
110 // Module init/finalize
112 virtual bool OnInit(void);
113 virtual void OnExit(void);
116 // Get the hidden window (creates on demand)
118 static HWND
GetHWND(void);
122 // The HWND of the hidden parent
127 // The class used to create it
129 static const wxChar
* m_szClassName
;
130 DECLARE_DYNAMIC_CLASS(wxTLWHiddenParentModule
)
131 }; // end of CLASS wxTLWHiddenParentModule
133 IMPLEMENT_DYNAMIC_CLASS(wxTLWHiddenParentModule
, wxModule
)
135 // ----------------------------------------------------------------------------
136 // wxTopLevelWindowOS2 creation
137 // ----------------------------------------------------------------------------
139 void wxTopLevelWindowOS2::Init()
141 m_bIconized
= m_bMaximizeOnShow
= FALSE
;
144 // Unlike (almost?) all other windows, frames are created hidden
149 // Data to save/restore when calling ShowFullScreen
151 m_lFsOldWindowStyle
= 0;
152 m_bFsIsMaximized
= FALSE
;
153 m_bFsIsShowing
= FALSE
;
155 m_hFrame
= NULLHANDLE
;
156 memset(&m_vSwp
, 0, sizeof(SWP
));
157 memset(&m_vSwpClient
, 0, sizeof(SWP
));
158 m_pWinLastFocused
= (wxWindow
*)NULL
;
159 } // end of wxTopLevelWindowIOS2::Init
161 void wxTopLevelWindowOS2::OnActivate(
162 wxActivateEvent
& rEvent
165 if (rEvent
.GetActive())
168 // Restore focus to the child which was last focused
170 wxLogTrace(_T("focus"), _T("wxTLW %08x activated."), m_hWnd
);
172 wxWindow
* pParent
= m_pWinLastFocused
? m_pWinLastFocused
->GetParent()
179 wxSetFocusToChild( pParent
186 // Remember the last focused child if it is our child
188 m_pWinLastFocused
= FindFocus();
191 // So we NULL it out if it's a child from some other frame
193 wxWindow
* pWin
= m_pWinLastFocused
;
197 if (pWin
->IsTopLevel())
201 m_pWinLastFocused
= NULL
;
205 pWin
= pWin
->GetParent();
208 wxLogTrace(_T("focus"),
209 _T("wxTLW %08x deactivated, last focused: %08x."),
211 m_pWinLastFocused
? GetHwndOf(m_pWinLastFocused
)
215 } // end of wxTopLevelWindowOS2::OnActivate
217 WXDWORD
wxTopLevelWindowOS2::OS2GetStyle(
219 , WXDWORD
* pdwExflags
222 long lMsflags
= wxWindow::OS2GetStyle( (lStyle
& ~wxBORDER_MASK
) | wxBORDER_NONE
226 if (lStyle
== wxDEFAULT_FRAME_STYLE
)
227 lMsflags
|= FCF_SIZEBORDER
| FCF_TITLEBAR
| FCF_SYSMENU
|
228 FCF_MINMAX
| FCF_TASKLIST
;
231 if ((lStyle
& wxCAPTION
) == wxCAPTION
)
232 lMsflags
|= FCF_TASKLIST
;
234 lMsflags
|= FCF_NOMOVEWITHOWNER
;
236 if ((lStyle
& wxVSCROLL
) == wxVSCROLL
)
237 lMsflags
|= FCF_VERTSCROLL
;
238 if ((lStyle
& wxHSCROLL
) == wxHSCROLL
)
239 lMsflags
|= FCF_HORZSCROLL
;
240 if (lStyle
& wxMINIMIZE_BOX
)
241 lMsflags
|= FCF_MINBUTTON
;
242 if (lStyle
& wxMAXIMIZE_BOX
)
243 lMsflags
|= FCF_MAXBUTTON
;
244 if (lStyle
& wxTHICK_FRAME
)
245 lMsflags
|= FCF_DLGBORDER
;
246 if (lStyle
& wxSYSTEM_MENU
)
247 lMsflags
|= FCF_SYSMENU
;
248 if (lStyle
& wxCAPTION
)
249 lMsflags
|= FCF_TASKLIST
;
250 if (lStyle
& wxCLIP_CHILDREN
)
252 // Invalid for frame windows under PM
255 if (lStyle
& wxTINY_CAPTION_VERT
)
256 lMsflags
|= FCF_TASKLIST
;
257 if (lStyle
& wxTINY_CAPTION_HORIZ
)
258 lMsflags
|= FCF_TASKLIST
;
260 if ((lStyle
& wxTHICK_FRAME
) == 0)
261 lMsflags
|= FCF_BORDER
;
262 if (lStyle
& wxFRAME_TOOL_WINDOW
)
263 *pdwExflags
= kFrameToolWindow
;
265 if (lStyle
& wxSTAY_ON_TOP
)
266 lMsflags
|= FCF_SYSMODAL
;
269 } // end of wxTopLevelWindowOS2::OS2GetCreateWindowFlags
271 WXHWND
wxTopLevelWindowOS2::OS2GetParent() const
273 HWND hWndParent
= NULL
;
276 // For the frames without wxFRAME_FLOAT_ON_PARENT style we should use NULL
277 // parent HWND or it would be always on top of its parent which is not what
278 // we usually want (in fact, we only want it for frames with the
279 // wxFRAME_FLOAT_ON_PARENT flag)
281 if (HasFlag(wxFRAME_FLOAT_ON_PARENT
) )
283 const wxWindow
* pParent
= GetParent();
288 // This flag doesn't make sense then and will be ignored
290 wxFAIL_MSG( _T("wxFRAME_FLOAT_ON_PARENT but no parent?") );
294 hWndParent
= GetHwndOf(pParent
);
297 //else: don't float on parent, must not be owned
300 // Now deal with the 2nd taskbar-related problem (see comments above in
303 if (HasFlag(wxFRAME_NO_TASKBAR
) && !hWndParent
)
308 hWndParent
= wxTLWHiddenParentModule::GetHWND();
310 return (WXHWND
)hWndParent
;
311 } // end of wxTopLevelWindowOS2::OS2GetParent
313 bool wxTopLevelWindowOS2::CreateDialog(
315 , const wxString
& rsTitle
316 , const wxPoint
& rPos
317 , const wxSize
& rSize
320 wxWindow
* pParent
= GetParent();
323 // For the dialogs without wxDIALOG_NO_PARENT style, use the top level
324 // app window as parent - this avoids creating modal dialogs without
327 if (!pParent
&& !(GetWindowStyleFlag() & wxDIALOG_NO_PARENT
))
329 pParent
= wxTheApp
->GetTopWindow();
334 // Don't use transient windows as parents, this is dangerous as it
335 // can lead to a crash if the parent is destroyed before the child
337 // also don't use the window which is currently hidden as then the
338 // dialog would be hidden as well
339 if ((pParent
->GetExtraStyle() & wxWS_EX_TRANSIENT
) ||
351 hWndOwner
= GetHwndOf(pParent
);
353 hWndOwner
= HWND_DESKTOP
;
355 hWndDlg
= ::WinLoadDlg( HWND_DESKTOP
359 ,(ULONG
)ulDlgTemplate
363 m_hWnd
= (WXHWND
) hWndDlg
;
367 wxFAIL_MSG(wxT("Did you forget to include wx/os2/wx.rc in your resources?"));
369 wxLogSysError(wxT("Can't create dialog using template '%ul'"), ulDlgTemplate
);
375 // Move the dialog to its initial position without forcing repainting
382 if (!OS2GetCreateWindowCoords( rPos
390 nX
= nWidth
= (int)CW_USEDEFAULT
;
394 // We can't use CW_USEDEFAULT here as we're not calling CreateWindow()
395 // and passing CW_USEDEFAULT to MoveWindow() results in resizing the
396 // window to (0, 0) size which breaks quite a lot of things, e.g. the
397 // sizer calculation in wxSizer::Fit()
399 if (nWidth
== (int)CW_USEDEFAULT
)
402 // The exact number doesn't matter, the dialog will be resized
403 // again soon anyhow but it should be big enough to allow
404 // calculation relying on "totalSize - clientSize > 0" work, i.e.
405 // at least greater than the title bar height
407 nWidth
= nHeight
= 100;
409 if (nX
== (int)CW_USEDEFAULT
)
412 // Centre it on the screen - what else can we do?
414 wxSize vSizeDpy
= wxGetDisplaySize();
416 nX
= (vSizeDpy
.x
- nWidth
) / 2;
417 nY
= (vSizeDpy
.y
- nHeight
) / 2;
419 m_backgroundColour
.Set(wxString("LIGHT GREY"));
421 LONG lColor
= (LONG
)m_backgroundColour
.GetPixel();
423 if (!::WinSetPresParam( m_hWnd
432 ::WinSetWindowPos( GetHwnd()
438 ,SWP_MOVE
| SWP_SIZE
| SWP_ZORDER
| SWP_SHOW
| SWP_ACTIVATE
440 ::WinQueryWindowPos(GetHwnd(), GetSwp());
444 } // end of wxTopLevelWindowOS2::CreateDialog
446 bool wxTopLevelWindowOS2::CreateFrame(
447 const wxString
& rsTitle
448 , const wxPoint
& rPos
449 , const wxSize
& rSize
453 WXDWORD lFlags
= OS2GetCreateWindowFlags(&lExflags
);
454 long lStyle
= GetWindowStyleFlag();
457 int nWidth
= rSize
.x
;
458 int nHeight
= rSize
.y
;
459 ULONG ulStyleFlags
= 0L;
462 wxWindow
* pParent
= GetParent();
468 hParent
= GetHwndOf(pParent
);
470 hParent
= HWND_DESKTOP
;
472 if ((lStyle
& wxMINIMIZE
) || (lStyle
& wxICONIZE
))
473 ulStyleFlags
|= WS_MINIMIZED
;
474 if (lStyle
& wxMAXIMIZE
)
475 ulStyleFlags
|= WS_MAXIMIZED
;
478 // Clear the visible flag, we always call show
480 ulStyleFlags
&= (unsigned long)~WS_VISIBLE
;
484 // Create the frame window: We break ranks with other ports now
485 // and instead of calling down into the base wxWindow class' OS2Create
486 // we do all our own stuff here. We will set the needed pieces
487 // of wxWindow manually, here.
490 hFrame
= ::WinCreateStdWindow( hParent
491 ,ulStyleFlags
// frame-window style
492 ,(PULONG
)&lFlags
// window style
493 ,(PSZ
)wxFrameClassName
// class name
494 ,(PSZ
)rsTitle
.c_str() // window title
495 ,0L // default client style
496 ,NULLHANDLE
// resource in executable file
498 ,&hClient
// receives client window handle
502 vError
= ::WinGetLastError(vHabmain
);
503 sError
= wxPMErrorToStr(vError
);
504 wxLogError("Error creating frame. Error: %s\n", sError
);
509 // wxWindow class' m_hWnd set here and needed associations
513 wxAssociateWinWithHandle(m_hWnd
, this);
514 wxAssociateWinWithHandle(m_hFrame
, this);
516 m_backgroundColour
.Set(wxString("MEDIUM GREY"));
518 LONG lColor
= (LONG
)m_backgroundColour
.GetPixel();
520 if (!::WinSetPresParam( m_hWnd
526 vError
= ::WinGetLastError(vHabmain
);
527 sError
= wxPMErrorToStr(vError
);
528 wxLogError("Error creating frame. Error: %s\n", sError
);
533 // Now need to subclass window. Instead of calling the SubClassWin in wxWindow
534 // we manually subclass here because we don't want to use the main wxWndProc
537 m_fnOldWndProc
= (WXFARPROC
) ::WinSubclassWindow(m_hFrame
, (PFNWP
)wxFrameMainWndProc
);
540 // Now size everything. If adding a menu the client will need to be resized.
545 nY
= pParent
->GetSize().y
- (nY
+ nHeight
);
551 ::WinQueryWindowRect(HWND_DESKTOP
, &vRect
);
552 nY
= vRect
.yTop
- (nY
+ nHeight
);
554 if (!::WinSetWindowPos( m_hFrame
560 ,SWP_SIZE
| SWP_MOVE
| SWP_ACTIVATE
| SWP_ZORDER
563 vError
= ::WinGetLastError(vHabmain
);
564 sError
= wxPMErrorToStr(vError
);
565 wxLogError("Error sizing frame. Error: %s\n", sError
);
568 lStyle
= ::WinQueryWindowULong( m_hWnd
571 lStyle
|= WS_CLIPCHILDREN
;
572 ::WinSetWindowULong( m_hWnd
577 } // end of wxTopLevelWindowOS2::CreateFrame
579 bool wxTopLevelWindowOS2::Create(
582 , const wxString
& rsTitle
583 , const wxPoint
& rPos
584 , const wxSize
& rSize
586 , const wxString
& rsName
593 m_windowStyle
= lStyle
;
595 m_windowId
= vId
== -1 ? NewControlId() : vId
;
596 wxTopLevelWindows
.Append(this);
598 pParent
->AddChild(this);
600 if (GetExtraStyle() & wxTOPLEVEL_EX_DIALOG
)
603 // We have different dialog templates to allows creation of dialogs
604 // with & without captions under OS2indows, resizeable or not (but a
605 // resizeable dialog always has caption - otherwise it would look too
610 if (lStyle
& wxRESIZE_BORDER
)
611 ulDlgTemplate
= (ULONG
)kResizeableDialog
;
612 else if (lStyle
& wxCAPTION
)
613 ulDlgTemplate
= (ULONG
)kCaptionDialog
;
615 ulDlgTemplate
= (ULONG
)kNoCaptionDialog
;
616 return CreateDialog( ulDlgTemplate
624 return CreateFrame( rsTitle
629 } // end of wxTopLevelWindowOS2::Create
631 wxTopLevelWindowOS2::~wxTopLevelWindowOS2()
633 if (wxModelessWindows
.Find(this))
634 wxModelessWindows
.DeleteObject(this);
637 // After destroying an owned window, Windows activates the next top level
638 // window in Z order but it may be different from our owner (to reproduce
639 // this simply Alt-TAB to another application and back before closing the
640 // owned frame) whereas we always want to yield activation to our parent
642 if (HasFlag(wxFRAME_FLOAT_ON_PARENT
))
644 wxWindow
* pParent
= GetParent();
648 ::WinSetWindowPos( GetHwndOf(pParent
)
655 } // end of wxTopLevelWindowOS2::~wxTopLevelWindowOS2
657 // ----------------------------------------------------------------------------
658 // wxTopLevelWindowOS2 client size
659 // ----------------------------------------------------------------------------
661 void wxTopLevelWindowOS2::DoSetClientSize(
667 // Call GetClientAreaOrigin() to take the toolbar into account
669 wxPoint vPt
= GetClientAreaOrigin();
674 wxWindow::DoSetClientSize( nWidth
677 } // end of wxTopLevelWindowOS2::DoSetClientSize
679 void wxTopLevelWindowOS2::DoGetClientSize(
684 wxWindow::DoGetClientSize( pnX
688 wxPoint vPt
= GetClientAreaOrigin();
695 } // end of wxTopLevelWindowOS2::DoGetClientSize
697 // ----------------------------------------------------------------------------
698 // wxTopLevelWindowOS2 showing
699 // ----------------------------------------------------------------------------
701 void wxTopLevelWindowOS2::DoShowWindow(
705 ::WinShowWindow(m_hFrame
, (BOOL
)(nShowCmd
& SWP_SHOW
));
708 // Need to artificially send a size event as wxApps often expect to do some
709 // final child control sizing
711 m_bIconized
= nShowCmd
== SWP_MINIMIZE
;
712 } // end of wxTopLevelWindowOS2::DoShowWindow
714 bool wxTopLevelWindowOS2::Show(
722 if (bShow
!= IsShown() )
732 if (m_bMaximizeOnShow
)
734 nShowCmd
= SWP_MAXIMIZE
;
735 m_bMaximizeOnShow
= FALSE
;
746 DoShowWindow(nShowCmd
);
750 wxActivateEvent
vEvent(wxEVT_ACTIVATE
, TRUE
, m_windowId
);
752 ::WinQueryWindowPos(m_hFrame
, &vSwp
);
753 m_bIconized
= vSwp
.fl
& SWP_MINIMIZE
;
754 ::WinQueryWindowPos(m_hWnd
, &m_vSwpClient
);
755 ::WinSendMsg(m_hFrame
, WM_UPDATEFRAME
, (MPARAM
)~0, 0);
756 ::WinQueryWindowPos(m_hWnd
, &vSwp
);
757 ::WinEnableWindow(m_hFrame
, TRUE
);
760 // Deal with children
762 MoveChildren(m_vSwpClient
.cy
- vSwp
.cy
);
763 vEvent
.SetEventObject(this);
764 GetEventHandler()->ProcessEvent(vEvent
);
769 // Try to highlight the correct window (the parent)
773 HWND hWndParent
= GetHwndOf(GetParent());
775 ::WinQueryWindowPos(hWndParent
, &vSwp
);
776 m_bIconized
= vSwp
.fl
& SWP_MINIMIZE
;
777 ::WinEnableWindow(hWndParent
, TRUE
);
781 } // end of wxTopLevelWindowOS2::Show
783 // ----------------------------------------------------------------------------
784 // wxTopLevelWindowOS2 maximize/minimize
785 // ----------------------------------------------------------------------------
787 void wxTopLevelWindowOS2::Maximize(
794 // Just maximize it directly
796 DoShowWindow(bMaximize
? SWP_MAXIMIZE
: SWP_RESTORE
);
801 // We can't maximize the hidden frame because it shows it as well, so
802 // just remember that we should do it later in this case
804 m_bMaximizeOnShow
= TRUE
;
806 } // end of wxTopLevelWindowOS2::Maximize
808 bool wxTopLevelWindowOS2::IsMaximized() const
812 ::WinQueryWindowPos(m_hFrame
, (PSWP
)&m_vSwp
);
813 return (m_vSwp
.fl
& SWP_MAXIMIZE
);
814 } // end of wxTopLevelWindowOS2::IsMaximized
816 void wxTopLevelWindowOS2::Iconize(
820 DoShowWindow(bIconize
? SWP_MINIMIZE
: SWP_RESTORE
);
821 } // end of wxTopLevelWindowOS2::Iconize
823 bool wxTopLevelWindowOS2::IsIconized() const
825 // also update the current state
826 ::WinQueryWindowPos(m_hFrame
, (PSWP
)&m_vSwp
);
827 if (m_vSwp
.fl
& SWP_MINIMIZE
)
828 ((wxTopLevelWindow
*)this)->m_bIconized
= TRUE
;
830 ((wxTopLevelWindow
*)this)->m_bIconized
= FALSE
;
832 } // end of wxTopLevelWindowOS2::IsIconized
834 void wxTopLevelWindowOS2::Restore()
836 DoShowWindow(SWP_RESTORE
);
837 } // end of wxTopLevelWindowOS2::Restore
839 // generate an artificial resize event
840 void wxTopLevelWindowOS2::SendSizeEvent()
844 RECTL vRect
= wxGetWindowRect(GetHwnd());
846 (void)::WinPostMsg( m_hFrame
848 ,MPFROM2SHORT(vRect
.xRight
- vRect
.xLeft
, vRect
.yTop
- vRect
.yBottom
)
849 ,MPFROM2SHORT(vRect
.xRight
- vRect
.xLeft
, vRect
.yTop
- vRect
.yBottom
)
852 } // end of wxTopLevelWindowOS2::SendSizeEvent
854 // ----------------------------------------------------------------------------
855 // wxTopLevelWindowOS2 fullscreen
856 // ----------------------------------------------------------------------------
858 bool wxTopLevelWindowOS2::ShowFullScreen(
868 m_bFsIsShowing
= TRUE
;
872 // Zap the frame borders
876 // Save the 'normal' window lStyle
878 m_lFsOldWindowStyle
= ::WinQueryWindowULong( (HWND
)GetHWND()
883 // Save the old position, width & height, maximize state
885 m_vFsOldSize
= GetRect();
886 m_bFsIsMaximized
= IsMaximized();
889 // Decide which window lStyle flags to turn off
891 LONG lNewStyle
= m_lFsOldWindowStyle
;
894 if (lStyle
& wxFULLSCREEN_NOBORDER
)
895 lOffFlags
|= FCF_BORDER
;
896 if (lStyle
& wxFULLSCREEN_NOCAPTION
)
897 lOffFlags
|= (FCF_TASKLIST
| FCF_SYSMENU
);
899 lNewStyle
&= (~lOffFlags
);
902 // Change our window style to be compatible with full-screen mode
904 ::WinSetWindowULong( (HWND
)GetHWND()
910 // Resize to the size of the desktop
914 RECTL vRect
= wxGetWindowRect(HWND_DESKTOP
);
916 nWidth
= vRect
.xRight
- vRect
.xLeft
;
917 nHeight
= vRect
.yTop
- vRect
.yBottom
;
924 // Now flush the window style cache and actually go full-screen
926 ::WinSetWindowPos( m_hFrame
935 wxSizeEvent
vEvent( wxSize( nWidth
941 GetEventHandler()->ProcessEvent(vEvent
);
949 m_bFsIsShowing
= FALSE
;
950 Maximize(m_bFsIsMaximized
);
951 ::WinSetWindowULong( (HWND
)GetHWND()
955 ::WinSetWindowPos( m_hFrame
965 } // end of wxTopLevelWindowOS2::ShowFullScreen
967 // ----------------------------------------------------------------------------
968 // wxTopLevelWindowOS2 misc
969 // ----------------------------------------------------------------------------
971 void wxTopLevelWindowOS2::SetIcon(
975 SetIcons(wxIconBundle(rIcon
));
976 } // end of wxTopLevelWindowOS2::SetIcon
978 void wxTopLevelWindowOS2::SetIcons(
979 const wxIconBundle
& rIcons
985 wxTopLevelWindowBase::SetIcons(rIcons
);
987 const wxIcon
& vIcon
= rIcons
.GetIcon(wxSize(32, 32));
989 if (vIcon
.Ok() && vIcon
.GetWidth() == 32 && vIcon
.GetHeight() == 32)
991 ::WinSendMsg( m_hFrame
993 ,(MPARAM
)((HPOINTER
)vIcon
.GetHICON())
996 ::WinSendMsg( m_hFrame
1002 } // end of wxTopLevelWindowOS2::SetIcon
1004 bool wxTopLevelWindowOS2::EnableCloseButton(
1009 // Get system (a.k.a. window) menu
1011 HMENU hMenu
= ::WinWindowFromID(m_hFrame
, FID_SYSMENU
);
1015 wxLogLastError(_T("GetSystemMenu"));
1020 // Enabling/disabling the close item from it also automatically
1021 // disables/enables the close title bar button
1024 (void)::WinSendMsg( hMenu
1026 ,MPFROM2SHORT(SC_CLOSE
, FALSE
)
1027 ,MPFROM2SHORT(MIA_DISABLED
, FALSE
)
1030 (void)::WinSendMsg( hMenu
1032 ,MPFROM2SHORT(SC_CLOSE
, FALSE
)
1033 ,MPFROM2SHORT(MIA_DISABLED
, MIA_DISABLED
)
1037 // Update appearance immediately
1039 ::WinSendMsg( m_hFrame
1045 } // end of wxTopLevelWindowOS2::EnableCloseButton
1047 // ============================================================================
1048 // wxTLWHiddenParentModule implementation
1049 // ============================================================================
1051 HWND
wxTLWHiddenParentModule::m_shWnd
= NULL
;
1052 const wxChar
* wxTLWHiddenParentModule::m_szClassName
= NULL
;
1054 bool wxTLWHiddenParentModule::OnInit()
1057 m_szClassName
= NULL
;
1059 } // end of wxTLWHiddenParentModule::OnInit
1061 void wxTLWHiddenParentModule::OnExit()
1065 if (!::WinDestroyWindow(m_shWnd
))
1067 wxLogLastError(_T("DestroyWindow(hidden TLW parent)"));
1072 m_szClassName
= NULL
;
1073 } // end of wxTLWHiddenParentModule::OnExit
1076 HWND
wxTLWHiddenParentModule::GetHWND()
1082 static const wxChar
* zHIDDEN_PARENT_CLASS
= _T("wxTLWHiddenParent");
1084 if (!::WinRegisterClass( wxGetInstance()
1085 ,zHIDDEN_PARENT_CLASS
1091 wxLogLastError(_T("RegisterClass(\"wxTLWHiddenParent\")"));
1095 m_szClassName
= zHIDDEN_PARENT_CLASS
;
1098 m_shWnd
= ::WinCreateWindow( HWND_DESKTOP
1114 wxLogLastError(_T("CreateWindow(hidden TLW parent)"));
1118 } // end of wxTLWHiddenParentModule::GetHWND