1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: src/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()
37 #include "wx/settings.h"
40 #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
= (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 SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_APPWORKSPACE
));
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( const wxString
& rsTitle
,
440 const wxSize
& rSize
)
443 WXDWORD lFlags
= OS2GetCreateWindowFlags(&lExflags
);
444 long lStyle
= GetWindowStyleFlag();
447 int nWidth
= rSize
.x
;
448 int nHeight
= rSize
.y
;
449 ULONG ulStyleFlags
= 0L;
452 wxWindow
* pParent
= GetParent();
458 hParent
= GetHwndOf(pParent
);
460 hParent
= HWND_DESKTOP
;
462 if ((lStyle
& wxMINIMIZE
) || (lStyle
& wxICONIZE
))
463 ulStyleFlags
|= WS_MINIMIZED
;
464 if (lStyle
& wxMAXIMIZE
)
465 ulStyleFlags
|= WS_MAXIMIZED
;
468 // Clear the visible flag, we always call show
470 ulStyleFlags
&= (unsigned long)~WS_VISIBLE
;
474 // Create the frame window: We break ranks with other ports now
475 // and instead of calling down into the base wxWindow class' OS2Create
476 // we do all our own stuff here. We will set the needed pieces
477 // of wxWindow manually, here.
480 hFrame
= ::WinCreateStdWindow( hParent
481 ,ulStyleFlags
// frame-window style
482 ,(PULONG
)&lFlags
// window style
483 ,(PSZ
)wxFrameClassName
// class name
484 ,(PSZ
)rsTitle
.c_str() // window title
485 ,0L // default client style
486 ,NULLHANDLE
// resource in executable file
488 ,&hClient
// receives client window handle
492 vError
= ::WinGetLastError(vHabmain
);
493 sError
= wxPMErrorToStr(vError
);
494 wxLogError(_T("Error creating frame. Error: %s\n"), sError
.c_str());
499 // wxWindow class' m_hWnd set here and needed associations
503 wxAssociateWinWithHandle(m_hWnd
, this);
504 wxAssociateWinWithHandle(m_hFrame
, this);
506 SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_APPWORKSPACE
));
508 LONG lColor
= (LONG
)m_backgroundColour
.GetPixel();
510 if (!::WinSetPresParam( m_hWnd
516 vError
= ::WinGetLastError(vHabmain
);
517 sError
= wxPMErrorToStr(vError
);
518 wxLogError(_T("Error creating frame. Error: %s\n"), sError
.c_str());
523 // Now need to subclass window. Instead of calling the SubClassWin in wxWindow
524 // we manually subclass here because we don't want to use the main wxWndProc
527 m_fnOldWndProc
= (WXFARPROC
) ::WinSubclassWindow(m_hFrame
, (PFNWP
)wxFrameMainWndProc
);
530 // Now size everything. If adding a menu the client will need to be resized.
535 nY
= pParent
->GetSize().y
- (nY
+ nHeight
);
541 ::WinQueryWindowRect(HWND_DESKTOP
, &vRect
);
542 nY
= vRect
.yTop
- (nY
+ nHeight
);
544 if (!::WinSetWindowPos( m_hFrame
550 ,SWP_SIZE
| SWP_MOVE
| SWP_ACTIVATE
| SWP_ZORDER
553 vError
= ::WinGetLastError(vHabmain
);
554 sError
= wxPMErrorToStr(vError
);
555 wxLogError(_T("Error sizing frame. Error: %s\n"), sError
.c_str());
558 lStyle
= ::WinQueryWindowULong( m_hWnd
561 lStyle
|= WS_CLIPCHILDREN
;
562 ::WinSetWindowULong( m_hWnd
567 } // end of wxTopLevelWindowOS2::CreateFrame
569 bool wxTopLevelWindowOS2::Create(
572 , const wxString
& rsTitle
573 , const wxPoint
& rPos
574 , const wxSize
& rSizeOrig
576 , const wxString
& rsName
583 m_windowStyle
= lStyle
;
585 m_windowId
= vId
== -1 ? NewControlId() : vId
;
587 // always create a frame of some reasonable, even if arbitrary, size (at
588 // least for MSW compatibility)
589 wxSize rSize
= rSizeOrig
;
590 if ( rSize
.x
== -1 || rSize
.y
== -1 )
592 wxSize sizeDpy
= wxGetDisplaySize();
594 rSize
.x
= sizeDpy
.x
/ 3;
596 rSize
.y
= sizeDpy
.y
/ 5;
599 wxTopLevelWindows
.Append(this);
601 pParent
->AddChild(this);
603 if (GetExtraStyle() & wxTOPLEVEL_EX_DIALOG
)
606 // We have different dialog templates to allow creation of dialogs
607 // with & without captions under OS2indows, resizeable or not (but a
608 // resizeable dialog always has caption - otherwise it would look too
613 if (lStyle
& wxRESIZE_BORDER
)
614 ulDlgTemplate
= (ULONG
)kResizeableDialog
;
615 else if (lStyle
& wxCAPTION
)
616 ulDlgTemplate
= (ULONG
)kCaptionDialog
;
618 ulDlgTemplate
= (ULONG
)kNoCaptionDialog
;
619 return CreateDialog( ulDlgTemplate
627 return CreateFrame( rsTitle
632 } // end of wxTopLevelWindowOS2::Create
634 wxTopLevelWindowOS2::~wxTopLevelWindowOS2()
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( bool bShow
)
719 if (bShow
!= IsShown() )
729 if (m_bMaximizeOnShow
)
731 nShowCmd
= SWP_MAXIMIZE
;
732 m_bMaximizeOnShow
= false;
743 DoShowWindow(nShowCmd
);
747 wxActivateEvent
vEvent(wxEVT_ACTIVATE
, true, m_windowId
);
749 ::WinQueryWindowPos(m_hFrame
, &vSwp
);
750 m_bIconized
= ( vSwp
.fl
& SWP_MINIMIZE
) == SWP_MINIMIZE
;
751 ::WinQueryWindowPos(m_hWnd
, &m_vSwpClient
);
752 ::WinSendMsg(m_hFrame
, WM_UPDATEFRAME
, (MPARAM
)~0, 0);
753 ::WinQueryWindowPos(m_hWnd
, &vSwp
);
754 ::WinEnableWindow(m_hFrame
, TRUE
);
757 // Deal with children
759 MoveChildren(m_vSwpClient
.cy
- vSwp
.cy
);
760 vEvent
.SetEventObject(this);
761 GetEventHandler()->ProcessEvent(vEvent
);
766 // Try to highlight the correct window (the parent)
770 HWND hWndParent
= GetHwndOf(GetParent());
772 ::WinQueryWindowPos(hWndParent
, &vSwp
);
773 m_bIconized
= (vSwp
.fl
& SWP_MINIMIZE
)==SWP_MINIMIZE
;
774 ::WinEnableWindow(hWndParent
, TRUE
);
778 } // end of wxTopLevelWindowOS2::Show
780 // ----------------------------------------------------------------------------
781 // wxTopLevelWindowOS2 maximize/minimize
782 // ----------------------------------------------------------------------------
784 void wxTopLevelWindowOS2::Maximize(
791 // Just maximize it directly
793 DoShowWindow(bMaximize
? SWP_MAXIMIZE
: SWP_RESTORE
);
798 // We can't maximize the hidden frame because it shows it as well, so
799 // just remember that we should do it later in this case
801 m_bMaximizeOnShow
= bMaximize
;
803 } // end of wxTopLevelWindowOS2::Maximize
805 bool wxTopLevelWindowOS2::IsMaximized() const
807 ::WinQueryWindowPos(m_hFrame
, (PSWP
)&m_vSwp
);
808 return (m_vSwp
.fl
& SWP_MAXIMIZE
) == SWP_MAXIMIZE
;
809 } // end of wxTopLevelWindowOS2::IsMaximized
811 void wxTopLevelWindowOS2::SetTitle( const wxString
& title
)
816 wxString
wxTopLevelWindowOS2::GetTitle() const
821 void wxTopLevelWindowOS2::Iconize( bool bIconize
)
823 DoShowWindow(bIconize
? SWP_MINIMIZE
: SWP_RESTORE
);
824 } // end of wxTopLevelWindowOS2::Iconize
826 bool wxTopLevelWindowOS2::IsIconized() const
828 // also update the current state
829 ::WinQueryWindowPos(m_hFrame
, (PSWP
)&m_vSwp
);
830 if (m_vSwp
.fl
& SWP_MINIMIZE
)
831 ((wxTopLevelWindow
*)this)->m_bIconized
= true;
833 ((wxTopLevelWindow
*)this)->m_bIconized
= false;
835 } // end of wxTopLevelWindowOS2::IsIconized
837 void wxTopLevelWindowOS2::Restore()
839 DoShowWindow(SWP_RESTORE
);
840 } // end of wxTopLevelWindowOS2::Restore
842 // generate an artificial resize event
843 void wxTopLevelWindowOS2::SendSizeEvent()
847 RECTL vRect
= wxGetWindowRect(GetHwnd());
849 (void)::WinPostMsg( m_hFrame
851 ,MPFROM2SHORT(vRect
.xRight
- vRect
.xLeft
, vRect
.yTop
- vRect
.yBottom
)
852 ,MPFROM2SHORT(vRect
.xRight
- vRect
.xLeft
, vRect
.yTop
- vRect
.yBottom
)
855 } // end of wxTopLevelWindowOS2::SendSizeEvent
857 // ----------------------------------------------------------------------------
858 // wxTopLevelWindowOS2 fullscreen
859 // ----------------------------------------------------------------------------
861 bool wxTopLevelWindowOS2::ShowFullScreen( bool bShow
,
869 m_bFsIsShowing
= true;
873 // Zap the frame borders
877 // Save the 'normal' window lStyle
879 m_lFsOldWindowStyle
= ::WinQueryWindowULong( (HWND
)GetHWND()
884 // Save the old position, width & height, maximize state
886 m_vFsOldSize
= GetRect();
887 m_bFsIsMaximized
= IsMaximized();
890 // Decide which window lStyle flags to turn off
892 LONG lNewStyle
= m_lFsOldWindowStyle
;
895 if (lStyle
& wxFULLSCREEN_NOBORDER
)
896 lOffFlags
|= FCF_BORDER
;
897 if (lStyle
& wxFULLSCREEN_NOCAPTION
)
898 lOffFlags
|= (FCF_TASKLIST
| FCF_SYSMENU
);
900 lNewStyle
&= (~lOffFlags
);
903 // Change our window style to be compatible with full-screen mode
905 ::WinSetWindowULong( (HWND
)GetHWND()
911 // Resize to the size of the desktop
915 RECTL vRect
= wxGetWindowRect(HWND_DESKTOP
);
917 nWidth
= vRect
.xRight
- vRect
.xLeft
;
918 nHeight
= vRect
.yTop
- vRect
.yBottom
;
920 SetSize( nWidth
, nHeight
);
923 // Now flush the window style cache and actually go full-screen
925 ::WinSetWindowPos( m_hFrame
934 wxSize
full( nWidth
, nHeight
);
935 wxSizeEvent
vEvent( full
, GetId() );
936 GetEventHandler()->ProcessEvent(vEvent
);
944 m_bFsIsShowing
= false;
945 Maximize(m_bFsIsMaximized
);
946 ::WinSetWindowULong( (HWND
)GetHWND()
950 ::WinSetWindowPos( m_hFrame
960 } // end of wxTopLevelWindowOS2::ShowFullScreen
962 // ----------------------------------------------------------------------------
963 // wxTopLevelWindowOS2 misc
964 // ----------------------------------------------------------------------------
966 void wxTopLevelWindowOS2::SetIcon(
970 SetIcons(wxIconBundle(rIcon
));
971 } // end of wxTopLevelWindowOS2::SetIcon
973 void wxTopLevelWindowOS2::SetIcons(
974 const wxIconBundle
& rIcons
980 wxTopLevelWindowBase::SetIcons(rIcons
);
982 const wxIcon
& vIcon
= rIcons
.GetIcon(wxSize(32, 32));
984 if (vIcon
.Ok() && vIcon
.GetWidth() == 32 && vIcon
.GetHeight() == 32)
986 ::WinSendMsg( m_hFrame
988 ,(MPARAM
)((HPOINTER
)vIcon
.GetHICON())
991 ::WinSendMsg( m_hFrame
997 } // end of wxTopLevelWindowOS2::SetIcon
999 bool wxTopLevelWindowOS2::EnableCloseButton( bool bEnable
)
1002 // Get system (a.k.a. window) menu
1004 HMENU hMenu
= ::WinWindowFromID(m_hFrame
, FID_SYSMENU
);
1008 wxLogLastError(_T("GetSystemMenu"));
1013 // Enabling/disabling the close item from it also automatically
1014 // disables/enables the close title bar button
1017 (void)::WinSendMsg( hMenu
1019 ,MPFROM2SHORT(SC_CLOSE
, FALSE
)
1020 ,MPFROM2SHORT(MIA_DISABLED
, FALSE
)
1023 (void)::WinSendMsg( hMenu
1025 ,MPFROM2SHORT(SC_CLOSE
, FALSE
)
1026 ,MPFROM2SHORT(MIA_DISABLED
, MIA_DISABLED
)
1030 // Update appearance immediately
1032 ::WinSendMsg( m_hFrame
1038 } // end of wxTopLevelWindowOS2::EnableCloseButton
1040 // ============================================================================
1041 // wxTLWHiddenParentModule implementation
1042 // ============================================================================
1044 HWND
wxTLWHiddenParentModule::m_shWnd
= NULL
;
1045 const wxChar
* wxTLWHiddenParentModule::m_szClassName
= NULL
;
1047 bool wxTLWHiddenParentModule::OnInit()
1050 m_szClassName
= NULL
;
1052 } // end of wxTLWHiddenParentModule::OnInit
1054 void wxTLWHiddenParentModule::OnExit()
1058 if (!::WinDestroyWindow(m_shWnd
))
1060 wxLogLastError(_T("DestroyWindow(hidden TLW parent)"));
1065 m_szClassName
= NULL
;
1066 } // end of wxTLWHiddenParentModule::OnExit
1069 HWND
wxTLWHiddenParentModule::GetHWND()
1075 static const wxChar
* zHIDDEN_PARENT_CLASS
= _T("wxTLWHiddenParent");
1077 if (!::WinRegisterClass( wxGetInstance()
1078 ,(PSZ
)zHIDDEN_PARENT_CLASS
1084 wxLogLastError(_T("RegisterClass(\"wxTLWHiddenParent\")"));
1088 m_szClassName
= zHIDDEN_PARENT_CLASS
;
1091 m_shWnd
= ::WinCreateWindow( HWND_DESKTOP
,
1106 wxLogLastError(_T("CreateWindow(hidden TLW parent)"));
1110 } // end of wxTLWHiddenParentModule::GetHWND