]>
git.saurik.com Git - wxWidgets.git/blob - src/os2/toplevel.cpp
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()
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
, wxWindowOS2
* pWin
);
54 bool wxTopLevelWindowOS2::m_sbInitialized
= false;
55 wxWindow
* wxTopLevelWindowOS2::m_spHiddenParent
= NULL
;
57 // ============================================================================
58 // wxTopLevelWindowOS2 implementation
59 // ============================================================================
61 BEGIN_EVENT_TABLE(wxTopLevelWindowOS2
, wxTopLevelWindowBase
)
62 EVT_ACTIVATE(wxTopLevelWindowOS2::OnActivate
)
65 // ============================================================================
66 // wxTopLevelWindowMSW implementation
67 // ============================================================================
70 MRESULT EXPENTRY
wxDlgProc( HWND
WXUNUSED(hWnd
)
72 ,void * WXUNUSED(wParam
)
73 ,void * WXUNUSED(lParam
)
80 // For this message, returning TRUE tells system to set focus to
81 // the first control in the dialog box, but we set the focus
82 // ourselves, however in OS/2 we must return true to enable the dialog
87 // For all the other ones, FALSE means that we didn't process the
90 return (MRESULT
)FALSE
;
94 // ----------------------------------------------------------------------------
95 // wxTLWHiddenParentModule: used to manage the hidden parent window (we need a
96 // module to ensure that the window is always deleted)
97 // ----------------------------------------------------------------------------
99 class wxTLWHiddenParentModule
: public wxModule
103 // Module init/finalize
105 virtual bool OnInit(void);
106 virtual void OnExit(void);
109 // Get the hidden window (creates on demand)
111 static HWND
GetHWND(void);
115 // The HWND of the hidden parent
120 // The class used to create it
122 static const wxChar
* m_szClassName
;
123 DECLARE_DYNAMIC_CLASS(wxTLWHiddenParentModule
)
124 }; // end of CLASS wxTLWHiddenParentModule
126 IMPLEMENT_DYNAMIC_CLASS(wxTLWHiddenParentModule
, wxModule
)
128 // ----------------------------------------------------------------------------
129 // wxTopLevelWindowOS2 creation
130 // ----------------------------------------------------------------------------
132 void wxTopLevelWindowOS2::Init()
134 m_bIconized
= m_bMaximizeOnShow
= false;
137 // Unlike (almost?) all other windows, frames are created hidden
142 // Data to save/restore when calling ShowFullScreen
144 m_lFsOldWindowStyle
= 0;
145 m_bFsIsMaximized
= false;
146 m_bFsIsShowing
= false;
148 m_hFrame
= NULLHANDLE
;
149 memset(&m_vSwp
, 0, sizeof(SWP
));
150 memset(&m_vSwpClient
, 0, sizeof(SWP
));
151 m_pWinLastFocused
= (wxWindow
*)NULL
;
152 } // end of wxTopLevelWindowIOS2::Init
154 void wxTopLevelWindowOS2::OnActivate(
155 wxActivateEvent
& rEvent
158 if (rEvent
.GetActive())
161 // Restore focus to the child which was last focused
163 wxLogTrace(_T("focus"), _T("wxTLW %08lx activated."), m_hWnd
);
165 wxWindow
* pParent
= m_pWinLastFocused
? m_pWinLastFocused
->GetParent()
172 wxSetFocusToChild( pParent
179 // Remember the last focused child if it is our child
181 m_pWinLastFocused
= FindFocus();
184 // So we NULL it out if it's a child from some other frame
186 wxWindow
* pWin
= m_pWinLastFocused
;
190 if (pWin
->IsTopLevel())
194 m_pWinLastFocused
= NULL
;
198 pWin
= pWin
->GetParent();
201 wxLogTrace(_T("focus"),
202 _T("wxTLW %08lx deactivated, last focused: %08lx."),
204 m_pWinLastFocused
? GetHwndOf(m_pWinLastFocused
)
208 } // end of wxTopLevelWindowOS2::OnActivate
210 WXDWORD
wxTopLevelWindowOS2::OS2GetStyle(
212 , WXDWORD
* pdwExflags
215 long lMsflags
= wxWindow::OS2GetStyle( (lStyle
& ~wxBORDER_MASK
) | wxBORDER_NONE
219 if ((lStyle
& wxDEFAULT_FRAME_STYLE
) == wxDEFAULT_FRAME_STYLE
)
220 lMsflags
|= FCF_SIZEBORDER
| FCF_TITLEBAR
| FCF_SYSMENU
|
221 FCF_MINMAX
| FCF_TASKLIST
;
223 if ((lStyle
& wxCAPTION
) == wxCAPTION
)
224 lMsflags
|= FCF_TASKLIST
;
226 lMsflags
|= FCF_NOMOVEWITHOWNER
;
228 if ((lStyle
& wxVSCROLL
) == wxVSCROLL
)
229 lMsflags
|= FCF_VERTSCROLL
;
230 if ((lStyle
& wxHSCROLL
) == wxHSCROLL
)
231 lMsflags
|= FCF_HORZSCROLL
;
232 if (lStyle
& wxMINIMIZE_BOX
)
233 lMsflags
|= FCF_MINBUTTON
;
234 if (lStyle
& wxMAXIMIZE_BOX
)
235 lMsflags
|= FCF_MAXBUTTON
;
236 if (lStyle
& wxTHICK_FRAME
)
237 lMsflags
|= FCF_DLGBORDER
;
238 if (lStyle
& wxSYSTEM_MENU
)
239 lMsflags
|= FCF_SYSMENU
;
240 if (lStyle
& wxCAPTION
)
241 lMsflags
|= FCF_TASKLIST
;
242 if (lStyle
& wxCLIP_CHILDREN
)
244 // Invalid for frame windows under PM
247 if (lStyle
& wxTINY_CAPTION_VERT
)
248 lMsflags
|= FCF_TASKLIST
;
249 if (lStyle
& wxTINY_CAPTION_HORIZ
)
250 lMsflags
|= FCF_TASKLIST
;
252 if ((lStyle
& wxTHICK_FRAME
) == 0)
253 lMsflags
|= FCF_BORDER
;
254 if (lStyle
& wxFRAME_TOOL_WINDOW
)
255 *pdwExflags
= kFrameToolWindow
;
257 if (lStyle
& wxSTAY_ON_TOP
)
258 lMsflags
|= FCF_SYSMODAL
;
261 } // end of wxTopLevelWindowOS2::OS2GetCreateWindowFlags
263 WXHWND
wxTopLevelWindowOS2::OS2GetParent() const
265 HWND hWndParent
= NULL
;
268 // For the frames without wxFRAME_FLOAT_ON_PARENT style we should use NULL
269 // parent HWND or it would be always on top of its parent which is not what
270 // we usually want (in fact, we only want it for frames with the
271 // wxFRAME_FLOAT_ON_PARENT flag)
273 if (HasFlag(wxFRAME_FLOAT_ON_PARENT
) )
275 const wxWindow
* pParent
= GetParent();
280 // This flag doesn't make sense then and will be ignored
282 wxFAIL_MSG( _T("wxFRAME_FLOAT_ON_PARENT but no parent?") );
286 hWndParent
= GetHwndOf(pParent
);
289 //else: don't float on parent, must not be owned
292 // Now deal with the 2nd taskbar-related problem (see comments above in
295 if (HasFlag(wxFRAME_NO_TASKBAR
) && !hWndParent
)
300 hWndParent
= wxTLWHiddenParentModule::GetHWND();
302 return (WXHWND
)hWndParent
;
303 } // end of wxTopLevelWindowOS2::OS2GetParent
306 bool wxTopLevelWindowOS2::CreateDialog( ULONG ulDlgTemplate
,
307 const wxString
& WXUNUSED(rsTitle
),
309 const wxSize
& rSize
)
311 wxWindow
* pParent
= GetParent();
314 // For the dialogs without wxDIALOG_NO_PARENT style, use the top level
315 // app window as parent - this avoids creating modal dialogs without
318 if (!pParent
&& !(GetWindowStyleFlag() & wxDIALOG_NO_PARENT
))
320 pParent
= wxTheApp
->GetTopWindow();
325 // Don't use transient windows as parents, this is dangerous as it
326 // can lead to a crash if the parent is destroyed before the child
328 // also don't use the window which is currently hidden as then the
329 // dialog would be hidden as well
330 if ((pParent
->GetExtraStyle() & wxWS_EX_TRANSIENT
) ||
342 hWndOwner
= GetHwndOf(pParent
);
344 hWndOwner
= HWND_DESKTOP
;
346 hWndDlg
= ::WinLoadDlg( HWND_DESKTOP
350 ,(ULONG
)ulDlgTemplate
354 m_hWnd
= (WXHWND
) hWndDlg
;
358 wxFAIL_MSG(wxT("Did you forget to include wx/os2/wx.rc in your resources?"));
360 wxLogSysError(wxT("Can't create dialog using template '%ld'"), ulDlgTemplate
);
366 // Move the dialog to its initial position without forcing repainting
373 if (!OS2GetCreateWindowCoords( rPos
381 nX
= nWidth
= (int)CW_USEDEFAULT
;
385 // We can't use CW_USEDEFAULT here as we're not calling CreateWindow()
386 // and passing CW_USEDEFAULT to MoveWindow() results in resizing the
387 // window to (0, 0) size which breaks quite a lot of things, e.g. the
388 // sizer calculation in wxSizer::Fit()
390 if (nWidth
== (int)CW_USEDEFAULT
)
393 // The exact number doesn't matter, the dialog will be resized
394 // again soon anyhow but it should be big enough to allow
395 // calculation relying on "totalSize - clientSize > 0" work, i.e.
396 // at least greater than the title bar height
398 nWidth
= nHeight
= 100;
400 if (nX
== (int)CW_USEDEFAULT
)
403 // Centre it on the screen - what else can we do?
405 wxSize vSizeDpy
= wxGetDisplaySize();
407 nX
= (vSizeDpy
.x
- nWidth
) / 2;
408 nY
= (vSizeDpy
.y
- nHeight
) / 2;
410 m_backgroundColour
.Set(wxString(wxT("LIGHT GREY")));
412 LONG lColor
= (LONG
)m_backgroundColour
.GetPixel();
414 if (!::WinSetPresParam( m_hWnd
423 ::WinSetWindowPos( GetHwnd()
429 ,SWP_MOVE
| SWP_SIZE
| SWP_ZORDER
| SWP_SHOW
| SWP_ACTIVATE
431 ::WinQueryWindowPos(GetHwnd(), GetSwp());
435 } // end of wxTopLevelWindowOS2::CreateDialog
437 bool wxTopLevelWindowOS2::CreateFrame( const wxString
& rsTitle
,
439 const wxSize
& rSize
)
442 WXDWORD lFlags
= OS2GetCreateWindowFlags(&lExflags
);
443 long lStyle
= GetWindowStyleFlag();
446 int nWidth
= rSize
.x
;
447 int nHeight
= rSize
.y
;
448 ULONG ulStyleFlags
= 0L;
451 wxWindow
* pParent
= GetParent();
457 hParent
= GetHwndOf(pParent
);
459 hParent
= HWND_DESKTOP
;
461 if ((lStyle
& wxMINIMIZE
) || (lStyle
& wxICONIZE
))
462 ulStyleFlags
|= WS_MINIMIZED
;
463 if (lStyle
& wxMAXIMIZE
)
464 ulStyleFlags
|= WS_MAXIMIZED
;
467 // Clear the visible flag, we always call show
469 ulStyleFlags
&= (unsigned long)~WS_VISIBLE
;
473 // Create the frame window: We break ranks with other ports now
474 // and instead of calling down into the base wxWindow class' OS2Create
475 // we do all our own stuff here. We will set the needed pieces
476 // of wxWindow manually, here.
479 hFrame
= ::WinCreateStdWindow( hParent
480 ,ulStyleFlags
// frame-window style
481 ,(PULONG
)&lFlags
// window style
482 ,(PSZ
)wxFrameClassName
// class name
483 ,(PSZ
)rsTitle
.c_str() // window title
484 ,0L // default client style
485 ,NULLHANDLE
// resource in executable file
487 ,&hClient
// receives client window handle
491 vError
= ::WinGetLastError(vHabmain
);
492 sError
= wxPMErrorToStr(vError
);
493 wxLogError(_T("Error creating frame. Error: %s\n"), sError
.c_str());
498 // wxWindow class' m_hWnd set here and needed associations
502 wxAssociateWinWithHandle(m_hWnd
, this);
503 wxAssociateWinWithHandle(m_hFrame
, this);
505 m_backgroundColour
.Set(wxString(wxT("MEDIUM GREY")));
507 LONG lColor
= (LONG
)m_backgroundColour
.GetPixel();
509 if (!::WinSetPresParam( m_hWnd
515 vError
= ::WinGetLastError(vHabmain
);
516 sError
= wxPMErrorToStr(vError
);
517 wxLogError(_T("Error creating frame. Error: %s\n"), sError
.c_str());
522 // Now need to subclass window. Instead of calling the SubClassWin in wxWindow
523 // we manually subclass here because we don't want to use the main wxWndProc
526 m_fnOldWndProc
= (WXFARPROC
) ::WinSubclassWindow(m_hFrame
, (PFNWP
)wxFrameMainWndProc
);
529 // Now size everything. If adding a menu the client will need to be resized.
534 nY
= pParent
->GetSize().y
- (nY
+ nHeight
);
540 ::WinQueryWindowRect(HWND_DESKTOP
, &vRect
);
541 nY
= vRect
.yTop
- (nY
+ nHeight
);
543 if (!::WinSetWindowPos( m_hFrame
549 ,SWP_SIZE
| SWP_MOVE
| SWP_ACTIVATE
| SWP_ZORDER
552 vError
= ::WinGetLastError(vHabmain
);
553 sError
= wxPMErrorToStr(vError
);
554 wxLogError(_T("Error sizing frame. Error: %s\n"), sError
.c_str());
557 lStyle
= ::WinQueryWindowULong( m_hWnd
560 lStyle
|= WS_CLIPCHILDREN
;
561 ::WinSetWindowULong( m_hWnd
566 } // end of wxTopLevelWindowOS2::CreateFrame
568 bool wxTopLevelWindowOS2::Create(
571 , const wxString
& rsTitle
572 , const wxPoint
& rPos
573 , const wxSize
& rSizeOrig
575 , const wxString
& rsName
582 m_windowStyle
= lStyle
;
584 m_windowId
= vId
== -1 ? NewControlId() : vId
;
586 // always create a frame of some reasonable, even if arbitrary, size (at
587 // least for MSW compatibility)
588 wxSize rSize
= rSizeOrig
;
589 if ( rSize
.x
== -1 || rSize
.y
== -1 )
591 wxSize sizeDpy
= wxGetDisplaySize();
593 rSize
.x
= sizeDpy
.x
/ 3;
595 rSize
.y
= sizeDpy
.y
/ 5;
598 wxTopLevelWindows
.Append(this);
600 pParent
->AddChild(this);
602 if (GetExtraStyle() & wxTOPLEVEL_EX_DIALOG
)
605 // We have different dialog templates to allows creation of dialogs
606 // with & without captions under OS2indows, resizeable or not (but a
607 // resizeable dialog always has caption - otherwise it would look too
612 if (lStyle
& wxRESIZE_BORDER
)
613 ulDlgTemplate
= (ULONG
)kResizeableDialog
;
614 else if (lStyle
& wxCAPTION
)
615 ulDlgTemplate
= (ULONG
)kCaptionDialog
;
617 ulDlgTemplate
= (ULONG
)kNoCaptionDialog
;
618 return CreateDialog( ulDlgTemplate
626 return CreateFrame( rsTitle
631 } // end of wxTopLevelWindowOS2::Create
633 wxTopLevelWindowOS2::~wxTopLevelWindowOS2()
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( bool bShow
)
718 if (bShow
!= IsShown() )
728 if (m_bMaximizeOnShow
)
730 nShowCmd
= SWP_MAXIMIZE
;
731 m_bMaximizeOnShow
= false;
742 DoShowWindow(nShowCmd
);
746 wxActivateEvent
vEvent(wxEVT_ACTIVATE
, true, m_windowId
);
748 ::WinQueryWindowPos(m_hFrame
, &vSwp
);
749 m_bIconized
= ( vSwp
.fl
& SWP_MINIMIZE
) == SWP_MINIMIZE
;
750 ::WinQueryWindowPos(m_hWnd
, &m_vSwpClient
);
751 ::WinSendMsg(m_hFrame
, WM_UPDATEFRAME
, (MPARAM
)~0, 0);
752 ::WinQueryWindowPos(m_hWnd
, &vSwp
);
753 ::WinEnableWindow(m_hFrame
, TRUE
);
756 // Deal with children
758 MoveChildren(m_vSwpClient
.cy
- vSwp
.cy
);
759 vEvent
.SetEventObject(this);
760 GetEventHandler()->ProcessEvent(vEvent
);
765 // Try to highlight the correct window (the parent)
769 HWND hWndParent
= GetHwndOf(GetParent());
771 ::WinQueryWindowPos(hWndParent
, &vSwp
);
772 m_bIconized
= (vSwp
.fl
& SWP_MINIMIZE
)==SWP_MINIMIZE
;
773 ::WinEnableWindow(hWndParent
, TRUE
);
777 } // end of wxTopLevelWindowOS2::Show
779 // ----------------------------------------------------------------------------
780 // wxTopLevelWindowOS2 maximize/minimize
781 // ----------------------------------------------------------------------------
783 void wxTopLevelWindowOS2::Maximize(
790 // Just maximize it directly
792 DoShowWindow(bMaximize
? SWP_MAXIMIZE
: SWP_RESTORE
);
797 // We can't maximize the hidden frame because it shows it as well, so
798 // just remember that we should do it later in this case
800 m_bMaximizeOnShow
= bMaximize
;
802 } // end of wxTopLevelWindowOS2::Maximize
804 bool wxTopLevelWindowOS2::IsMaximized() const
806 ::WinQueryWindowPos(m_hFrame
, (PSWP
)&m_vSwp
);
807 return (m_vSwp
.fl
& SWP_MAXIMIZE
) == SWP_MAXIMIZE
;
808 } // end of wxTopLevelWindowOS2::IsMaximized
810 void wxTopLevelWindowOS2::SetTitle( const wxString
& title
)
815 wxString
wxTopLevelWindowOS2::GetTitle() const
820 void wxTopLevelWindowOS2::Iconize( bool bIconize
)
822 DoShowWindow(bIconize
? SWP_MINIMIZE
: SWP_RESTORE
);
823 } // end of wxTopLevelWindowOS2::Iconize
825 bool wxTopLevelWindowOS2::IsIconized() const
827 // also update the current state
828 ::WinQueryWindowPos(m_hFrame
, (PSWP
)&m_vSwp
);
829 if (m_vSwp
.fl
& SWP_MINIMIZE
)
830 ((wxTopLevelWindow
*)this)->m_bIconized
= true;
832 ((wxTopLevelWindow
*)this)->m_bIconized
= false;
834 } // end of wxTopLevelWindowOS2::IsIconized
836 void wxTopLevelWindowOS2::Restore()
838 DoShowWindow(SWP_RESTORE
);
839 } // end of wxTopLevelWindowOS2::Restore
841 // generate an artificial resize event
842 void wxTopLevelWindowOS2::SendSizeEvent()
846 RECTL vRect
= wxGetWindowRect(GetHwnd());
848 (void)::WinPostMsg( m_hFrame
850 ,MPFROM2SHORT(vRect
.xRight
- vRect
.xLeft
, vRect
.yTop
- vRect
.yBottom
)
851 ,MPFROM2SHORT(vRect
.xRight
- vRect
.xLeft
, vRect
.yTop
- vRect
.yBottom
)
854 } // end of wxTopLevelWindowOS2::SendSizeEvent
856 // ----------------------------------------------------------------------------
857 // wxTopLevelWindowOS2 fullscreen
858 // ----------------------------------------------------------------------------
860 bool wxTopLevelWindowOS2::ShowFullScreen( bool bShow
,
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
;
919 SetSize( nWidth
, nHeight
);
922 // Now flush the window style cache and actually go full-screen
924 ::WinSetWindowPos( m_hFrame
933 wxSize
full( nWidth
, nHeight
);
934 wxSizeEvent
vEvent( full
, GetId() );
935 GetEventHandler()->ProcessEvent(vEvent
);
943 m_bFsIsShowing
= false;
944 Maximize(m_bFsIsMaximized
);
945 ::WinSetWindowULong( (HWND
)GetHWND()
949 ::WinSetWindowPos( m_hFrame
959 } // end of wxTopLevelWindowOS2::ShowFullScreen
961 // ----------------------------------------------------------------------------
962 // wxTopLevelWindowOS2 misc
963 // ----------------------------------------------------------------------------
965 void wxTopLevelWindowOS2::SetIcon(
969 SetIcons(wxIconBundle(rIcon
));
970 } // end of wxTopLevelWindowOS2::SetIcon
972 void wxTopLevelWindowOS2::SetIcons(
973 const wxIconBundle
& rIcons
979 wxTopLevelWindowBase::SetIcons(rIcons
);
981 const wxIcon
& vIcon
= rIcons
.GetIcon(wxSize(32, 32));
983 if (vIcon
.Ok() && vIcon
.GetWidth() == 32 && vIcon
.GetHeight() == 32)
985 ::WinSendMsg( m_hFrame
987 ,(MPARAM
)((HPOINTER
)vIcon
.GetHICON())
990 ::WinSendMsg( m_hFrame
996 } // end of wxTopLevelWindowOS2::SetIcon
998 bool wxTopLevelWindowOS2::EnableCloseButton( bool bEnable
)
1001 // Get system (a.k.a. window) menu
1003 HMENU hMenu
= ::WinWindowFromID(m_hFrame
, FID_SYSMENU
);
1007 wxLogLastError(_T("GetSystemMenu"));
1012 // Enabling/disabling the close item from it also automatically
1013 // disables/enables the close title bar button
1016 (void)::WinSendMsg( hMenu
1018 ,MPFROM2SHORT(SC_CLOSE
, FALSE
)
1019 ,MPFROM2SHORT(MIA_DISABLED
, FALSE
)
1022 (void)::WinSendMsg( hMenu
1024 ,MPFROM2SHORT(SC_CLOSE
, FALSE
)
1025 ,MPFROM2SHORT(MIA_DISABLED
, MIA_DISABLED
)
1029 // Update appearance immediately
1031 ::WinSendMsg( m_hFrame
1037 } // end of wxTopLevelWindowOS2::EnableCloseButton
1039 // ============================================================================
1040 // wxTLWHiddenParentModule implementation
1041 // ============================================================================
1043 HWND
wxTLWHiddenParentModule::m_shWnd
= NULL
;
1044 const wxChar
* wxTLWHiddenParentModule::m_szClassName
= NULL
;
1046 bool wxTLWHiddenParentModule::OnInit()
1049 m_szClassName
= NULL
;
1051 } // end of wxTLWHiddenParentModule::OnInit
1053 void wxTLWHiddenParentModule::OnExit()
1057 if (!::WinDestroyWindow(m_shWnd
))
1059 wxLogLastError(_T("DestroyWindow(hidden TLW parent)"));
1064 m_szClassName
= NULL
;
1065 } // end of wxTLWHiddenParentModule::OnExit
1068 HWND
wxTLWHiddenParentModule::GetHWND()
1074 static const wxChar
* zHIDDEN_PARENT_CLASS
= _T("wxTLWHiddenParent");
1076 if (!::WinRegisterClass( wxGetInstance()
1077 ,(PSZ
)zHIDDEN_PARENT_CLASS
1083 wxLogLastError(_T("RegisterClass(\"wxTLWHiddenParent\")"));
1087 m_szClassName
= zHIDDEN_PARENT_CLASS
;
1090 m_shWnd
= ::WinCreateWindow( HWND_DESKTOP
,
1105 wxLogLastError(_T("CreateWindow(hidden TLW parent)"));
1109 } // end of wxTLWHiddenParentModule::GetHWND