]>
git.saurik.com Git - wxWidgets.git/blob - src/os2/toplevel.cpp
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: 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()
39 #include "wx/module.h" // wxSetFocusToChild()
40 #include "wx/os2/private.h"
42 // ----------------------------------------------------------------------------
43 // stubs for missing functions under MicroWindows
44 // ----------------------------------------------------------------------------
47 // ----------------------------------------------------------------------------
49 // ----------------------------------------------------------------------------
51 // the name of the default wxWidgets class
52 extern void wxAssociateWinWithHandle( HWND hWnd
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 m_backgroundColour
.Set(wxString(wxT("LIGHT GREY")));
413 LONG lColor
= (LONG
)m_backgroundColour
.GetPixel();
415 if (!::WinSetPresParam( m_hWnd
424 ::WinSetWindowPos( GetHwnd()
430 ,SWP_MOVE
| SWP_SIZE
| SWP_ZORDER
| SWP_SHOW
| SWP_ACTIVATE
432 ::WinQueryWindowPos(GetHwnd(), GetSwp());
436 } // end of wxTopLevelWindowOS2::CreateDialog
438 bool wxTopLevelWindowOS2::CreateFrame(
439 const wxString
& rsTitle
440 , const wxPoint
& rPos
441 , const wxSize
& rSize
445 WXDWORD lFlags
= OS2GetCreateWindowFlags(&lExflags
);
446 long lStyle
= GetWindowStyleFlag();
449 int nWidth
= rSize
.x
;
450 int nHeight
= rSize
.y
;
451 ULONG ulStyleFlags
= 0L;
454 wxWindow
* pParent
= GetParent();
460 hParent
= GetHwndOf(pParent
);
462 hParent
= HWND_DESKTOP
;
464 if ((lStyle
& wxMINIMIZE
) || (lStyle
& wxICONIZE
))
465 ulStyleFlags
|= WS_MINIMIZED
;
466 if (lStyle
& wxMAXIMIZE
)
467 ulStyleFlags
|= WS_MAXIMIZED
;
470 // Clear the visible flag, we always call show
472 ulStyleFlags
&= (unsigned long)~WS_VISIBLE
;
476 // Create the frame window: We break ranks with other ports now
477 // and instead of calling down into the base wxWindow class' OS2Create
478 // we do all our own stuff here. We will set the needed pieces
479 // of wxWindow manually, here.
482 hFrame
= ::WinCreateStdWindow( hParent
483 ,ulStyleFlags
// frame-window style
484 ,(PULONG
)&lFlags
// window style
485 ,(PSZ
)wxFrameClassName
// class name
486 ,(PSZ
)rsTitle
.c_str() // window title
487 ,0L // default client style
488 ,NULLHANDLE
// resource in executable file
490 ,&hClient
// receives client window handle
494 vError
= ::WinGetLastError(vHabmain
);
495 sError
= wxPMErrorToStr(vError
);
496 wxLogError(_T("Error creating frame. Error: %s\n"), sError
.c_str());
501 // wxWindow class' m_hWnd set here and needed associations
505 wxAssociateWinWithHandle(m_hWnd
, this);
506 wxAssociateWinWithHandle(m_hFrame
, this);
508 m_backgroundColour
.Set(wxString(wxT("MEDIUM GREY")));
510 LONG lColor
= (LONG
)m_backgroundColour
.GetPixel();
512 if (!::WinSetPresParam( m_hWnd
518 vError
= ::WinGetLastError(vHabmain
);
519 sError
= wxPMErrorToStr(vError
);
520 wxLogError(_T("Error creating frame. Error: %s\n"), sError
.c_str());
525 // Now need to subclass window. Instead of calling the SubClassWin in wxWindow
526 // we manually subclass here because we don't want to use the main wxWndProc
529 m_fnOldWndProc
= (WXFARPROC
) ::WinSubclassWindow(m_hFrame
, (PFNWP
)wxFrameMainWndProc
);
532 // Now size everything. If adding a menu the client will need to be resized.
537 nY
= pParent
->GetSize().y
- (nY
+ nHeight
);
543 ::WinQueryWindowRect(HWND_DESKTOP
, &vRect
);
544 nY
= vRect
.yTop
- (nY
+ nHeight
);
546 if (!::WinSetWindowPos( m_hFrame
552 ,SWP_SIZE
| SWP_MOVE
| SWP_ACTIVATE
| SWP_ZORDER
555 vError
= ::WinGetLastError(vHabmain
);
556 sError
= wxPMErrorToStr(vError
);
557 wxLogError(_T("Error sizing frame. Error: %s\n"), sError
.c_str());
560 lStyle
= ::WinQueryWindowULong( m_hWnd
563 lStyle
|= WS_CLIPCHILDREN
;
564 ::WinSetWindowULong( m_hWnd
569 } // end of wxTopLevelWindowOS2::CreateFrame
571 bool wxTopLevelWindowOS2::Create(
574 , const wxString
& rsTitle
575 , const wxPoint
& rPos
576 , const wxSize
& rSizeOrig
578 , const wxString
& rsName
585 m_windowStyle
= lStyle
;
587 m_windowId
= vId
== -1 ? NewControlId() : vId
;
589 // always create a frame of some reasonable, even if arbitrary, size (at
590 // least for MSW compatibility)
591 wxSize rSize
= rSizeOrig
;
592 if ( rSize
.x
== -1 || rSize
.y
== -1 )
594 wxSize sizeDpy
= wxGetDisplaySize();
596 rSize
.x
= sizeDpy
.x
/ 3;
598 rSize
.y
= sizeDpy
.y
/ 5;
601 wxTopLevelWindows
.Append(this);
603 pParent
->AddChild(this);
605 if (GetExtraStyle() & wxTOPLEVEL_EX_DIALOG
)
608 // We have different dialog templates to allows creation of dialogs
609 // with & without captions under OS2indows, resizeable or not (but a
610 // resizeable dialog always has caption - otherwise it would look too
615 if (lStyle
& wxRESIZE_BORDER
)
616 ulDlgTemplate
= (ULONG
)kResizeableDialog
;
617 else if (lStyle
& wxCAPTION
)
618 ulDlgTemplate
= (ULONG
)kCaptionDialog
;
620 ulDlgTemplate
= (ULONG
)kNoCaptionDialog
;
621 return CreateDialog( ulDlgTemplate
629 return CreateFrame( rsTitle
634 } // end of wxTopLevelWindowOS2::Create
636 wxTopLevelWindowOS2::~wxTopLevelWindowOS2()
639 // After destroying an owned window, Windows activates the next top level
640 // window in Z order but it may be different from our owner (to reproduce
641 // this simply Alt-TAB to another application and back before closing the
642 // owned frame) whereas we always want to yield activation to our parent
644 if (HasFlag(wxFRAME_FLOAT_ON_PARENT
))
646 wxWindow
* pParent
= GetParent();
650 ::WinSetWindowPos( GetHwndOf(pParent
)
657 } // end of wxTopLevelWindowOS2::~wxTopLevelWindowOS2
659 // ----------------------------------------------------------------------------
660 // wxTopLevelWindowOS2 client size
661 // ----------------------------------------------------------------------------
663 void wxTopLevelWindowOS2::DoSetClientSize(
669 // Call GetClientAreaOrigin() to take the toolbar into account
671 wxPoint vPt
= GetClientAreaOrigin();
676 wxWindow::DoSetClientSize( nWidth
679 } // end of wxTopLevelWindowOS2::DoSetClientSize
681 void wxTopLevelWindowOS2::DoGetClientSize(
686 wxWindow::DoGetClientSize( pnX
690 wxPoint vPt
= GetClientAreaOrigin();
697 } // end of wxTopLevelWindowOS2::DoGetClientSize
699 // ----------------------------------------------------------------------------
700 // wxTopLevelWindowOS2 showing
701 // ----------------------------------------------------------------------------
703 void wxTopLevelWindowOS2::DoShowWindow(
707 ::WinShowWindow(m_hFrame
, (BOOL
)(nShowCmd
& SWP_SHOW
));
710 // Need to artificially send a size event as wxApps often expect to do some
711 // final child control sizing
713 m_bIconized
= nShowCmd
== SWP_MINIMIZE
;
714 } // end of wxTopLevelWindowOS2::DoShowWindow
716 bool wxTopLevelWindowOS2::Show(
723 if (bShow
!= IsShown() )
733 if (m_bMaximizeOnShow
)
735 nShowCmd
= SWP_MAXIMIZE
;
736 m_bMaximizeOnShow
= FALSE
;
747 DoShowWindow(nShowCmd
);
751 wxActivateEvent
vEvent(wxEVT_ACTIVATE
, TRUE
, m_windowId
);
753 ::WinQueryWindowPos(m_hFrame
, &vSwp
);
754 m_bIconized
= ( vSwp
.fl
& SWP_MINIMIZE
) == SWP_MINIMIZE
;
755 ::WinQueryWindowPos(m_hWnd
, &m_vSwpClient
);
756 ::WinSendMsg(m_hFrame
, WM_UPDATEFRAME
, (MPARAM
)~0, 0);
757 ::WinQueryWindowPos(m_hWnd
, &vSwp
);
758 ::WinEnableWindow(m_hFrame
, TRUE
);
761 // Deal with children
763 MoveChildren(m_vSwpClient
.cy
- vSwp
.cy
);
764 vEvent
.SetEventObject(this);
765 GetEventHandler()->ProcessEvent(vEvent
);
770 // Try to highlight the correct window (the parent)
774 HWND hWndParent
= GetHwndOf(GetParent());
776 ::WinQueryWindowPos(hWndParent
, &vSwp
);
777 m_bIconized
= (vSwp
.fl
& SWP_MINIMIZE
)==SWP_MINIMIZE
;
778 ::WinEnableWindow(hWndParent
, TRUE
);
782 } // end of wxTopLevelWindowOS2::Show
784 // ----------------------------------------------------------------------------
785 // wxTopLevelWindowOS2 maximize/minimize
786 // ----------------------------------------------------------------------------
788 void wxTopLevelWindowOS2::Maximize(
795 // Just maximize it directly
797 DoShowWindow(bMaximize
? SWP_MAXIMIZE
: SWP_RESTORE
);
802 // We can't maximize the hidden frame because it shows it as well, so
803 // just remember that we should do it later in this case
805 m_bMaximizeOnShow
= bMaximize
;
807 } // end of wxTopLevelWindowOS2::Maximize
809 bool wxTopLevelWindowOS2::IsMaximized() const
811 ::WinQueryWindowPos(m_hFrame
, (PSWP
)&m_vSwp
);
812 return (m_vSwp
.fl
& SWP_MAXIMIZE
) == 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( bool bShow
,
865 m_bFsIsShowing
= true;
869 // Zap the frame borders
873 // Save the 'normal' window lStyle
875 m_lFsOldWindowStyle
= ::WinQueryWindowULong( (HWND
)GetHWND()
880 // Save the old position, width & height, maximize state
882 m_vFsOldSize
= GetRect();
883 m_bFsIsMaximized
= IsMaximized();
886 // Decide which window lStyle flags to turn off
888 LONG lNewStyle
= m_lFsOldWindowStyle
;
891 if (lStyle
& wxFULLSCREEN_NOBORDER
)
892 lOffFlags
|= FCF_BORDER
;
893 if (lStyle
& wxFULLSCREEN_NOCAPTION
)
894 lOffFlags
|= (FCF_TASKLIST
| FCF_SYSMENU
);
896 lNewStyle
&= (~lOffFlags
);
899 // Change our window style to be compatible with full-screen mode
901 ::WinSetWindowULong( (HWND
)GetHWND()
907 // Resize to the size of the desktop
911 RECTL vRect
= wxGetWindowRect(HWND_DESKTOP
);
913 nWidth
= vRect
.xRight
- vRect
.xLeft
;
914 nHeight
= vRect
.yTop
- vRect
.yBottom
;
916 SetSize( nWidth
, nHeight
);
919 // Now flush the window style cache and actually go full-screen
921 ::WinSetWindowPos( m_hFrame
930 wxSize
full( nWidth
, nHeight
);
931 wxSizeEvent
vEvent( full
, GetId() );
932 GetEventHandler()->ProcessEvent(vEvent
);
940 m_bFsIsShowing
= false;
941 Maximize(m_bFsIsMaximized
);
942 ::WinSetWindowULong( (HWND
)GetHWND()
946 ::WinSetWindowPos( m_hFrame
956 } // end of wxTopLevelWindowOS2::ShowFullScreen
958 // ----------------------------------------------------------------------------
959 // wxTopLevelWindowOS2 misc
960 // ----------------------------------------------------------------------------
962 void wxTopLevelWindowOS2::SetIcon(
966 SetIcons(wxIconBundle(rIcon
));
967 } // end of wxTopLevelWindowOS2::SetIcon
969 void wxTopLevelWindowOS2::SetIcons(
970 const wxIconBundle
& rIcons
976 wxTopLevelWindowBase::SetIcons(rIcons
);
978 const wxIcon
& vIcon
= rIcons
.GetIcon(wxSize(32, 32));
980 if (vIcon
.Ok() && vIcon
.GetWidth() == 32 && vIcon
.GetHeight() == 32)
982 ::WinSendMsg( m_hFrame
984 ,(MPARAM
)((HPOINTER
)vIcon
.GetHICON())
987 ::WinSendMsg( m_hFrame
993 } // end of wxTopLevelWindowOS2::SetIcon
995 bool wxTopLevelWindowOS2::EnableCloseButton(
1000 // Get system (a.k.a. window) menu
1002 HMENU hMenu
= ::WinWindowFromID(m_hFrame
, FID_SYSMENU
);
1006 wxLogLastError(_T("GetSystemMenu"));
1011 // Enabling/disabling the close item from it also automatically
1012 // disables/enables the close title bar button
1015 (void)::WinSendMsg( hMenu
1017 ,MPFROM2SHORT(SC_CLOSE
, FALSE
)
1018 ,MPFROM2SHORT(MIA_DISABLED
, FALSE
)
1021 (void)::WinSendMsg( hMenu
1023 ,MPFROM2SHORT(SC_CLOSE
, FALSE
)
1024 ,MPFROM2SHORT(MIA_DISABLED
, MIA_DISABLED
)
1028 // Update appearance immediately
1030 ::WinSendMsg( m_hFrame
1036 } // end of wxTopLevelWindowOS2::EnableCloseButton
1038 // ============================================================================
1039 // wxTLWHiddenParentModule implementation
1040 // ============================================================================
1042 HWND
wxTLWHiddenParentModule::m_shWnd
= NULL
;
1043 const wxChar
* wxTLWHiddenParentModule::m_szClassName
= NULL
;
1045 bool wxTLWHiddenParentModule::OnInit()
1048 m_szClassName
= NULL
;
1050 } // end of wxTLWHiddenParentModule::OnInit
1052 void wxTLWHiddenParentModule::OnExit()
1056 if (!::WinDestroyWindow(m_shWnd
))
1058 wxLogLastError(_T("DestroyWindow(hidden TLW parent)"));
1063 m_szClassName
= NULL
;
1064 } // end of wxTLWHiddenParentModule::OnExit
1067 HWND
wxTLWHiddenParentModule::GetHWND()
1073 static const wxChar
* zHIDDEN_PARENT_CLASS
= _T("wxTLWHiddenParent");
1075 if (!::WinRegisterClass( wxGetInstance()
1076 ,(PSZ
)zHIDDEN_PARENT_CLASS
1082 wxLogLastError(_T("RegisterClass(\"wxTLWHiddenParent\")"));
1086 m_szClassName
= zHIDDEN_PARENT_CLASS
;
1089 m_shWnd
= ::WinCreateWindow( HWND_DESKTOP
1105 wxLogLastError(_T("CreateWindow(hidden TLW parent)"));
1109 } // end of wxTLWHiddenParentModule::GetHWND