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/dialog.h"
35 #include "wx/string.h"
39 #include "wx/control.h"
40 #include "wx/containr.h" // wxSetFocusToChild()
43 #include "wx/module.h" // wxSetFocusToChild()
44 #include "wx/os2/private.h"
46 // ----------------------------------------------------------------------------
47 // stubs for missing functions under MicroWindows
48 // ----------------------------------------------------------------------------
51 // ----------------------------------------------------------------------------
53 // ----------------------------------------------------------------------------
55 // list of all frames and modeless dialogs
56 wxWindowList wxModelessWindows
;
58 // the name of the default wxWindows class
59 extern void wxAssociateWinWithHandle( HWND hWnd
62 bool wxTopLevelWindowOS2::m_sbInitialized
= FALSE
;
63 wxWindow
* wxTopLevelWindowOS2::m_spHiddenParent
= NULL
;
65 // ============================================================================
66 // wxTopLevelWindowOS2 implementation
67 // ============================================================================
69 BEGIN_EVENT_TABLE(wxTopLevelWindowOS2
, wxTopLevelWindowBase
)
70 EVT_ACTIVATE(wxTopLevelWindowOS2::OnActivate
)
73 // ============================================================================
74 // wxTopLevelWindowMSW implementation
75 // ============================================================================
78 MRESULT EXPENTRY
wxDlgProc( HWND
WXUNUSED(hWnd
)
80 ,void * WXUNUSED(wParam
)
81 ,void * WXUNUSED(lParam
)
88 // For this message, returning TRUE tells system to set focus to
89 // the first control in the dialog box, but we set the focus
90 // ourselves, however in OS/2 we must return true to enable the dialog
95 // For all the other ones, FALSE means that we didn't process the
98 return (MRESULT
)FALSE
;
100 } // end of wxDlgProc
102 // ----------------------------------------------------------------------------
103 // wxTLWHiddenParentModule: used to manage the hidden parent window (we need a
104 // module to ensure that the window is always deleted)
105 // ----------------------------------------------------------------------------
107 class wxTLWHiddenParentModule
: public wxModule
111 // Module init/finalize
113 virtual bool OnInit(void);
114 virtual void OnExit(void);
117 // Get the hidden window (creates on demand)
119 static HWND
GetHWND(void);
123 // The HWND of the hidden parent
128 // The class used to create it
130 static const wxChar
* m_szClassName
;
131 DECLARE_DYNAMIC_CLASS(wxTLWHiddenParentModule
)
132 }; // end of CLASS wxTLWHiddenParentModule
134 IMPLEMENT_DYNAMIC_CLASS(wxTLWHiddenParentModule
, wxModule
)
136 // ----------------------------------------------------------------------------
137 // wxTopLevelWindowOS2 creation
138 // ----------------------------------------------------------------------------
140 void wxTopLevelWindowOS2::Init()
142 m_bIconized
= m_bMaximizeOnShow
= FALSE
;
145 // Unlike (almost?) all other windows, frames are created hidden
150 // Data to save/restore when calling ShowFullScreen
152 m_lFsOldWindowStyle
= 0;
153 m_bFsIsMaximized
= FALSE
;
154 m_bFsIsShowing
= FALSE
;
156 m_hFrame
= NULLHANDLE
;
157 memset(&m_vSwp
, 0, sizeof(SWP
));
158 memset(&m_vSwpClient
, 0, sizeof(SWP
));
159 m_pWinLastFocused
= (wxWindow
*)NULL
;
160 } // end of wxTopLevelWindowIOS2::Init
162 void wxTopLevelWindowOS2::OnActivate(
163 wxActivateEvent
& rEvent
166 if (rEvent
.GetActive())
169 // Restore focus to the child which was last focused
171 wxLogTrace(_T("focus"), _T("wxTLW %08lx activated."), m_hWnd
);
173 wxWindow
* pParent
= m_pWinLastFocused
? m_pWinLastFocused
->GetParent()
180 wxSetFocusToChild( pParent
187 // Remember the last focused child if it is our child
189 m_pWinLastFocused
= FindFocus();
192 // So we NULL it out if it's a child from some other frame
194 wxWindow
* pWin
= m_pWinLastFocused
;
198 if (pWin
->IsTopLevel())
202 m_pWinLastFocused
= NULL
;
206 pWin
= pWin
->GetParent();
209 wxLogTrace(_T("focus"),
210 _T("wxTLW %08lx deactivated, last focused: %08lx."),
212 m_pWinLastFocused
? GetHwndOf(m_pWinLastFocused
)
216 } // end of wxTopLevelWindowOS2::OnActivate
218 WXDWORD
wxTopLevelWindowOS2::OS2GetStyle(
220 , WXDWORD
* pdwExflags
223 long lMsflags
= wxWindow::OS2GetStyle( (lStyle
& ~wxBORDER_MASK
) | wxBORDER_NONE
227 if (lStyle
== wxDEFAULT_FRAME_STYLE
)
228 lMsflags
|= FCF_SIZEBORDER
| FCF_TITLEBAR
| FCF_SYSMENU
|
229 FCF_MINMAX
| FCF_TASKLIST
;
232 if ((lStyle
& wxCAPTION
) == wxCAPTION
)
233 lMsflags
|= FCF_TASKLIST
;
235 lMsflags
|= FCF_NOMOVEWITHOWNER
;
237 if ((lStyle
& wxVSCROLL
) == wxVSCROLL
)
238 lMsflags
|= FCF_VERTSCROLL
;
239 if ((lStyle
& wxHSCROLL
) == wxHSCROLL
)
240 lMsflags
|= FCF_HORZSCROLL
;
241 if (lStyle
& wxMINIMIZE_BOX
)
242 lMsflags
|= FCF_MINBUTTON
;
243 if (lStyle
& wxMAXIMIZE_BOX
)
244 lMsflags
|= FCF_MAXBUTTON
;
245 if (lStyle
& wxTHICK_FRAME
)
246 lMsflags
|= FCF_DLGBORDER
;
247 if (lStyle
& wxSYSTEM_MENU
)
248 lMsflags
|= FCF_SYSMENU
;
249 if (lStyle
& wxCAPTION
)
250 lMsflags
|= FCF_TASKLIST
;
251 if (lStyle
& wxCLIP_CHILDREN
)
253 // Invalid for frame windows under PM
256 if (lStyle
& wxTINY_CAPTION_VERT
)
257 lMsflags
|= FCF_TASKLIST
;
258 if (lStyle
& wxTINY_CAPTION_HORIZ
)
259 lMsflags
|= FCF_TASKLIST
;
261 if ((lStyle
& wxTHICK_FRAME
) == 0)
262 lMsflags
|= FCF_BORDER
;
263 if (lStyle
& wxFRAME_TOOL_WINDOW
)
264 *pdwExflags
= kFrameToolWindow
;
266 if (lStyle
& wxSTAY_ON_TOP
)
267 lMsflags
|= FCF_SYSMODAL
;
270 } // end of wxTopLevelWindowOS2::OS2GetCreateWindowFlags
272 WXHWND
wxTopLevelWindowOS2::OS2GetParent() const
274 HWND hWndParent
= NULL
;
277 // For the frames without wxFRAME_FLOAT_ON_PARENT style we should use NULL
278 // parent HWND or it would be always on top of its parent which is not what
279 // we usually want (in fact, we only want it for frames with the
280 // wxFRAME_FLOAT_ON_PARENT flag)
282 if (HasFlag(wxFRAME_FLOAT_ON_PARENT
) )
284 const wxWindow
* pParent
= GetParent();
289 // This flag doesn't make sense then and will be ignored
291 wxFAIL_MSG( _T("wxFRAME_FLOAT_ON_PARENT but no parent?") );
295 hWndParent
= GetHwndOf(pParent
);
298 //else: don't float on parent, must not be owned
301 // Now deal with the 2nd taskbar-related problem (see comments above in
304 if (HasFlag(wxFRAME_NO_TASKBAR
) && !hWndParent
)
309 hWndParent
= wxTLWHiddenParentModule::GetHWND();
311 return (WXHWND
)hWndParent
;
312 } // end of wxTopLevelWindowOS2::OS2GetParent
314 bool wxTopLevelWindowOS2::CreateDialog(
316 , const wxString
& rsTitle
317 , const wxPoint
& rPos
318 , const wxSize
& rSize
321 wxWindow
* pParent
= GetParent();
324 // For the dialogs without wxDIALOG_NO_PARENT style, use the top level
325 // app window as parent - this avoids creating modal dialogs without
328 if (!pParent
&& !(GetWindowStyleFlag() & wxDIALOG_NO_PARENT
))
330 pParent
= wxTheApp
->GetTopWindow();
335 // Don't use transient windows as parents, this is dangerous as it
336 // can lead to a crash if the parent is destroyed before the child
338 // also don't use the window which is currently hidden as then the
339 // dialog would be hidden as well
340 if ((pParent
->GetExtraStyle() & wxWS_EX_TRANSIENT
) ||
352 hWndOwner
= GetHwndOf(pParent
);
354 hWndOwner
= HWND_DESKTOP
;
356 hWndDlg
= ::WinLoadDlg( HWND_DESKTOP
360 ,(ULONG
)ulDlgTemplate
364 m_hWnd
= (WXHWND
) hWndDlg
;
368 wxFAIL_MSG(wxT("Did you forget to include wx/os2/wx.rc in your resources?"));
370 wxLogSysError(wxT("Can't create dialog using template '%ld'"), ulDlgTemplate
);
376 // Move the dialog to its initial position without forcing repainting
383 if (!OS2GetCreateWindowCoords( rPos
391 nX
= nWidth
= (int)CW_USEDEFAULT
;
395 // We can't use CW_USEDEFAULT here as we're not calling CreateWindow()
396 // and passing CW_USEDEFAULT to MoveWindow() results in resizing the
397 // window to (0, 0) size which breaks quite a lot of things, e.g. the
398 // sizer calculation in wxSizer::Fit()
400 if (nWidth
== (int)CW_USEDEFAULT
)
403 // The exact number doesn't matter, the dialog will be resized
404 // again soon anyhow but it should be big enough to allow
405 // calculation relying on "totalSize - clientSize > 0" work, i.e.
406 // at least greater than the title bar height
408 nWidth
= nHeight
= 100;
410 if (nX
== (int)CW_USEDEFAULT
)
413 // Centre it on the screen - what else can we do?
415 wxSize vSizeDpy
= wxGetDisplaySize();
417 nX
= (vSizeDpy
.x
- nWidth
) / 2;
418 nY
= (vSizeDpy
.y
- nHeight
) / 2;
420 m_backgroundColour
.Set(wxString("LIGHT GREY"));
422 LONG lColor
= (LONG
)m_backgroundColour
.GetPixel();
424 if (!::WinSetPresParam( m_hWnd
433 ::WinSetWindowPos( GetHwnd()
439 ,SWP_MOVE
| SWP_SIZE
| SWP_ZORDER
| SWP_SHOW
| SWP_ACTIVATE
441 ::WinQueryWindowPos(GetHwnd(), GetSwp());
445 } // end of wxTopLevelWindowOS2::CreateDialog
447 bool wxTopLevelWindowOS2::CreateFrame(
448 const wxString
& rsTitle
449 , const wxPoint
& rPos
450 , const wxSize
& rSize
454 WXDWORD lFlags
= OS2GetCreateWindowFlags(&lExflags
);
455 long lStyle
= GetWindowStyleFlag();
458 int nWidth
= rSize
.x
;
459 int nHeight
= rSize
.y
;
460 ULONG ulStyleFlags
= 0L;
463 wxWindow
* pParent
= GetParent();
469 hParent
= GetHwndOf(pParent
);
471 hParent
= HWND_DESKTOP
;
473 if ((lStyle
& wxMINIMIZE
) || (lStyle
& wxICONIZE
))
474 ulStyleFlags
|= WS_MINIMIZED
;
475 if (lStyle
& wxMAXIMIZE
)
476 ulStyleFlags
|= WS_MAXIMIZED
;
479 // Clear the visible flag, we always call show
481 ulStyleFlags
&= (unsigned long)~WS_VISIBLE
;
485 // Create the frame window: We break ranks with other ports now
486 // and instead of calling down into the base wxWindow class' OS2Create
487 // we do all our own stuff here. We will set the needed pieces
488 // of wxWindow manually, here.
491 hFrame
= ::WinCreateStdWindow( hParent
492 ,ulStyleFlags
// frame-window style
493 ,(PULONG
)&lFlags
// window style
494 ,(PSZ
)wxFrameClassName
// class name
495 ,(PSZ
)rsTitle
.c_str() // window title
496 ,0L // default client style
497 ,NULLHANDLE
// resource in executable file
499 ,&hClient
// receives client window handle
503 vError
= ::WinGetLastError(vHabmain
);
504 sError
= wxPMErrorToStr(vError
);
505 wxLogError("Error creating frame. Error: %s\n", sError
.c_str());
510 // wxWindow class' m_hWnd set here and needed associations
514 wxAssociateWinWithHandle(m_hWnd
, this);
515 wxAssociateWinWithHandle(m_hFrame
, this);
517 m_backgroundColour
.Set(wxString("MEDIUM GREY"));
519 LONG lColor
= (LONG
)m_backgroundColour
.GetPixel();
521 if (!::WinSetPresParam( m_hWnd
527 vError
= ::WinGetLastError(vHabmain
);
528 sError
= wxPMErrorToStr(vError
);
529 wxLogError("Error creating frame. Error: %s\n", sError
.c_str());
534 // Now need to subclass window. Instead of calling the SubClassWin in wxWindow
535 // we manually subclass here because we don't want to use the main wxWndProc
538 m_fnOldWndProc
= (WXFARPROC
) ::WinSubclassWindow(m_hFrame
, (PFNWP
)wxFrameMainWndProc
);
541 // Now size everything. If adding a menu the client will need to be resized.
546 nY
= pParent
->GetSize().y
- (nY
+ nHeight
);
552 ::WinQueryWindowRect(HWND_DESKTOP
, &vRect
);
553 nY
= vRect
.yTop
- (nY
+ nHeight
);
555 if (!::WinSetWindowPos( m_hFrame
561 ,SWP_SIZE
| SWP_MOVE
| SWP_ACTIVATE
| SWP_ZORDER
564 vError
= ::WinGetLastError(vHabmain
);
565 sError
= wxPMErrorToStr(vError
);
566 wxLogError("Error sizing frame. Error: %s\n", sError
.c_str());
569 lStyle
= ::WinQueryWindowULong( m_hWnd
572 lStyle
|= WS_CLIPCHILDREN
;
573 ::WinSetWindowULong( m_hWnd
578 } // end of wxTopLevelWindowOS2::CreateFrame
580 bool wxTopLevelWindowOS2::Create(
583 , const wxString
& rsTitle
584 , const wxPoint
& rPos
585 , const wxSize
& rSizeOrig
587 , const wxString
& rsName
594 m_windowStyle
= lStyle
;
596 m_windowId
= vId
== -1 ? NewControlId() : vId
;
598 // always create a frame of some reasonable, even if arbitrary, size (at
599 // least for MSW compatibility)
600 wxSize rSize
= rSizeOrig
;
601 if ( rSize
.x
== -1 || rSize
.y
== -1 )
603 wxSize sizeDpy
= wxGetDisplaySize();
605 rSize
.x
= sizeDpy
.x
/ 3;
607 rSize
.y
= sizeDpy
.y
/ 5;
610 wxTopLevelWindows
.Append(this);
612 pParent
->AddChild(this);
614 if (GetExtraStyle() & wxTOPLEVEL_EX_DIALOG
)
617 // We have different dialog templates to allows creation of dialogs
618 // with & without captions under OS2indows, resizeable or not (but a
619 // resizeable dialog always has caption - otherwise it would look too
624 if (lStyle
& wxRESIZE_BORDER
)
625 ulDlgTemplate
= (ULONG
)kResizeableDialog
;
626 else if (lStyle
& wxCAPTION
)
627 ulDlgTemplate
= (ULONG
)kCaptionDialog
;
629 ulDlgTemplate
= (ULONG
)kNoCaptionDialog
;
630 return CreateDialog( ulDlgTemplate
638 return CreateFrame( rsTitle
643 } // end of wxTopLevelWindowOS2::Create
645 wxTopLevelWindowOS2::~wxTopLevelWindowOS2()
647 if (wxModelessWindows
.Find(this))
648 wxModelessWindows
.DeleteObject(this);
651 // After destroying an owned window, Windows activates the next top level
652 // window in Z order but it may be different from our owner (to reproduce
653 // this simply Alt-TAB to another application and back before closing the
654 // owned frame) whereas we always want to yield activation to our parent
656 if (HasFlag(wxFRAME_FLOAT_ON_PARENT
))
658 wxWindow
* pParent
= GetParent();
662 ::WinSetWindowPos( GetHwndOf(pParent
)
669 } // end of wxTopLevelWindowOS2::~wxTopLevelWindowOS2
671 // ----------------------------------------------------------------------------
672 // wxTopLevelWindowOS2 client size
673 // ----------------------------------------------------------------------------
675 void wxTopLevelWindowOS2::DoSetClientSize(
681 // Call GetClientAreaOrigin() to take the toolbar into account
683 wxPoint vPt
= GetClientAreaOrigin();
688 wxWindow::DoSetClientSize( nWidth
691 } // end of wxTopLevelWindowOS2::DoSetClientSize
693 void wxTopLevelWindowOS2::DoGetClientSize(
698 wxWindow::DoGetClientSize( pnX
702 wxPoint vPt
= GetClientAreaOrigin();
709 } // end of wxTopLevelWindowOS2::DoGetClientSize
711 // ----------------------------------------------------------------------------
712 // wxTopLevelWindowOS2 showing
713 // ----------------------------------------------------------------------------
715 void wxTopLevelWindowOS2::DoShowWindow(
719 ::WinShowWindow(m_hFrame
, (BOOL
)(nShowCmd
& SWP_SHOW
));
722 // Need to artificially send a size event as wxApps often expect to do some
723 // final child control sizing
725 m_bIconized
= nShowCmd
== SWP_MINIMIZE
;
726 } // end of wxTopLevelWindowOS2::DoShowWindow
728 bool wxTopLevelWindowOS2::Show(
735 if (bShow
!= IsShown() )
745 if (m_bMaximizeOnShow
)
747 nShowCmd
= SWP_MAXIMIZE
;
748 m_bMaximizeOnShow
= FALSE
;
759 DoShowWindow(nShowCmd
);
763 wxActivateEvent
vEvent(wxEVT_ACTIVATE
, TRUE
, m_windowId
);
765 ::WinQueryWindowPos(m_hFrame
, &vSwp
);
766 m_bIconized
= vSwp
.fl
& SWP_MINIMIZE
;
767 ::WinQueryWindowPos(m_hWnd
, &m_vSwpClient
);
768 ::WinSendMsg(m_hFrame
, WM_UPDATEFRAME
, (MPARAM
)~0, 0);
769 ::WinQueryWindowPos(m_hWnd
, &vSwp
);
770 ::WinEnableWindow(m_hFrame
, TRUE
);
773 // Deal with children
775 MoveChildren(m_vSwpClient
.cy
- vSwp
.cy
);
776 vEvent
.SetEventObject(this);
777 GetEventHandler()->ProcessEvent(vEvent
);
782 // Try to highlight the correct window (the parent)
786 HWND hWndParent
= GetHwndOf(GetParent());
788 ::WinQueryWindowPos(hWndParent
, &vSwp
);
789 m_bIconized
= vSwp
.fl
& SWP_MINIMIZE
;
790 ::WinEnableWindow(hWndParent
, TRUE
);
794 } // end of wxTopLevelWindowOS2::Show
796 // ----------------------------------------------------------------------------
797 // wxTopLevelWindowOS2 maximize/minimize
798 // ----------------------------------------------------------------------------
800 void wxTopLevelWindowOS2::Maximize(
807 // Just maximize it directly
809 DoShowWindow(bMaximize
? SWP_MAXIMIZE
: SWP_RESTORE
);
814 // We can't maximize the hidden frame because it shows it as well, so
815 // just remember that we should do it later in this case
817 m_bMaximizeOnShow
= bMaximize
;
819 } // end of wxTopLevelWindowOS2::Maximize
821 bool wxTopLevelWindowOS2::IsMaximized() const
824 ::WinQueryWindowPos(m_hFrame
, (PSWP
)&m_vSwp
);
825 return (m_vSwp
.fl
& SWP_MAXIMIZE
);
826 } // end of wxTopLevelWindowOS2::IsMaximized
828 void wxTopLevelWindowOS2::Iconize(
832 DoShowWindow(bIconize
? SWP_MINIMIZE
: SWP_RESTORE
);
833 } // end of wxTopLevelWindowOS2::Iconize
835 bool wxTopLevelWindowOS2::IsIconized() const
837 // also update the current state
838 ::WinQueryWindowPos(m_hFrame
, (PSWP
)&m_vSwp
);
839 if (m_vSwp
.fl
& SWP_MINIMIZE
)
840 ((wxTopLevelWindow
*)this)->m_bIconized
= TRUE
;
842 ((wxTopLevelWindow
*)this)->m_bIconized
= FALSE
;
844 } // end of wxTopLevelWindowOS2::IsIconized
846 void wxTopLevelWindowOS2::Restore()
848 DoShowWindow(SWP_RESTORE
);
849 } // end of wxTopLevelWindowOS2::Restore
851 // generate an artificial resize event
852 void wxTopLevelWindowOS2::SendSizeEvent()
856 RECTL vRect
= wxGetWindowRect(GetHwnd());
858 (void)::WinPostMsg( m_hFrame
860 ,MPFROM2SHORT(vRect
.xRight
- vRect
.xLeft
, vRect
.yTop
- vRect
.yBottom
)
861 ,MPFROM2SHORT(vRect
.xRight
- vRect
.xLeft
, vRect
.yTop
- vRect
.yBottom
)
864 } // end of wxTopLevelWindowOS2::SendSizeEvent
866 // ----------------------------------------------------------------------------
867 // wxTopLevelWindowOS2 fullscreen
868 // ----------------------------------------------------------------------------
870 bool wxTopLevelWindowOS2::ShowFullScreen(
880 m_bFsIsShowing
= TRUE
;
884 // Zap the frame borders
888 // Save the 'normal' window lStyle
890 m_lFsOldWindowStyle
= ::WinQueryWindowULong( (HWND
)GetHWND()
895 // Save the old position, width & height, maximize state
897 m_vFsOldSize
= GetRect();
898 m_bFsIsMaximized
= IsMaximized();
901 // Decide which window lStyle flags to turn off
903 LONG lNewStyle
= m_lFsOldWindowStyle
;
906 if (lStyle
& wxFULLSCREEN_NOBORDER
)
907 lOffFlags
|= FCF_BORDER
;
908 if (lStyle
& wxFULLSCREEN_NOCAPTION
)
909 lOffFlags
|= (FCF_TASKLIST
| FCF_SYSMENU
);
911 lNewStyle
&= (~lOffFlags
);
914 // Change our window style to be compatible with full-screen mode
916 ::WinSetWindowULong( (HWND
)GetHWND()
922 // Resize to the size of the desktop
926 RECTL vRect
= wxGetWindowRect(HWND_DESKTOP
);
928 nWidth
= vRect
.xRight
- vRect
.xLeft
;
929 nHeight
= vRect
.yTop
- vRect
.yBottom
;
936 // Now flush the window style cache and actually go full-screen
938 ::WinSetWindowPos( m_hFrame
947 wxSizeEvent
vEvent( wxSize( nWidth
953 GetEventHandler()->ProcessEvent(vEvent
);
961 m_bFsIsShowing
= FALSE
;
962 Maximize(m_bFsIsMaximized
);
963 ::WinSetWindowULong( (HWND
)GetHWND()
967 ::WinSetWindowPos( m_hFrame
977 } // end of wxTopLevelWindowOS2::ShowFullScreen
979 // ----------------------------------------------------------------------------
980 // wxTopLevelWindowOS2 misc
981 // ----------------------------------------------------------------------------
983 void wxTopLevelWindowOS2::SetIcon(
987 SetIcons(wxIconBundle(rIcon
));
988 } // end of wxTopLevelWindowOS2::SetIcon
990 void wxTopLevelWindowOS2::SetIcons(
991 const wxIconBundle
& rIcons
997 wxTopLevelWindowBase::SetIcons(rIcons
);
999 const wxIcon
& vIcon
= rIcons
.GetIcon(wxSize(32, 32));
1001 if (vIcon
.Ok() && vIcon
.GetWidth() == 32 && vIcon
.GetHeight() == 32)
1003 ::WinSendMsg( m_hFrame
1005 ,(MPARAM
)((HPOINTER
)vIcon
.GetHICON())
1008 ::WinSendMsg( m_hFrame
1014 } // end of wxTopLevelWindowOS2::SetIcon
1016 bool wxTopLevelWindowOS2::EnableCloseButton(
1021 // Get system (a.k.a. window) menu
1023 HMENU hMenu
= ::WinWindowFromID(m_hFrame
, FID_SYSMENU
);
1027 wxLogLastError(_T("GetSystemMenu"));
1032 // Enabling/disabling the close item from it also automatically
1033 // disables/enables the close title bar button
1036 (void)::WinSendMsg( hMenu
1038 ,MPFROM2SHORT(SC_CLOSE
, FALSE
)
1039 ,MPFROM2SHORT(MIA_DISABLED
, FALSE
)
1042 (void)::WinSendMsg( hMenu
1044 ,MPFROM2SHORT(SC_CLOSE
, FALSE
)
1045 ,MPFROM2SHORT(MIA_DISABLED
, MIA_DISABLED
)
1049 // Update appearance immediately
1051 ::WinSendMsg( m_hFrame
1057 } // end of wxTopLevelWindowOS2::EnableCloseButton
1059 // ============================================================================
1060 // wxTLWHiddenParentModule implementation
1061 // ============================================================================
1063 HWND
wxTLWHiddenParentModule::m_shWnd
= NULL
;
1064 const wxChar
* wxTLWHiddenParentModule::m_szClassName
= NULL
;
1066 bool wxTLWHiddenParentModule::OnInit()
1069 m_szClassName
= NULL
;
1071 } // end of wxTLWHiddenParentModule::OnInit
1073 void wxTLWHiddenParentModule::OnExit()
1077 if (!::WinDestroyWindow(m_shWnd
))
1079 wxLogLastError(_T("DestroyWindow(hidden TLW parent)"));
1084 m_szClassName
= NULL
;
1085 } // end of wxTLWHiddenParentModule::OnExit
1088 HWND
wxTLWHiddenParentModule::GetHWND()
1094 static const wxChar
* zHIDDEN_PARENT_CLASS
= _T("wxTLWHiddenParent");
1096 if (!::WinRegisterClass( wxGetInstance()
1097 ,zHIDDEN_PARENT_CLASS
1103 wxLogLastError(_T("RegisterClass(\"wxTLWHiddenParent\")"));
1107 m_szClassName
= zHIDDEN_PARENT_CLASS
;
1110 m_shWnd
= ::WinCreateWindow( HWND_DESKTOP
1126 wxLogLastError(_T("CreateWindow(hidden TLW parent)"));
1130 } // end of wxTLWHiddenParentModule::GetHWND