1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/os2/frame.cpp
4 // Author: David Webster
8 // Copyright: (c) David Webster
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 // For compilers that support precompilation, includes "wx.h".
13 #include "wx/wxprec.h"
17 #include "wx/object.h"
18 #include "wx/dynarray.h"
21 #include "wx/string.h"
30 #include "wx/dialog.h"
31 #include "wx/settings.h"
32 #include "wx/dcclient.h"
36 #include "wx/os2/private.h"
39 #include "wx/statusbr.h"
40 #include "wx/generic/statusbr.h"
41 #endif // wxUSE_STATUSBAR
44 #include "wx/toolbar.h"
45 #endif // wxUSE_TOOLBAR
47 #include "wx/menuitem.h"
50 // ----------------------------------------------------------------------------
52 // ----------------------------------------------------------------------------
54 extern wxList WXDLLEXPORT wxPendingDelete
;
56 #if wxUSE_MENUS_NATIVE
57 extern wxMenu
*wxCurrentPopupMenu
;
60 extern void wxAssociateWinWithHandle( HWND hWnd
64 // ----------------------------------------------------------------------------
66 // ----------------------------------------------------------------------------
68 BEGIN_EVENT_TABLE(wxFrame
, wxFrameBase
)
69 EVT_SYS_COLOUR_CHANGED(wxFrame::OnSysColourChanged
)
72 IMPLEMENT_DYNAMIC_CLASS(wxFrame
, wxWindow
)
74 // ============================================================================
76 // ============================================================================
78 // ----------------------------------------------------------------------------
79 // static class members
80 // ----------------------------------------------------------------------------
83 #if wxUSE_NATIVE_STATUSBAR
84 bool wxFrame::m_bUseNativeStatusBar
= true;
86 bool wxFrame::m_bUseNativeStatusBar
= false;
89 #endif //wxUSE_STATUSBAR
91 // ----------------------------------------------------------------------------
92 // creation/destruction
93 // ----------------------------------------------------------------------------
97 m_nFsStatusBarFields
= 0;
98 m_nFsStatusBarHeight
= 0;
99 m_nFsToolBarHeight
= 0;
101 m_bWasMinimized
= false;
104 m_frameMenuBar
= NULL
;
105 m_frameToolBar
= NULL
;
106 m_frameStatusBar
= NULL
;
108 m_hTitleBar
= NULLHANDLE
;
109 m_hHScroll
= NULLHANDLE
;
110 m_hVScroll
= NULLHANDLE
;
115 memset(&m_vSwpTitleBar
, 0, sizeof(SWP
));
116 memset(&m_vSwpMenuBar
, 0, sizeof(SWP
));
117 memset(&m_vSwpHScroll
, 0, sizeof(SWP
));
118 memset(&m_vSwpVScroll
, 0, sizeof(SWP
));
119 memset(&m_vSwpStatusBar
, 0, sizeof(SWP
));
120 memset(&m_vSwpToolBar
, 0, sizeof(SWP
));
123 } // end of wxFrame::Init
125 bool wxFrame::Create( wxWindow
* pParent
,
127 const wxString
& rsTitle
,
131 const wxString
& rsName
)
133 if (!wxTopLevelWindow::Create( pParent
143 } // end of wxFrame::Create
147 m_isBeingDeleted
= true;
149 } // end of wxFrame::~wxFrame
152 // Get size *available for subwindows* i.e. excluding menu bar, toolbar etc.
154 void wxFrame::DoGetClientSize(
159 wxTopLevelWindow::DoGetClientSize( pX
163 // No need to use statusbar code as in WIN32 as the FORMATFRAME
164 // window procedure ensures PM knows about the new frame client
165 // size internally. A ::WinQueryWindowRect (that is called in
166 // wxWindow's GetClient size from above) is all that is needed!
168 } // end of wxFrame::DoGetClientSize
171 // Set the client size (i.e. leave the calculation of borders etc.
174 void wxFrame::DoSetClientSize(
180 // Statusbars are not part of the OS/2 Client but parent frame
181 // so no statusbar consideration
183 wxTopLevelWindow::DoSetClientSize( nWidth
186 } // end of wxFrame::DoSetClientSize
188 // ----------------------------------------------------------------------------
189 // wxFrame: various geometry-related functions
190 // ----------------------------------------------------------------------------
192 void wxFrame::Raise()
194 wxFrameBase::Raise();
195 ::WinSetWindowPos( (HWND
) GetParent()->GetHWND()
206 wxStatusBar
* wxFrame::OnCreateStatusBar(
210 , const wxString
& rName
213 wxStatusBar
* pStatusBar
= NULL
;
216 pStatusBar
= wxFrameBase::OnCreateStatusBar( nNumber
225 wxClientDC
vDC(pStatusBar
);
229 // Set the height according to the font and the border size
231 vDC
.SetFont(pStatusBar
->GetFont()); // Screws up the menues for some reason
232 vDC
.GetTextExtent( wxT("X")
237 int nHeight
= ((11 * nY
) / 10 + 2 * pStatusBar
->GetBorderY());
239 pStatusBar
->SetSize( wxDefaultCoord
245 ::WinSetParent( pStatusBar
->GetHWND(), m_hFrame
, FALSE
);
246 ::WinSetOwner( pStatusBar
->GetHWND(), m_hFrame
);
250 if(::WinIsWindowShowing(m_hFrame
))
251 ::WinSendMsg(m_hFrame
, WM_UPDATEFRAME
, (MPARAM
)~0, 0);
254 } // end of wxFrame::OnCreateStatusBar
256 void wxFrame::PositionStatusBar()
263 // Native status bar positions itself
265 if (m_frameStatusBar
)
274 ::WinQueryWindowRect(m_hFrame
, &vRect
);
276 ::WinMapWindowPoints(m_hFrame
, HWND_DESKTOP
, (PPOINTL
)&vRect
, 2);
278 ::WinCalcFrameRect(m_hFrame
, &vRect
, TRUE
);
279 nWidth
= vRect
.xRight
- vRect
.xLeft
;
280 nY
= nY
- (vRect
.yBottom
- vFRect
.yBottom
);
282 m_frameStatusBar
->GetSize( &nStatbarWidth
286 nY
= nY
- nStatbarHeight
;
288 // Since we wish the status bar to be directly under the client area,
289 // we use the adjusted sizes without using wxSIZE_NO_ADJUSTMENTS.
291 m_frameStatusBar
->SetSize( vRect
.xLeft
- vFRect
.xLeft
296 if (!::WinQueryWindowPos(m_frameStatusBar
->GetHWND(), &vSwp
))
298 vError
= ::WinGetLastError(vHabmain
);
299 sError
= wxPMErrorToStr(vError
);
300 wxLogError(_T("Error setting parent for StatusBar. Error: %s\n"), sError
.c_str());
304 } // end of wxFrame::PositionStatusBar
305 #endif // wxUSE_STATUSBAR
308 wxToolBar
* wxFrame::OnCreateToolBar( long lStyle
, wxWindowID vId
, const wxString
& rsName
)
310 wxToolBar
* pToolBar
= wxFrameBase::OnCreateToolBar( lStyle
315 ::WinSetParent( pToolBar
->GetHWND(), m_hFrame
, FALSE
);
316 ::WinSetOwner( pToolBar
->GetHWND(), m_hFrame
);
318 } // end of WinGuiBase_CFrame::OnCreateToolBar
321 #if wxUSE_MENUS_NATIVE
322 void wxFrame::DetachMenuBar()
326 m_frameMenuBar
->Detach();
327 m_frameMenuBar
= NULL
;
329 } // end of wxFrame::DetachMenuBar
331 void wxFrame::SetMenuBar(
342 // Actually remove the menu from the frame
344 m_hMenu
= (WXHMENU
)0;
345 InternalSetMenuBar();
347 else // set new non NULL menu bar
349 m_frameMenuBar
= NULL
;
352 // Can set a menubar several times.
353 // TODO: how to prevent a memory leak if you have a currently-unattached
354 // menubar? wxWidgets assumes that the frame will delete the menu (otherwise
355 // there are problems for MDI).
357 if (pMenuBar
->GetHMenu())
359 m_hMenu
= pMenuBar
->GetHMenu();
364 m_hMenu
= pMenuBar
->Create();
368 InternalSetMenuBar();
369 m_frameMenuBar
= pMenuBar
;
370 pMenuBar
->Attach((wxFrame
*)this);
372 } // end of wxFrame::SetMenuBar
374 void wxFrame::AttachMenuBar(
378 wxFrameBase::AttachMenuBar(pMenubar
);
380 m_frameMenuBar
= pMenubar
;
385 // Actually remove the menu from the frame
387 m_hMenu
= (WXHMENU
)0;
388 InternalSetMenuBar();
390 else // Set new non NULL menu bar
393 // Can set a menubar several times.
395 if (pMenubar
->GetHMenu())
397 m_hMenu
= pMenubar
->GetHMenu();
401 if (pMenubar
->IsAttached())
404 m_hMenu
= pMenubar
->Create();
409 InternalSetMenuBar();
411 } // end of wxFrame::AttachMenuBar
413 void wxFrame::InternalSetMenuBar()
418 // Set the parent and owner of the menubar to be the frame
420 if (!::WinSetParent(m_hMenu
, m_hFrame
, FALSE
))
422 vError
= ::WinGetLastError(vHabmain
);
423 sError
= wxPMErrorToStr(vError
);
424 wxLogError(_T("Error setting parent for submenu. Error: %s\n"), sError
.c_str());
427 if (!::WinSetOwner(m_hMenu
, m_hFrame
))
429 vError
= ::WinGetLastError(vHabmain
);
430 sError
= wxPMErrorToStr(vError
);
431 wxLogError(_T("Error setting parent for submenu. Error: %s\n"), sError
.c_str());
433 ::WinSendMsg(m_hFrame
, WM_UPDATEFRAME
, (MPARAM
)FCF_MENU
, (MPARAM
)0);
434 } // end of wxFrame::InternalSetMenuBar
435 #endif // wxUSE_MENUS_NATIVE
438 // Responds to colour changes, and passes event on to children
440 void wxFrame::OnSysColourChanged(
441 wxSysColourChangedEvent
& rEvent
444 SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_APPWORKSPACE
));
448 if (m_frameStatusBar
)
450 wxSysColourChangedEvent vEvent2
;
452 vEvent2
.SetEventObject(m_frameStatusBar
);
453 m_frameStatusBar
->GetEventHandler()->ProcessEvent(vEvent2
);
455 #endif //wxUSE_STATUSBAR
458 // Propagate the event to the non-top-level children
460 wxWindow::OnSysColourChanged(rEvent
);
461 } // end of wxFrame::OnSysColourChanged
463 // Pass true to show full screen, false to restore.
464 bool wxFrame::ShowFullScreen( bool bShow
, long lStyle
)
471 m_bFsIsShowing
= true;
475 wxToolBar
* pTheToolBar
= GetToolBar();
476 #endif //wxUSE_TOOLBAR
479 wxStatusBar
* pTheStatusBar
= GetStatusBar();
480 #endif //wxUSE_STATUSBAR
486 pTheToolBar
->GetSize(&nDummyWidth
, &m_nFsToolBarHeight
);
487 #endif //wxUSE_TOOLBAR
491 pTheStatusBar
->GetSize(&nDummyWidth
, &m_nFsStatusBarHeight
);
492 #endif //wxUSE_STATUSBAR
496 // Zap the toolbar, menubar, and statusbar
498 if ((lStyle
& wxFULLSCREEN_NOTOOLBAR
) && pTheToolBar
)
500 pTheToolBar
->SetSize(wxDefaultCoord
,0);
501 pTheToolBar
->Show(false);
503 #endif //wxUSE_TOOLBAR
505 if (lStyle
& wxFULLSCREEN_NOMENUBAR
)
507 ::WinSetParent(m_hMenu
, m_hFrame
, FALSE
);
508 ::WinSetOwner(m_hMenu
, m_hFrame
);
509 ::WinSendMsg((HWND
)m_hFrame
, WM_UPDATEFRAME
, (MPARAM
)FCF_MENU
, (MPARAM
)0);
514 // Save the number of fields in the statusbar
516 if ((lStyle
& wxFULLSCREEN_NOSTATUSBAR
) && pTheStatusBar
)
518 m_nFsStatusBarFields
= pTheStatusBar
->GetFieldsCount();
519 SetStatusBar((wxStatusBar
*) NULL
);
520 delete pTheStatusBar
;
523 m_nFsStatusBarFields
= 0;
524 #endif //wxUSE_STATUSBAR
527 // Zap the frame borders
531 // Save the 'normal' window style
533 m_lFsOldWindowStyle
= ::WinQueryWindowULong(m_hFrame
, QWL_STYLE
);
536 // Save the old position, width & height, maximize state
538 m_vFsOldSize
= GetRect();
539 m_bFsIsMaximized
= IsMaximized();
542 // Decide which window style flags to turn off
544 LONG lNewStyle
= m_lFsOldWindowStyle
;
547 if (lStyle
& wxFULLSCREEN_NOBORDER
)
548 lOffFlags
|= FCF_BORDER
;
549 if (lStyle
& wxFULLSCREEN_NOCAPTION
)
550 lOffFlags
|= (FCF_TASKLIST
| FCF_SYSMENU
);
552 lNewStyle
&= (~lOffFlags
);
555 // Change our window style to be compatible with full-screen mode
557 ::WinSetWindowULong((HWND
)m_hFrame
, QWL_STYLE
, (ULONG
)lNewStyle
);
560 // Resize to the size of the desktop
566 ::WinQueryWindowRect(HWND_DESKTOP
, &vRect
);
567 nWidth
= vRect
.xRight
- vRect
.xLeft
;
569 // Rmember OS/2 is backwards!
571 nHeight
= vRect
.yTop
- vRect
.yBottom
;
573 SetSize( nWidth
, nHeight
);
576 // Now flush the window style cache and actually go full-screen
578 ::WinSetWindowPos( (HWND
) GetParent()->GetHWND()
587 wxSize
sz( nWidth
, nHeight
);
588 wxSizeEvent
vEvent( sz
, GetId() );
590 GetEventHandler()->ProcessEvent(vEvent
);
598 m_bFsIsShowing
= false;
601 wxToolBar
* pTheToolBar
= GetToolBar();
604 // Restore the toolbar, menubar, and statusbar
606 if (pTheToolBar
&& (m_lFsStyle
& wxFULLSCREEN_NOTOOLBAR
))
608 pTheToolBar
->SetSize(wxDefaultCoord
, m_nFsToolBarHeight
);
609 pTheToolBar
->Show(true);
611 #endif //wxUSE_TOOLBAR
614 if ((m_lFsStyle
& wxFULLSCREEN_NOSTATUSBAR
) && (m_nFsStatusBarFields
> 0))
616 CreateStatusBar(m_nFsStatusBarFields
);
617 // PositionStatusBar();
619 #endif //wxUSE_STATUSBAR
621 if ((m_lFsStyle
& wxFULLSCREEN_NOMENUBAR
) && (m_hMenu
!= 0))
623 ::WinSetParent(m_hMenu
, m_hFrame
, FALSE
);
624 ::WinSetOwner(m_hMenu
, m_hFrame
);
625 ::WinSendMsg(m_hFrame
, WM_UPDATEFRAME
, (MPARAM
)FCF_MENU
, (MPARAM
)0);
627 Maximize(m_bFsIsMaximized
);
629 ::WinSetWindowULong( m_hFrame
631 ,(ULONG
)m_lFsOldWindowStyle
633 ::WinSetWindowPos( (HWND
) GetParent()->GetHWND()
642 return wxFrameBase::ShowFullScreen(bShow
, lStyle
);
643 } // end of wxFrame::ShowFullScreen
648 // ----------------------------------------------------------------------------
649 // wxFrame size management: we exclude the areas taken by menu/status/toolbars
650 // from the client area, so the client area is what's really available for the
652 // ----------------------------------------------------------------------------
654 // Checks if there is a toolbar, and returns the first free client position
655 wxPoint
wxFrame::GetClientAreaOrigin() const
657 wxPoint vPoint
= wxTopLevelWindow::GetClientAreaOrigin();
660 // In OS/2 the toolbar and statusbar are frame extensions so there is no
661 // adjustment. The client is supposedly resized for a toolbar in OS/2
662 // as it is for the status bar.
665 } // end of wxFrame::GetClientAreaOrigin
667 // ----------------------------------------------------------------------------
668 // tool/status bar stuff
669 // ----------------------------------------------------------------------------
673 wxToolBar
* wxFrame::CreateToolBar(
676 , const wxString
& rName
679 if (wxFrameBase::CreateToolBar( lStyle
686 return m_frameToolBar
;
687 } // end of wxFrame::CreateToolBar
689 void wxFrame::PositionToolBar()
691 wxToolBar
* pToolBar
= GetToolBar();
704 ::WinQueryWindowRect(m_hFrame
, &vRect
);
705 vPos
.y
= (wxCoord
)vRect
.yTop
;
706 ::WinMapWindowPoints(m_hFrame
, HWND_DESKTOP
, (PPOINTL
)&vRect
, 2);
708 ::WinCalcFrameRect(m_hFrame
, &vRect
, TRUE
);
710 vPos
.y
= (wxCoord
)(vFRect
.yTop
- vRect
.yTop
);
711 pToolBar
->GetSize( &vTWidth
715 if (pToolBar
->GetWindowStyleFlag() & wxTB_HORIZONTAL
)
717 vWidth
= (wxCoord
)(vRect
.xRight
- vRect
.xLeft
);
718 pToolBar
->SetSize( vRect
.xLeft
- vFRect
.xLeft
727 wxCoord vSheight
= 0;
729 if (m_frameStatusBar
)
730 m_frameStatusBar
->GetSize( &vSwidth
733 vHeight
= (wxCoord
)(vRect
.yTop
- vRect
.yBottom
);
734 pToolBar
->SetSize( vRect
.xLeft
- vFRect
.xLeft
740 if( ::WinIsWindowShowing(m_hFrame
) )
741 ::WinSendMsg(m_hFrame
, WM_UPDATEFRAME
, (MPARAM
)~0, 0);
742 } // end of wxFrame::PositionToolBar
743 #endif // wxUSE_TOOLBAR
745 // ----------------------------------------------------------------------------
746 // frame state (iconized/maximized/...)
747 // ----------------------------------------------------------------------------
750 // propagate our state change to all child frames: this allows us to emulate X
751 // Windows behaviour where child frames float independently of the parent one
752 // on the desktop, but are iconized/restored with it
754 void wxFrame::IconizeChildFrames( bool WXUNUSED(bIconize
) )
756 // FIXME: Generic MDI does not use Frames for the Childs, so this does _not_
757 // work. Possibly, the right thing is simply to eliminate this
758 // functions and all the calls to it from within this file.
760 for (wxWindowList::Node
* pNode
= GetChildren().GetFirst();
762 pNode
= pNode
->GetNext() )
764 wxWindow
* pWin
= pNode
->GetData();
765 wxFrame
* pFrame
= wxDynamicCast(pWin
, wxFrame
);
768 #if wxUSE_MDI_ARCHITECTURE
769 && !wxDynamicCast(pFrame
, wxMDIChildFrame
)
770 #endif // wxUSE_MDI_ARCHITECTURE
774 // We don't want to restore the child frames which had been
775 // iconized even before we were iconized, so save the child frame
776 // status when iconizing the parent frame and check it when
781 pFrame
->m_bWasMinimized
= pFrame
->IsIconized();
785 // This test works for both iconizing and restoring
787 if (!pFrame
->m_bWasMinimized
)
788 pFrame
->Iconize(bIconize
);
792 } // end of wxFrame::IconizeChildFrames
794 WXHICON
wxFrame::GetDefaultIcon() const
796 return (WXHICON
)(wxSTD_FRAME_ICON
? wxSTD_FRAME_ICON
797 : wxDEFAULT_FRAME_ICON
);
799 // ===========================================================================
800 // message processing
801 // ===========================================================================
803 // ---------------------------------------------------------------------------
805 // ---------------------------------------------------------------------------
806 bool wxFrame::OS2TranslateMessage( WXMSG
* pMsg
)
809 // try the menu bar accels
811 wxMenuBar
* pMenuBar
= GetMenuBar();
816 #if wxUSE_ACCEL && wxUSE_MENUS_NATIVE
817 const wxAcceleratorTable
& rAcceleratorTable
= pMenuBar
->GetAccelTable();
818 return rAcceleratorTable
.Translate(GetHWND(), pMsg
);
822 } // end of wxFrame::OS2TranslateMessage
824 // ---------------------------------------------------------------------------
825 // our private (non virtual) message handlers
826 // ---------------------------------------------------------------------------
827 bool wxFrame::HandlePaint()
831 if (::WinQueryUpdateRect(GetHWND(), &vRect
))
836 // Icons in PM are the same as "pointers"
838 const wxIcon
& vIcon
= GetIcon();
842 hIcon
= (HPOINTER
)::WinSendMsg(m_hFrame
, WM_QUERYICON
, 0L, 0L);
844 hIcon
= (HPOINTER
)m_hDefaultIcon
;
847 // Hold a pointer to the dc so long as the OnPaint() message
848 // is being processed
851 HPS hPs
= ::WinBeginPaint(GetHwnd(), NULLHANDLE
, &vRect2
);
854 // Erase background before painting or we get white background
856 OS2DefWindowProc(WM_ERASEBACKGROUND
, (MPARAM
)hPs
, (MPARAM
)&vRect2
);
862 ::WinQueryWindowRect(GetHwnd(), &vRect3
);
864 static const int nIconWidth
= 32;
865 static const int nIconHeight
= 32;
866 int nIconX
= (int)((vRect3
.xRight
- nIconWidth
)/2);
867 int nIconY
= (int)((vRect3
.yBottom
+ nIconHeight
)/2);
869 ::WinDrawPointer(hPs
, nIconX
, nIconY
, hIcon
, DP_NORMAL
);
875 if (!wxWindow::HandlePaint())
880 hPS
= ::WinBeginPaint( GetHwnd()
886 ::GpiCreateLogColorTable( hPS
890 ,(LONG
)wxTheColourDatabase
->m_nSize
891 ,(PLONG
)wxTheColourDatabase
->m_palTable
893 ::GpiCreateLogColorTable( hPS
903 ,GetBackgroundColour().GetPixel()
912 } // end of wxFrame::HandlePaint
914 bool wxFrame::HandleSize( int nX
, int nY
, WXUINT nId
)
916 bool bProcessed
= false;
922 // Only do it it if we were iconized before, otherwise resizing the
923 // parent frame has a curious side effect of bringing it under it's
929 // restore all child frames too
931 IconizeChildFrames(false);
932 (void)SendIconizeEvent(false);
944 // Iconize all child frames too
946 IconizeChildFrames(true);
947 (void)SendIconizeEvent();
955 // forward WM_SIZE to status bar control
957 #if wxUSE_NATIVE_STATUSBAR
958 if (m_frameStatusBar
&& m_frameStatusBar
->IsKindOf(CLASSINFO(wxStatusBar95
)))
960 wxSizeEvent
vEvent( wxSize( nX
963 ,m_frameStatusBar
->GetId()
966 vEvent
.SetEventObject(m_frameStatusBar
);
967 m_frameStatusBar
->OnSize(vEvent
);
969 #endif // wxUSE_NATIVE_STATUSBAR
974 #endif // wxUSE_TOOLBAR
976 bProcessed
= wxWindow::HandleSize( nX
982 } // end of wxFrame::HandleSize
984 bool wxFrame::HandleCommand( WXWORD nId
,
991 // In case it's e.g. a toolbar.
993 wxWindow
* pWin
= wxFindWinFromHandle(hControl
);
996 return pWin
->OS2Command( nCmd
, nId
);
1000 // Handle here commands from menus and accelerators
1002 if (nCmd
== CMDSRC_MENU
|| nCmd
== CMDSRC_ACCELERATOR
)
1004 #if wxUSE_MENUS_NATIVE
1005 if (wxCurrentPopupMenu
)
1007 wxMenu
* pPopupMenu
= wxCurrentPopupMenu
;
1009 wxCurrentPopupMenu
= NULL
;
1011 return pPopupMenu
->OS2Command( nCmd
, nId
);
1015 if (ProcessCommand(nId
))
1021 } // end of wxFrame::HandleCommand
1023 bool wxFrame::HandleMenuSelect( WXWORD nItem
,
1032 rc
= ::WinSendMsg(hMenu
, MM_QUERYITEM
, MPFROM2SHORT(nItem
, TRUE
), (MPARAM
)&mItem
);
1034 if(rc
&& !(mItem
.afStyle
& (MIS_SUBMENU
| MIS_SEPARATOR
)))
1036 wxMenuEvent
vEvent(wxEVT_MENU_HIGHLIGHT
, nItem
);
1038 vEvent
.SetEventObject(this);
1039 GetEventHandler()->ProcessEvent(vEvent
); // return value would be ignored by PM
1043 DoGiveHelp(wxEmptyString
, false);
1048 } // end of wxFrame::HandleMenuSelect
1050 // ---------------------------------------------------------------------------
1051 // Main Frame window proc
1052 // ---------------------------------------------------------------------------
1053 MRESULT EXPENTRY
wxFrameMainWndProc( HWND hWnd
,
1058 MRESULT rc
= (MRESULT
)0;
1059 bool bProcessed
= false;
1060 wxFrame
* pWnd
= NULL
;
1062 pWnd
= (wxFrame
*) wxFindWinFromHandle((WXHWND
) hWnd
);
1065 case WM_QUERYFRAMECTLCOUNT
:
1066 if(pWnd
&& pWnd
->m_fnOldWndProc
)
1068 USHORT uItemCount
= SHORT1FROMMR(pWnd
->m_fnOldWndProc(hWnd
, ulMsg
, wParam
, lParam
));
1070 rc
= MRFROMSHORT(uItemCount
);
1074 case WM_FORMATFRAME
:
1075 /////////////////////////////////////////////////////////////////////////////////
1076 // Applications that subclass frame controls may find that the frame is already
1077 // subclassed the number of frame controls is variable.
1078 // The WM_FORMATFRAME and WM_QUERYFRAMECTLCOUNT messages must always be
1079 // subclassed by calling the previous window procedure and modifying its result.
1080 ////////////////////////////////////////////////////////////////////////////////
1092 pSWP
= (PSWP
)PVOIDFROMMP(wParam
);
1093 nItemCount
= SHORT1FROMMR(pWnd
->m_fnOldWndProc(hWnd
, ulMsg
, wParam
, lParam
));
1094 if(pWnd
->m_frameStatusBar
)
1096 ::WinQueryWindowRect(pWnd
->m_frameStatusBar
->GetHWND(), &vRstb
);
1097 pWnd
->m_frameStatusBar
->GetSize(NULL
, &nHeight
);
1099 if(pWnd
->m_frameToolBar
)
1101 ::WinQueryWindowRect(pWnd
->m_frameToolBar
->GetHWND(), &vRtlb
);
1102 pWnd
->m_frameToolBar
->GetSize(&nWidth
, &nHeight2
);
1104 ::WinQueryWindowRect(pWnd
->m_hFrame
, &vRectl
);
1105 ::WinMapWindowPoints(pWnd
->m_hFrame
, HWND_DESKTOP
, (PPOINTL
)&vRectl
, 2);
1106 ::WinCalcFrameRect(pWnd
->m_hFrame
, &vRectl
, TRUE
);
1107 ::WinMapWindowPoints(HWND_DESKTOP
, pWnd
->m_hFrame
, (PPOINTL
)&vRectl
, 2);
1108 for(i
= 0; i
< nItemCount
; i
++)
1110 if(pWnd
->m_hWnd
&& pSWP
[i
].hwnd
== pWnd
->m_hWnd
)
1112 if (pWnd
->m_frameToolBar
&& pWnd
->m_frameToolBar
->GetWindowStyleFlag() & wxTB_HORIZONTAL
)
1114 pSWP
[i
].x
= vRectl
.xLeft
;
1115 pSWP
[i
].y
= vRectl
.yBottom
+ nHeight
;
1116 pSWP
[i
].cx
= vRectl
.xRight
- vRectl
.xLeft
;
1117 pSWP
[i
].cy
= vRectl
.yTop
- vRectl
.yBottom
- (nHeight
+ nHeight2
);
1121 pSWP
[i
].x
= vRectl
.xLeft
+ nWidth
;
1122 pSWP
[i
].y
= vRectl
.yBottom
+ nHeight
;
1123 pSWP
[i
].cx
= vRectl
.xRight
- (vRectl
.xLeft
+ nWidth
);
1124 pSWP
[i
].cy
= vRectl
.yTop
- vRectl
.yBottom
- nHeight
;
1126 pSWP
[i
].fl
= SWP_SIZE
| SWP_MOVE
| SWP_SHOW
;
1127 pSWP
[i
].hwndInsertBehind
= HWND_TOP
;
1131 rc
= MRFROMSHORT(nItemCount
);
1136 if(pWnd
&& pWnd
->m_fnOldWndProc
)
1137 rc
= pWnd
->m_fnOldWndProc(hWnd
, ulMsg
, wParam
, lParam
);
1139 rc
= ::WinDefWindowProc(hWnd
, ulMsg
, wParam
, lParam
);
1142 } // end of wxFrameMainWndProc
1144 MRESULT EXPENTRY
wxFrameWndProc(
1152 // Trace all ulMsgs - useful for the debugging
1155 wxFrame
* pWnd
= NULL
;
1157 parentHwnd
= WinQueryWindow(hWnd
,QW_PARENT
);
1158 pWnd
= (wxFrame
*) wxFindWinFromHandle((WXHWND
) hWnd
);
1161 // When we get the first message for the HWND we just created, we associate
1162 // it with wxWindow stored in wxWndHook
1165 MRESULT rc
= (MRESULT
)0;
1168 // Stop right here if we don't have a valid handle in our wxWindow object.
1170 if (pWnd
&& !pWnd
->GetHWND())
1172 pWnd
->SetHWND((WXHWND
) hWnd
);
1173 rc
= pWnd
->OS2DefWindowProc(ulMsg
, wParam
, lParam
);
1179 rc
= pWnd
->OS2WindowProc(ulMsg
, wParam
, lParam
);
1181 rc
= ::WinDefWindowProc(hWnd
, ulMsg
, wParam
, lParam
);
1184 } // end of wxFrameWndProc
1186 MRESULT
wxFrame::OS2WindowProc( WXUINT uMessage
,
1191 bool bProcessed
= false;
1197 // If we can't close, tell the system that we processed the
1198 // message - otherwise it would close us
1200 bProcessed
= !Close();
1204 bProcessed
= HandlePaint();
1205 mRc
= (MRESULT
)FALSE
;
1208 case WM_ERASEBACKGROUND
:
1210 // Returning TRUE to requests PM to paint the window background
1211 // in SYSCLR_WINDOW. We capture this here because the PS returned
1212 // in Frames is the PS for the whole frame, which we can't really
1213 // use at all. If you want to paint a different background, do it
1214 // in an OnPaint using a wxPaintDC.
1216 mRc
= (MRESULT
)(TRUE
);
1225 UnpackCommand( (WXWPARAM
)wParam
1232 bProcessed
= HandleCommand( wId
1245 UnpackMenuSelect( wParam
1251 bProcessed
= HandleMenuSelect( wItem
1255 mRc
= (MRESULT
)TRUE
;
1261 SHORT nScxnew
= SHORT1FROMMP(lParam
); // New horizontal size.
1262 SHORT nScynew
= SHORT2FROMMP(lParam
); // New vertical size.
1264 lParam
= MRFROM2SHORT( nScxnew
- 20
1268 bProcessed
= HandleSize(LOWORD(lParam
), HIWORD(lParam
), (WXUINT
)wParam
);
1269 mRc
= (MRESULT
)FALSE
;
1272 case CM_QUERYDRAGIMAGE
:
1274 const wxIcon
& vIcon
= GetIcon();
1278 hIcon
= (HPOINTER
)::WinSendMsg(GetHWND(), WM_QUERYICON
, 0L, 0L);
1280 hIcon
= (HPOINTER
)m_hDefaultIcon
;
1281 mRc
= (MRESULT
)hIcon
;
1282 bProcessed
= mRc
!= 0;
1288 mRc
= wxWindow::OS2WindowProc( uMessage
1292 return (MRESULT
)mRc
;
1293 } // wxFrame::OS2WindowProc
1295 void wxFrame::SetClient(WXHWND
WXUNUSED(c_Hwnd
))
1297 // Duh...nothing to do under OS/2
1300 void wxFrame::SetClient( wxWindow
* pWindow
)
1302 wxWindow
* pOldClient
= this->GetClient();
1303 bool bClientHasFocus
= pOldClient
&& (pOldClient
== wxWindow::FindFocus());
1305 if(pOldClient
== pWindow
) // nothing to do
1307 if(pWindow
== NULL
) // just need to remove old client
1309 if(pOldClient
== NULL
) // nothing to do
1312 if(bClientHasFocus
)
1315 pOldClient
->Enable( false );
1316 pOldClient
->Show( false );
1317 ::WinSetWindowUShort(pOldClient
->GetHWND(), QWS_ID
, (USHORT
)pOldClient
->GetId());
1318 // to avoid OS/2 bug need to update frame
1319 ::WinSendMsg((HWND
)this->GetFrame(), WM_UPDATEFRAME
, (MPARAM
)~0, 0);
1324 // Else need to change client
1329 ::WinEnableWindowUpdate((HWND
)GetHWND(), FALSE
);
1332 pOldClient
->Enable(false);
1333 pOldClient
->Show(false);
1334 ::WinSetWindowUShort(pOldClient
->GetHWND(), QWS_ID
, (USHORT
)pOldClient
->GetId());
1336 pWindow
->Reparent(this);
1337 ::WinSetWindowUShort(pWindow
->GetHWND(), QWS_ID
, FID_CLIENT
);
1338 ::WinEnableWindowUpdate((HWND
)GetHWND(), TRUE
);
1340 pWindow
->Show(); // ensure client is showing
1341 if( this->IsShown() )
1344 ::WinSendMsg(m_hFrame
, WM_UPDATEFRAME
, (MPARAM
)~0, 0);
1348 wxWindow
* wxFrame::GetClient()
1350 return wxFindWinFromHandle((WXHWND
)::WinWindowFromID(m_hFrame
, FID_CLIENT
));
1353 void wxFrame::SendSizeEvent()
1357 RECTL vRect
= wxGetWindowRect(GetHwnd());
1359 ::WinPostMsg( GetHwnd()
1361 ,MPFROM2SHORT( vRect
.xRight
- vRect
.xLeft
1362 ,vRect
.xRight
- vRect
.xLeft
1364 ,MPFROM2SHORT( vRect
.yTop
- vRect
.yBottom
1365 ,vRect
.yTop
- vRect
.yBottom