1 /////////////////////////////////////////////////////////////////////////////
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 wxWindowList wxModelessWindows
;
55 extern wxList WXDLLEXPORT wxPendingDelete
;
57 #if wxUSE_MENUS_NATIVE
58 extern wxMenu
*wxCurrentPopupMenu
;
61 extern void wxAssociateWinWithHandle( HWND hWnd
65 // ----------------------------------------------------------------------------
67 // ----------------------------------------------------------------------------
69 BEGIN_EVENT_TABLE(wxFrame
, wxFrameBase
)
70 EVT_SYS_COLOUR_CHANGED(wxFrame::OnSysColourChanged
)
73 IMPLEMENT_DYNAMIC_CLASS(wxFrame
, wxWindow
)
75 // ============================================================================
77 // ============================================================================
79 // ----------------------------------------------------------------------------
80 // static class members
81 // ----------------------------------------------------------------------------
84 #if wxUSE_NATIVE_STATUSBAR
85 bool wxFrame::m_bUseNativeStatusBar
= TRUE
;
87 bool wxFrame::m_bUseNativeStatusBar
= FALSE
;
90 #endif //wxUSE_STATUSBAR
92 // ----------------------------------------------------------------------------
93 // creation/destruction
94 // ----------------------------------------------------------------------------
98 m_nFsStatusBarFields
= 0;
99 m_nFsStatusBarHeight
= 0;
100 m_nFsToolBarHeight
= 0;
102 m_bWasMinimized
= FALSE
;
105 m_frameMenuBar
= NULL
;
106 m_frameToolBar
= NULL
;
107 m_frameStatusBar
= NULL
;
109 m_hTitleBar
= NULLHANDLE
;
110 m_hHScroll
= NULLHANDLE
;
111 m_hVScroll
= NULLHANDLE
;
116 memset(&m_vSwpTitleBar
, 0, sizeof(SWP
));
117 memset(&m_vSwpMenuBar
, 0, sizeof(SWP
));
118 memset(&m_vSwpHScroll
, 0, sizeof(SWP
));
119 memset(&m_vSwpVScroll
, 0, sizeof(SWP
));
120 memset(&m_vSwpStatusBar
, 0, sizeof(SWP
));
121 memset(&m_vSwpToolBar
, 0, sizeof(SWP
));
124 } // end of wxFrame::Init
126 bool wxFrame::Create(
129 , const wxString
& rsTitle
130 , const wxPoint
& rPos
131 , const wxSize
& rSize
133 , const wxString
& rsName
136 if (!wxTopLevelWindow::Create( pParent
145 wxModelessWindows
.Append(this);
147 } // end of wxFrame::Create
151 m_isBeingDeleted
= TRUE
;
153 } // end of wxFrame::~wxFrame
156 // Get size *available for subwindows* i.e. excluding menu bar, toolbar etc.
158 void wxFrame::DoGetClientSize(
163 wxTopLevelWindow::DoGetClientSize( pX
167 // No need to use statusbar code as in WIN32 as the FORMATFRAME
168 // window procedure ensures PM knows about the new frame client
169 // size internally. A ::WinQueryWindowRect (that is called in
170 // wxWindow's GetClient size from above) is all that is needed!
172 } // end of wxFrame::DoGetClientSize
175 // Set the client size (i.e. leave the calculation of borders etc.
178 void wxFrame::DoSetClientSize(
183 wxStatusBar
* pStatusBar
= GetStatusBar();
186 // Statusbars are not part of the OS/2 Client but parent frame
187 // so no statusbar consideration
189 wxTopLevelWindow::DoSetClientSize( nWidth
192 } // end of wxFrame::DoSetClientSize
194 // ----------------------------------------------------------------------------
195 // wxFrame: various geometry-related functions
196 // ----------------------------------------------------------------------------
198 void wxFrame::Raise()
200 wxFrameBase::Raise();
201 ::WinSetWindowPos( (HWND
) GetParent()->GetHWND()
212 wxStatusBar
* wxFrame::OnCreateStatusBar(
216 , const wxString
& rName
219 wxStatusBar
* pStatusBar
= NULL
;
224 pStatusBar
= wxFrameBase::OnCreateStatusBar( nNumber
233 wxClientDC
vDC(pStatusBar
);
237 // Set the height according to the font and the border size
239 vDC
.SetFont(pStatusBar
->GetFont()); // Screws up the menues for some reason
240 vDC
.GetTextExtent( "X"
245 int nHeight
= ((11 * nY
) / 10 + 2 * pStatusBar
->GetBorderY());
247 pStatusBar
->SetSize( -1
253 ::WinSetParent( pStatusBar
->GetHWND()
257 ::WinSetOwner( pStatusBar
->GetHWND()
263 if(::WinIsWindowShowing(m_hFrame
))
264 ::WinSendMsg(m_hFrame
, WM_UPDATEFRAME
, (MPARAM
)~0, 0);
267 } // end of wxFrame::OnCreateStatusBar
269 void wxFrame::PositionStatusBar()
276 // Native status bar positions itself
278 if (m_frameStatusBar
)
288 ::WinQueryWindowRect(m_hFrame
, &vRect
);
290 ::WinMapWindowPoints(m_hFrame
, HWND_DESKTOP
, (PPOINTL
)&vRect
, 2);
292 ::WinCalcFrameRect(m_hFrame
, &vRect
, TRUE
);
293 nWidth
= vRect
.xRight
- vRect
.xLeft
;
294 nY
= nY
- (vRect
.yBottom
- vFRect
.yBottom
);
296 m_frameStatusBar
->GetSize( &nStatbarWidth
300 nY
= nY
- nStatbarHeight
;
302 // Since we wish the status bar to be directly under the client area,
303 // we use the adjusted sizes without using wxSIZE_NO_ADJUSTMENTS.
305 m_frameStatusBar
->SetSize( vRect
.xLeft
- vFRect
.xLeft
310 if (!::WinQueryWindowPos(m_frameStatusBar
->GetHWND(), &vSwp
))
312 vError
= ::WinGetLastError(vHabmain
);
313 sError
= wxPMErrorToStr(vError
);
314 wxLogError("Error setting parent for StautsBar. Error: %s\n", sError
);
318 } // end of wxFrame::PositionStatusBar
319 #endif // wxUSE_STATUSBAR
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(
337 HWND hTitlebar
= NULLHANDLE
;
338 HWND hHScroll
= NULLHANDLE
;
339 HWND hVScroll
= NULLHANDLE
;
340 HWND hMenuBar
= NULLHANDLE
;
352 // Actually remove the menu from the frame
354 m_hMenu
= (WXHMENU
)0;
355 InternalSetMenuBar();
357 else // set new non NULL menu bar
359 m_frameMenuBar
= NULL
;
362 // Can set a menubar several times.
363 // TODO: how to prevent a memory leak if you have a currently-unattached
364 // menubar? wxWindows assumes that the frame will delete the menu (otherwise
365 // there are problems for MDI).
367 if (pMenuBar
->GetHMenu())
369 m_hMenu
= pMenuBar
->GetHMenu();
374 m_hMenu
= pMenuBar
->Create();
378 InternalSetMenuBar();
379 m_frameMenuBar
= pMenuBar
;
380 pMenuBar
->Attach((wxFrame
*)this);
382 } // end of wxFrame::SetMenuBar
384 void wxFrame::AttachMenuBar(
388 wxFrameBase::AttachMenuBar(pMenubar
);
390 m_frameMenuBar
= pMenubar
;
395 // Actually remove the menu from the frame
397 m_hMenu
= (WXHMENU
)0;
398 InternalSetMenuBar();
400 else // Set new non NULL menu bar
403 // Can set a menubar several times.
405 if (pMenubar
->GetHMenu())
407 m_hMenu
= pMenubar
->GetHMenu();
411 if (pMenubar
->IsAttached())
414 m_hMenu
= pMenubar
->Create();
419 InternalSetMenuBar();
421 } // end of wxFrame::AttachMenuBar
423 void wxFrame::InternalSetMenuBar()
428 // Set the parent and owner of the menubar to be the frame
430 if (!::WinSetParent(m_hMenu
, m_hFrame
, FALSE
))
432 vError
= ::WinGetLastError(vHabmain
);
433 sError
= wxPMErrorToStr(vError
);
434 wxLogError("Error setting parent for submenu. Error: %s\n", sError
);
437 if (!::WinSetOwner(m_hMenu
, m_hFrame
))
439 vError
= ::WinGetLastError(vHabmain
);
440 sError
= wxPMErrorToStr(vError
);
441 wxLogError("Error setting parent for submenu. Error: %s\n", sError
);
443 ::WinSendMsg(m_hFrame
, WM_UPDATEFRAME
, (MPARAM
)FCF_MENU
, (MPARAM
)0);
444 } // end of wxFrame::InternalSetMenuBar
445 #endif // wxUSE_MENUS_NATIVE
448 // Responds to colour changes, and passes event on to children
450 void wxFrame::OnSysColourChanged(
451 wxSysColourChangedEvent
& rEvent
454 SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_APPWORKSPACE
));
458 if (m_frameStatusBar
)
460 wxSysColourChangedEvent vEvent2
;
462 vEvent2
.SetEventObject(m_frameStatusBar
);
463 m_frameStatusBar
->GetEventHandler()->ProcessEvent(vEvent2
);
465 #endif //wxUSE_STATUSBAR
468 // Propagate the event to the non-top-level children
470 wxWindow::OnSysColourChanged(rEvent
);
471 } // end of wxFrame::OnSysColourChanged
473 // Pass TRUE to show full screen, FALSE to restore.
474 bool wxFrame::ShowFullScreen(
484 m_bFsIsShowing
= TRUE
;
488 wxToolBar
* pTheToolBar
= GetToolBar();
489 #endif //wxUSE_TOOLBAR
492 wxStatusBar
* pTheStatusBar
= GetStatusBar();
493 #endif //wxUSE_STATUSBAR
499 pTheToolBar
->GetSize(&nDummyWidth
, &m_nFsToolBarHeight
);
500 #endif //wxUSE_TOOLBAR
504 pTheStatusBar
->GetSize(&nDummyWidth
, &m_nFsStatusBarHeight
);
505 #endif //wxUSE_STATUSBAR
509 // Zap the toolbar, menubar, and statusbar
511 if ((lStyle
& wxFULLSCREEN_NOTOOLBAR
) && pTheToolBar
)
513 pTheToolBar
->SetSize(-1,0);
514 pTheToolBar
->Show(FALSE
);
516 #endif //wxUSE_TOOLBAR
518 if (lStyle
& wxFULLSCREEN_NOMENUBAR
)
520 ::WinSetParent(m_hMenu
, m_hFrame
, FALSE
);
521 ::WinSetOwner(m_hMenu
, m_hFrame
);
522 ::WinSendMsg((HWND
)m_hFrame
, WM_UPDATEFRAME
, (MPARAM
)FCF_MENU
, (MPARAM
)0);
527 // Save the number of fields in the statusbar
529 if ((lStyle
& wxFULLSCREEN_NOSTATUSBAR
) && pTheStatusBar
)
531 m_nFsStatusBarFields
= pTheStatusBar
->GetFieldsCount();
532 SetStatusBar((wxStatusBar
*) NULL
);
533 delete pTheStatusBar
;
536 m_nFsStatusBarFields
= 0;
537 #endif //wxUSE_STATUSBAR
540 // Zap the frame borders
544 // Save the 'normal' window style
546 m_lFsOldWindowStyle
= ::WinQueryWindowULong(m_hFrame
, QWL_STYLE
);
549 // Save the old position, width & height, maximize state
551 m_vFsOldSize
= GetRect();
552 m_bFsIsMaximized
= IsMaximized();
555 // Decide which window style flags to turn off
557 LONG lNewStyle
= m_lFsOldWindowStyle
;
560 if (lStyle
& wxFULLSCREEN_NOBORDER
)
561 lOffFlags
|= FCF_BORDER
;
562 if (lStyle
& wxFULLSCREEN_NOCAPTION
)
563 lOffFlags
|= (FCF_TASKLIST
| FCF_SYSMENU
);
565 lNewStyle
&= (~lOffFlags
);
568 // Change our window style to be compatible with full-screen mode
570 ::WinSetWindowULong((HWND
)m_hFrame
, QWL_STYLE
, (ULONG
)lNewStyle
);
573 // Resize to the size of the desktop
579 ::WinQueryWindowRect(HWND_DESKTOP
, &vRect
);
580 nWidth
= vRect
.xRight
- vRect
.xLeft
;
582 // Rmember OS/2 is backwards!
584 nHeight
= vRect
.yTop
- vRect
.yBottom
;
591 // Now flush the window style cache and actually go full-screen
593 ::WinSetWindowPos( (HWND
) GetParent()->GetHWND()
602 wxSizeEvent
vEvent( wxSize( nWidth
608 GetEventHandler()->ProcessEvent(vEvent
);
616 m_bFsIsShowing
= FALSE
;
619 wxToolBar
* pTheToolBar
= GetToolBar();
622 // Restore the toolbar, menubar, and statusbar
624 if (pTheToolBar
&& (m_lFsStyle
& wxFULLSCREEN_NOTOOLBAR
))
626 pTheToolBar
->SetSize(-1, m_nFsToolBarHeight
);
627 pTheToolBar
->Show(TRUE
);
629 #endif //wxUSE_TOOLBAR
632 if ((m_lFsStyle
& wxFULLSCREEN_NOSTATUSBAR
) && (m_nFsStatusBarFields
> 0))
634 CreateStatusBar(m_nFsStatusBarFields
);
635 // PositionStatusBar();
637 #endif //wxUSE_STATUSBAR
639 if ((m_lFsStyle
& wxFULLSCREEN_NOMENUBAR
) && (m_hMenu
!= 0))
641 ::WinSetParent(m_hMenu
, m_hFrame
, FALSE
);
642 ::WinSetOwner(m_hMenu
, m_hFrame
);
643 ::WinSendMsg(m_hFrame
, WM_UPDATEFRAME
, (MPARAM
)FCF_MENU
, (MPARAM
)0);
645 Maximize(m_bFsIsMaximized
);
647 ::WinSetWindowULong( m_hFrame
649 ,(ULONG
)m_lFsOldWindowStyle
651 ::WinSetWindowPos( (HWND
) GetParent()->GetHWND()
660 return wxFrameBase::ShowFullScreen(bShow
, lStyle
);
661 } // end of wxFrame::ShowFullScreen
666 // ----------------------------------------------------------------------------
667 // wxFrame size management: we exclude the areas taken by menu/status/toolbars
668 // from the client area, so the client area is what's really available for the
670 // ----------------------------------------------------------------------------
672 // Checks if there is a toolbar, and returns the first free client position
673 wxPoint
wxFrame::GetClientAreaOrigin() const
675 wxPoint
vPoint(0, 0);
683 GetToolBar()->GetSize( &nWidth
687 if (GetToolBar()->GetWindowStyleFlag() & wxTB_VERTICAL
)
693 // PM is backwards from windows
697 #endif //wxUSE_TOOLBAR
699 } // end of wxFrame::GetClientAreaOrigin
701 // ----------------------------------------------------------------------------
702 // tool/status bar stuff
703 // ----------------------------------------------------------------------------
707 wxToolBar
* wxFrame::CreateToolBar(
710 , const wxString
& rName
713 if (wxFrameBase::CreateToolBar( lStyle
720 return m_frameToolBar
;
721 } // end of wxFrame::CreateToolBar
723 void wxFrame::PositionToolBar()
728 ::WinQueryWindowRect(GetHwnd(), &vRect
);
736 GetStatusBar()->GetClientSize( &nStatusX
739 // PM is backwards from windows
740 vRect
.yBottom
+= nStatusY
;
742 #endif // wxUSE_STATUSBAR
744 if ( m_frameToolBar
)
749 m_frameToolBar
->GetSize( &nToolbarWidth
753 if (GetToolBar()->GetWindowStyleFlag() & wxTB_VERTICAL
)
755 nToolbarHeight
= vRect
.yBottom
;
759 nToolbarWidth
= vRect
.xRight
;
763 // Use the 'real' PM position here
765 GetToolBar()->SetSize( 0
769 ,wxSIZE_NO_ADJUSTMENTS
772 } // end of wxFrame::PositionToolBar
773 #endif // wxUSE_TOOLBAR
775 // ----------------------------------------------------------------------------
776 // frame state (iconized/maximized/...)
777 // ----------------------------------------------------------------------------
780 // propagate our state change to all child frames: this allows us to emulate X
781 // Windows behaviour where child frames float independently of the parent one
782 // on the desktop, but are iconized/restored with it
784 void wxFrame::IconizeChildFrames(
788 for (wxWindowList::Node
* pNode
= GetChildren().GetFirst();
790 pNode
= pNode
->GetNext() )
792 wxWindow
* pWin
= pNode
->GetData();
793 wxFrame
* pFrame
= wxDynamicCast(pWin
, wxFrame
);
796 #if wxUSE_MDI_ARCHITECTURE
797 && !wxDynamicCast(pFrame
, wxMDIChildFrame
)
798 #endif // wxUSE_MDI_ARCHITECTURE
802 // We don't want to restore the child frames which had been
803 // iconized even before we were iconized, so save the child frame
804 // status when iconizing the parent frame and check it when
809 pFrame
->m_bWasMinimized
= pFrame
->IsIconized();
813 // This test works for both iconizing and restoring
815 if (!pFrame
->m_bWasMinimized
)
816 pFrame
->Iconize(bIconize
);
819 } // end of wxFrame::IconizeChildFrames
821 WXHICON
wxFrame::GetDefaultIcon() const
823 return (WXHICON
)(wxSTD_FRAME_ICON
? wxSTD_FRAME_ICON
824 : wxDEFAULT_FRAME_ICON
);
826 // ===========================================================================
827 // message processing
828 // ===========================================================================
830 // ---------------------------------------------------------------------------
832 // ---------------------------------------------------------------------------
833 bool wxFrame::OS2TranslateMessage(
838 // try the menu bar accels
840 wxMenuBar
* pMenuBar
= GetMenuBar();
845 #if wxUSE_ACCEL && wxUSE_MENUS_NATIVE
846 const wxAcceleratorTable
& rAcceleratorTable
= pMenuBar
->GetAccelTable();
847 return rAcceleratorTable
.Translate(GetHWND(), pMsg
);
851 } // end of wxFrame::OS2TranslateMessage
853 // ---------------------------------------------------------------------------
854 // our private (non virtual) message handlers
855 // ---------------------------------------------------------------------------
856 bool wxFrame::HandlePaint()
860 if (::WinQueryUpdateRect(GetHWND(), &vRect
))
865 // Icons in PM are the same as "pointers"
867 const wxIcon
& vIcon
= GetIcon();
871 hIcon
= (HPOINTER
)::WinSendMsg(m_hFrame
, WM_QUERYICON
, 0L, 0L);
873 hIcon
= (HPOINTER
)m_hDefaultIcon
;
876 // Hold a pointer to the dc so long as the OnPaint() message
877 // is being processed
880 HPS hPs
= ::WinBeginPaint(GetHwnd(), NULLHANDLE
, &vRect2
);
883 // Erase background before painting or we get white background
885 OS2DefWindowProc(WM_ERASEBACKGROUND
, (MPARAM
)hPs
, (MPARAM
)&vRect2
);
892 ::WinQueryWindowRect(GetHwnd(), &vRect3
);
894 static const int nIconWidth
= 32;
895 static const int nIconHeight
= 32;
896 int nIconX
= (int)((vRect3
.xRight
- nIconWidth
)/2);
897 int nIconY
= (int)((vRect3
.yBottom
+ nIconHeight
)/2);
899 ::WinDrawPointer(hPs
, nIconX
, nIconY
, hIcon
, DP_NORMAL
);
906 if (!wxWindow::HandlePaint())
911 hPS
= ::WinBeginPaint( GetHwnd()
917 ::GpiCreateLogColorTable( hPS
921 ,(LONG
)wxTheColourDatabase
->m_nSize
922 ,(PLONG
)wxTheColourDatabase
->m_palTable
924 ::GpiCreateLogColorTable( hPS
934 ,GetBackgroundColour().GetPixel()
944 // nothing to paint - processed
948 } // end of wxFrame::HandlePaint
950 bool wxFrame::HandleSize(
956 bool bProcessed
= FALSE
;
962 // Only do it it if we were iconized before, otherwise resizing the
963 // parent frame has a curious side effect of bringing it under it's
969 // restore all child frames too
971 IconizeChildFrames(FALSE
);
972 (void)SendIconizeEvent(FALSE
);
984 // Iconize all child frames too
986 IconizeChildFrames(TRUE
);
987 (void)SendIconizeEvent();
995 // forward WM_SIZE to status bar control
997 #if wxUSE_NATIVE_STATUSBAR
998 if (m_frameStatusBar
&& m_frameStatusBar
->IsKindOf(CLASSINFO(wxStatusBar95
)))
1000 wxSizeEvent
vEvent( wxSize( nX
1003 ,m_frameStatusBar
->GetId()
1006 vEvent
.SetEventObject(m_frameStatusBar
);
1007 m_frameStatusBar
->OnSize(vEvent
);
1009 #endif // wxUSE_NATIVE_STATUSBAR
1011 PositionStatusBar();
1014 #endif // wxUSE_TOOLBAR
1016 bProcessed
= wxWindow::HandleSize( nX
1022 } // end of wxFrame::HandleSize
1024 bool wxFrame::HandleCommand(
1033 // In case it's e.g. a toolbar.
1035 wxWindow
* pWin
= wxFindWinFromHandle(hControl
);
1038 return pWin
->OS2Command( nCmd
1044 // Handle here commands from menus and accelerators
1046 if (nCmd
== CMDSRC_MENU
|| nCmd
== CMDSRC_ACCELERATOR
)
1048 #if wxUSE_MENUS_NATIVE
1049 if (wxCurrentPopupMenu
)
1051 wxMenu
* pPopupMenu
= wxCurrentPopupMenu
;
1053 wxCurrentPopupMenu
= NULL
;
1055 return pPopupMenu
->OS2Command( nCmd
1062 if (ProcessCommand(nId
))
1068 } // end of wxFrame::HandleCommand
1070 bool wxFrame::HandleMenuSelect(
1081 rc
= ::WinSendMsg(hMenu
, MM_QUERYITEM
, MPFROM2SHORT(nItem
, TRUE
), (MPARAM
)&mItem
);
1083 if(rc
&& !(mItem
.afStyle
& (MIS_SUBMENU
| MIS_SEPARATOR
)))
1085 wxMenuEvent
vEvent(wxEVT_MENU_HIGHLIGHT
, nItem
);
1087 vEvent
.SetEventObject(this);
1088 GetEventHandler()->ProcessEvent(vEvent
); // return value would be ignored by PM
1092 DoGiveHelp(wxEmptyString
, FALSE
);
1097 } // end of wxFrame::HandleMenuSelect
1099 // ---------------------------------------------------------------------------
1100 // Main Frame window proc
1101 // ---------------------------------------------------------------------------
1102 MRESULT EXPENTRY
wxFrameMainWndProc(
1109 MRESULT rc
= (MRESULT
)0;
1110 bool bProcessed
= FALSE
;
1111 wxFrame
* pWnd
= NULL
;
1113 pWnd
= (wxFrame
*) wxFindWinFromHandle((WXHWND
) hWnd
);
1116 case WM_QUERYFRAMECTLCOUNT
:
1117 if(pWnd
&& pWnd
->m_fnOldWndProc
)
1119 USHORT uItemCount
= SHORT1FROMMR(pWnd
->m_fnOldWndProc(hWnd
, ulMsg
, wParam
, lParam
));
1121 rc
= MRFROMSHORT(uItemCount
);
1125 case WM_FORMATFRAME
:
1126 /////////////////////////////////////////////////////////////////////////////////
1127 // Applications that subclass frame controls may find that the frame is already
1128 // subclassed the number of frame controls is variable.
1129 // The WM_FORMATFRAME and WM_QUERYFRAMECTLCOUNT messages must always be
1130 // subclassed by calling the previous window procedure and modifying its result.
1131 ////////////////////////////////////////////////////////////////////////////////
1141 pSWP
= (PSWP
)PVOIDFROMMP(wParam
);
1142 nItemCount
= SHORT1FROMMR(pWnd
->m_fnOldWndProc(hWnd
, ulMsg
, wParam
, lParam
));
1143 if(pWnd
->m_frameStatusBar
)
1145 ::WinQueryWindowRect(pWnd
->m_frameStatusBar
->GetHWND(), &vRstb
);
1146 pWnd
->m_frameStatusBar
->GetSize(NULL
, &nHeight
);
1147 ::WinQueryWindowRect(pWnd
->m_hFrame
, &vRectl
);
1148 ::WinMapWindowPoints(pWnd
->m_hFrame
, HWND_DESKTOP
, (PPOINTL
)&vRectl
, 2);
1150 ::WinCalcFrameRect(pWnd
->m_hFrame
, &vRectl
, TRUE
);
1152 vSwpStb
.x
= vRectl
.xLeft
- vRstb
.xLeft
;
1153 vSwpStb
.y
= vRectl
.yBottom
- vRstb
.yBottom
;
1154 vSwpStb
.cx
= vRectl
.xRight
- vRectl
.xLeft
- 1; //?? -1 ??
1155 vSwpStb
.cy
= nHeight
;
1156 vSwpStb
.fl
= SWP_SIZE
|SWP_MOVE
| SWP_SHOW
;
1157 vSwpStb
.hwnd
= pWnd
->m_frameStatusBar
->GetHWND();
1158 vSwpStb
.hwndInsertBehind
= HWND_TOP
;
1160 ::WinQueryWindowRect(pWnd
->m_hFrame
, &vRectl
);
1161 ::WinMapWindowPoints(pWnd
->m_hFrame
, HWND_DESKTOP
, (PPOINTL
)&vRectl
, 2);
1162 ::WinCalcFrameRect(pWnd
->m_hFrame
, &vRectl
, TRUE
);
1163 ::WinMapWindowPoints(HWND_DESKTOP
, pWnd
->m_hFrame
, (PPOINTL
)&vRectl
, 2);
1164 for(i
= 0; i
< nItemCount
; i
++)
1166 if(pWnd
->m_hWnd
&& pSWP
[i
].hwnd
== pWnd
->m_hWnd
)
1168 pSWP
[i
].x
= vRectl
.xLeft
;
1169 pSWP
[i
].y
= vRectl
.yBottom
+ nHeight
;
1170 pSWP
[i
].cx
= vRectl
.xRight
- vRectl
.xLeft
;
1171 pSWP
[i
].cy
= vRectl
.yTop
- vRectl
.yBottom
- nHeight
;
1172 pSWP
[i
].fl
= SWP_SIZE
| SWP_MOVE
| SWP_SHOW
;
1173 pSWP
[i
].hwndInsertBehind
= HWND_TOP
;
1177 rc
= MRFROMSHORT(nItemCount
);
1182 if(pWnd
&& pWnd
->m_fnOldWndProc
)
1183 rc
= pWnd
->m_fnOldWndProc(hWnd
, ulMsg
, wParam
, lParam
);
1185 rc
= ::WinDefWindowProc(hWnd
, ulMsg
, wParam
, lParam
);
1188 } // end of wxFrameMainWndProc
1190 MRESULT EXPENTRY
wxFrameWndProc(
1198 // Trace all ulMsgs - useful for the debugging
1201 wxFrame
* pWnd
= NULL
;
1203 parentHwnd
= WinQueryWindow(hWnd
,QW_PARENT
);
1204 pWnd
= (wxFrame
*) wxFindWinFromHandle((WXHWND
) hWnd
);
1207 // When we get the first message for the HWND we just created, we associate
1208 // it with wxWindow stored in wxWndHook
1211 MRESULT rc
= (MRESULT
)0;
1212 bool bProcessed
= FALSE
;
1215 // Stop right here if we don't have a valid handle in our wxWindow object.
1217 if (pWnd
&& !pWnd
->GetHWND())
1219 pWnd
->SetHWND((WXHWND
) hWnd
);
1220 rc
= pWnd
->OS2DefWindowProc(ulMsg
, wParam
, lParam
);
1226 rc
= pWnd
->OS2WindowProc(ulMsg
, wParam
, lParam
);
1228 rc
= ::WinDefWindowProc(hWnd
, ulMsg
, wParam
, lParam
);
1231 } // end of wxFrameWndProc
1233 MRESULT
wxFrame::OS2WindowProc(
1240 bool bProcessed
= FALSE
;
1246 // If we can't close, tell the system that we processed the
1247 // message - otherwise it would close us
1249 bProcessed
= !Close();
1253 bProcessed
= HandlePaint();
1254 mRc
= (MRESULT
)FALSE
;
1257 case WM_ERASEBACKGROUND
:
1259 // Returning TRUE to requests PM to paint the window background
1260 // in SYSCLR_WINDOW. We capture this here because the PS returned
1261 // in Frames is the PS for the whole frame, which we can't really
1262 // use at all. If you want to paint a different background, do it
1263 // in an OnPaint using a wxPaintDC.
1265 mRc
= (MRESULT
)(TRUE
);
1274 UnpackCommand( (WXWPARAM
)wParam
1281 bProcessed
= HandleCommand( wId
1294 UnpackMenuSelect( wParam
1300 bProcessed
= HandleMenuSelect( wItem
1304 mRc
= (MRESULT
)TRUE
;
1310 SHORT nScxold
= SHORT1FROMMP(wParam
); // Old horizontal size.
1311 SHORT nScyold
= SHORT2FROMMP(wParam
); // Old vertical size.
1312 SHORT nScxnew
= SHORT1FROMMP(lParam
); // New horizontal size.
1313 SHORT nScynew
= SHORT2FROMMP(lParam
); // New vertical size.
1315 lParam
= MRFROM2SHORT( nScxnew
- 20
1319 bProcessed
= HandleSize(LOWORD(lParam
), HIWORD(lParam
), (WXUINT
)wParam
);
1320 mRc
= (MRESULT
)FALSE
;
1323 case CM_QUERYDRAGIMAGE
:
1325 const wxIcon
& vIcon
= GetIcon();
1329 hIcon
= (HPOINTER
)::WinSendMsg(GetHWND(), WM_QUERYICON
, 0L, 0L);
1331 hIcon
= (HPOINTER
)m_hDefaultIcon
;
1332 mRc
= (MRESULT
)hIcon
;
1333 bProcessed
= mRc
!= 0;
1339 mRc
= wxWindow::OS2WindowProc( uMessage
1343 return (MRESULT
)mRc
;
1344 } // wxFrame::OS2WindowProc
1346 void wxFrame::SetClient(WXHWND c_Hwnd
)
1348 // Duh...nothing to do under OS/2
1351 void wxFrame::SetClient(
1355 wxWindow
* pOldClient
= this->GetClient();
1356 bool bClientHasFocus
= pOldClient
&& (pOldClient
== wxWindow::FindFocus());
1358 if(pOldClient
== pWindow
) // nothing to do
1360 if(pWindow
== NULL
) // just need to remove old client
1362 if(pOldClient
== NULL
) // nothing to do
1365 if(bClientHasFocus
)
1368 pOldClient
->Enable( FALSE
);
1369 pOldClient
->Show( FALSE
);
1370 ::WinSetWindowUShort(pOldClient
->GetHWND(), QWS_ID
, (USHORT
)pOldClient
->GetId());
1371 // to avoid OS/2 bug need to update frame
1372 ::WinSendMsg((HWND
)this->GetFrame(), WM_UPDATEFRAME
, (MPARAM
)~0, 0);
1377 // Else need to change client
1382 ::WinEnableWindowUpdate((HWND
)GetHWND(), FALSE
);
1385 pOldClient
->Enable(FALSE
);
1386 pOldClient
->Show(FALSE
);
1387 ::WinSetWindowUShort(pOldClient
->GetHWND(), QWS_ID
, (USHORT
)pOldClient
->GetId());
1389 pWindow
->Reparent(this);
1390 ::WinSetWindowUShort(pWindow
->GetHWND(), QWS_ID
, FID_CLIENT
);
1391 ::WinEnableWindowUpdate((HWND
)GetHWND(), TRUE
);
1393 pWindow
->Show(); // ensure client is showing
1394 if( this->IsShown() )
1397 ::WinSendMsg(m_hFrame
, WM_UPDATEFRAME
, (MPARAM
)~0, 0);
1401 wxWindow
* wxFrame::GetClient()
1403 return wxFindWinFromHandle((WXHWND
)::WinWindowFromID(m_hFrame
, FID_CLIENT
));