]> git.saurik.com Git - wxWidgets.git/blame - src/os2/frame.cpp
fix for the dialog controls font
[wxWidgets.git] / src / os2 / frame.cpp
CommitLineData
0e320a79
DW
1/////////////////////////////////////////////////////////////////////////////
2// Name: frame.cpp
0367c1c0 3// Purpose: wxFrameOS2
f0a56ab0 4// Author: David Webster
0e320a79 5// Modified by:
29435d81 6// Created: 10/27/99
0e320a79 7// RCS-ID: $Id$
f0a56ab0 8// Copyright: (c) David Webster
0e320a79
DW
9// Licence: wxWindows licence
10/////////////////////////////////////////////////////////////////////////////
11
21802234
DW
12// For compilers that support precompilation, includes "wx.h".
13#include "wx/wxprec.h"
14
15#ifndef WX_PRECOMP
51c1d535
DW
16 #include "wx/defs.h"
17 #include "wx/object.h"
18 #include "wx/dynarray.h"
19 #include "wx/list.h"
20 #include "wx/hash.h"
21 #include "wx/string.h"
22 #include "wx/intl.h"
23 #include "wx/log.h"
24 #include "wx/event.h"
21802234
DW
25 #include "wx/setup.h"
26 #include "wx/frame.h"
27 #include "wx/menu.h"
28 #include "wx/app.h"
29 #include "wx/utils.h"
30 #include "wx/dialog.h"
31 #include "wx/settings.h"
32 #include "wx/dcclient.h"
33#endif // WX_PRECOMP
34
35#include "wx/os2/private.h"
f38374d0
DW
36
37#if wxUSE_STATUSBAR
38 #include "wx/statusbr.h"
ea51d98d 39 #include "wx/generic/statusbr.h"
f38374d0
DW
40#endif // wxUSE_STATUSBAR
41
42#if wxUSE_TOOLBAR
43 #include "wx/toolbar.h"
44#endif // wxUSE_TOOLBAR
45
0e320a79 46#include "wx/menuitem.h"
21802234 47#include "wx/log.h"
0e320a79 48
f38374d0
DW
49// ----------------------------------------------------------------------------
50// globals
51// ----------------------------------------------------------------------------
52
21802234
DW
53extern wxWindowList wxModelessWindows;
54extern wxList WXDLLEXPORT wxPendingDelete;
55extern wxChar wxFrameClassName[];
56extern wxMenu *wxCurrentPopupMenu;
0e320a79 57
b7084589
DW
58extern void wxAssociateWinWithHandle( HWND hWnd
59 ,wxWindow* pWin
60 );
51c1d535 61
f38374d0
DW
62// ----------------------------------------------------------------------------
63// event tables
64// ----------------------------------------------------------------------------
65
0367c1c0
DW
66BEGIN_EVENT_TABLE(wxFrameOS2, wxFrameBase)
67 EVT_ACTIVATE(wxFrameOS2::OnActivate)
68 EVT_SYS_COLOUR_CHANGED(wxFrameOS2::OnSysColourChanged)
0e320a79
DW
69END_EVENT_TABLE()
70
0367c1c0 71#ifndef __WXUNIVERSAL__
8d7ddd02 72IMPLEMENT_DYNAMIC_CLASS(wxFrame, wxWindow)
0367c1c0 73#endif
0e320a79 74
f38374d0
DW
75// ============================================================================
76// implementation
77// ============================================================================
0e320a79 78
f38374d0
DW
79// ----------------------------------------------------------------------------
80// static class members
81// ----------------------------------------------------------------------------
7e99520b 82#if wxUSE_STATUSBAR
0e320a79 83
f38374d0 84#if wxUSE_NATIVE_STATUSBAR
0367c1c0 85 bool wxFrameOS2::m_bUseNativeStatusBar = TRUE;
f38374d0 86#else
0367c1c0 87 bool wxFrameOS2::m_bUseNativeStatusBar = FALSE;
f38374d0 88#endif
0e320a79 89
7e99520b
DW
90#endif //wxUSE_STATUSBAR
91
f38374d0
DW
92// ----------------------------------------------------------------------------
93// creation/destruction
94// ----------------------------------------------------------------------------
95
0367c1c0 96void wxFrameOS2::Init()
0e320a79 97{
80d83cbc 98 m_bIconized = FALSE;
f38374d0 99
21802234 100#if wxUSE_TOOLTIPS
a885d89a 101 m_hWndToolTip = 0;
21802234 102#endif
ea51d98d
DW
103 // Data to save/restore when calling ShowFullScreen
104 m_lFsStyle = 0L;
105 m_lFsOldWindowStyle = 0L;
106 m_nFsStatusBarFields = 0;
107 m_nFsStatusBarHeight = 0;
108 m_nFsToolBarHeight = 0;
109 m_bFsIsMaximized = FALSE;
110 m_bFsIsShowing = FALSE;
64e0c5c6
DW
111 m_bIsShown = FALSE;
112 m_pWinLastFocused = (wxWindow *)NULL;
40bd6154 113
51c1d535
DW
114 m_hFrame = NULL;
115 m_hTitleBar = NULL;
116 m_hHScroll = NULL;
117 m_hVScroll = NULL;
118
40bd6154
DW
119 //
120 // Initialize SWP's
121 //
122 memset(&m_vSwp, 0, sizeof(SWP));
123 memset(&m_vSwpClient, 0, sizeof(SWP));
124 memset(&m_vSwpTitleBar, 0, sizeof(SWP));
125 memset(&m_vSwpMenuBar, 0, sizeof(SWP));
126 memset(&m_vSwpHScroll, 0, sizeof(SWP));
127 memset(&m_vSwpVScroll, 0, sizeof(SWP));
128 memset(&m_vSwpStatusBar, 0, sizeof(SWP));
129 memset(&m_vSwpToolBar, 0, sizeof(SWP));
0367c1c0 130} // end of wxFrameOS2::Init
ea51d98d 131
0367c1c0 132bool wxFrameOS2::Create(
ea51d98d
DW
133 wxWindow* pParent
134, wxWindowID vId
135, const wxString& rsTitle
136, const wxPoint& rPos
137, const wxSize& rSize
a885d89a 138, long lulStyle
ea51d98d
DW
139, const wxString& rsName
140)
f38374d0 141{
ea51d98d
DW
142 int nX = rPos.x;
143 int nY = rPos.y;
144 int nWidth = rSize.x;
145 int nHeight = rSize.y;
51c1d535 146 bool bOk = FALSE;
ea51d98d
DW
147
148 SetName(rsName);
a885d89a 149 m_windowStyle = lulStyle;
ea51d98d 150 m_frameMenuBar = NULL;
7e99520b 151#if wxUSE_TOOLBAR
ea51d98d 152 m_frameToolBar = NULL;
7e99520b
DW
153#endif //wxUSE_TOOLBAR
154
155#if wxUSE_STATUSBAR
ea51d98d 156 m_frameStatusBar = NULL;
7e99520b 157#endif //wxUSE_STATUSBAR
ea51d98d
DW
158
159 SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_APPWORKSPACE));
160
161 if (vId > -1 )
162 m_windowId = vId;
163 else
164 m_windowId = (int)NewControlId();
165
80d83cbc 166 if (pParent)
ea51d98d
DW
167 pParent->AddChild(this);
168
169 m_bIconized = FALSE;
170
ea51d98d
DW
171 if ((m_windowStyle & wxFRAME_FLOAT_ON_PARENT) == 0)
172 pParent = NULL;
173
51c1d535
DW
174 bOk = OS2Create( m_windowId
175 ,pParent
176 ,wxFrameClassName
177 ,this
178 ,rsTitle
179 ,nX
180 ,nY
181 ,nWidth
182 ,nHeight
183 ,lulStyle
184 );
185 if (bOk)
186 {
187 if (!pParent)
188 wxTopLevelWindows.Append(this);
189 wxModelessWindows.Append(this);
190 }
191 return(bOk);
0367c1c0 192} // end of wxFrameOS2::Create
0e320a79 193
0367c1c0 194wxFrameOS2::~wxFrameOS2()
0e320a79 195{
ea51d98d 196 m_isBeingDeleted = TRUE;
e604d44b 197
ea51d98d 198 wxTopLevelWindows.DeleteObject(this);
0e320a79 199
ea51d98d 200 DeleteAllBars();
29435d81 201
ea51d98d
DW
202 if (wxTheApp && (wxTopLevelWindows.Number() == 0))
203 {
204 wxTheApp->SetTopWindow(NULL);
0e320a79 205
ea51d98d
DW
206 if (wxTheApp->GetExitOnFrameDelete())
207 {
4d098649 208 ::WinPostMsg(NULL, WM_QUIT, 0, 0);
ea51d98d
DW
209 }
210 }
5b3ed311 211
ea51d98d
DW
212 wxModelessWindows.DeleteObject(this);
213
214 //
215 // For some reason, wxWindows can activate another task altogether
216 // when a frame is destroyed after a modal dialog has been invoked.
217 // Try to bring the parent to the top.
218 //
219 // MT:Only do this if this frame is currently the active window, else weird
220 // things start to happen.
221 //
222 if (wxGetActiveWindow() == this)
0e320a79 223 {
ea51d98d
DW
224 if (GetParent() && GetParent()->GetHWND())
225 {
ea51d98d
DW
226 ::WinSetWindowPos( (HWND) GetParent()->GetHWND()
227 ,HWND_TOP
80d83cbc
DW
228 ,0
229 ,0
230 ,0
231 ,0
232 ,SWP_ZORDER
ea51d98d
DW
233 );
234 }
0e320a79 235 }
0367c1c0 236} // end of wxFrameOS2::~wxFrame
0e320a79 237
ea51d98d 238//
0e320a79 239// Get size *available for subwindows* i.e. excluding menu bar, toolbar etc.
ea51d98d 240//
0367c1c0 241void wxFrameOS2::DoGetClientSize(
80d83cbc
DW
242 int* pX
243, int* pY
244) const
0e320a79 245{
80d83cbc 246 RECTL vRect;
40bd6154 247 ::WinQueryWindowRect(GetHwnd(), &vRect);
51523f25 248
5fb9d2be
DW
249 //
250 // No need to use statusbar code as in WIN32 as the FORMATFRAME
251 // window procedure ensures PM knows about the new frame client
252 // size internally. A ::WinQueryWindowRect is all that is needed!
253 //
254
80d83cbc 255 if (pX)
51c1d535 256 *pX = vRect.xRight - vRect.xLeft;
80d83cbc 257 if (pY)
51c1d535 258 *pY = vRect.yTop - vRect.yBottom;
0367c1c0 259} // end of wxFrameOS2::DoGetClientSize
0e320a79 260
a885d89a 261//
0e320a79
DW
262// Set the client size (i.e. leave the calculation of borders etc.
263// to wxWindows)
80d83cbc 264//
0367c1c0 265void wxFrameOS2::DoSetClientSize(
80d83cbc
DW
266 int nWidth
267, int nHeight
268)
0e320a79 269{
80d83cbc 270 HWND hWnd = GetHwnd();
80d83cbc 271 RECTL vRect;
a7ef993c 272 RECTL vRect2;
0e320a79 273
40bd6154 274 ::WinQueryWindowRect(GetHwnd(), &vRect);
51c1d535 275 ::WinQueryWindowRect(GetHwnd(), &vRect2);
21802234 276
80d83cbc
DW
277 //
278 // Find the difference between the entire window (title bar and all)
279 // and the client area; add this to the new client size to move the
280 // window. Remember OS/2's backwards y coord system!
281 //
282 int nActualWidth = vRect2.xRight - vRect2.xLeft - vRect.xRight + nWidth;
283 int nActualHeight = vRect2.yTop + vRect2.yTop - vRect.yTop + nHeight;
29435d81 284
f38374d0 285#if wxUSE_STATUSBAR
80d83cbc
DW
286 if ( GetStatusBar() )
287 {
288 int nStatusX;
289 int nStatusY;
290
291 GetStatusBar()->GetClientSize( &nStatusX
292 ,&nStatusY
293 );
294 nActualHeight += nStatusY;
295 }
f38374d0 296#endif // wxUSE_STATUSBAR
29435d81 297
80d83cbc
DW
298 wxPoint vPoint(GetClientAreaOrigin());
299 nActualWidth += vPoint.y;
300 nActualHeight += vPoint.x;
301
302 POINTL vPointl;
303
304 vPointl.x = vRect2.xLeft;
64e0c5c6 305 vPointl.y = vRect2.yTop;
80d83cbc 306
64e0c5c6 307 ::WinSetWindowPos( hWnd
80d83cbc
DW
308 ,HWND_TOP
309 ,vPointl.x
310 ,vPointl.y
311 ,nActualWidth
312 ,nActualHeight
313 ,SWP_MOVE | SWP_SIZE | SWP_SHOW
314 );
315
316 wxSizeEvent vEvent( wxSize( nWidth
317 ,nHeight
318 )
319 ,m_windowId
320 );
321 vEvent.SetEventObject(this);
322 GetEventHandler()->ProcessEvent(vEvent);
0367c1c0 323} // end of wxFrameOS2::DoSetClientSize
80d83cbc 324
0367c1c0 325void wxFrameOS2::DoGetSize(
80d83cbc
DW
326 int* pWidth
327, int* pHeight
328) const
329{
330 RECTL vRect;
21802234 331
51c1d535 332 ::WinQueryWindowRect(m_hFrame, &vRect);
80d83cbc
DW
333 *pWidth = vRect.xRight - vRect.xLeft;
334 *pHeight = vRect.yTop - vRect.yBottom;
0367c1c0 335} // end of wxFrameOS2::DoGetSize
21802234 336
0367c1c0 337void wxFrameOS2::DoGetPosition(
80d83cbc
DW
338 int* pX
339, int* pY
340) const
341{
342 RECTL vRect;
a885d89a 343 POINTL vPoint;
29435d81 344
51c1d535 345 ::WinQueryWindowRect(m_hFrame, &vRect);
0e320a79 346
3febf684
DW
347 *pX = vRect.xRight - vRect.xLeft;
348 *pY = vRect.yTop - vRect.yBottom;
0367c1c0 349} // end of wxFrameOS2::DoGetPosition
0e320a79 350
f38374d0
DW
351// ----------------------------------------------------------------------------
352// variations around ::ShowWindow()
353// ----------------------------------------------------------------------------
354
0367c1c0 355void wxFrameOS2::DoShowWindow(
426d5745 356 int bShowCmd
80d83cbc 357)
0e320a79 358{
51c1d535 359 ::WinShowWindow(m_hFrame, (BOOL)bShowCmd);
64e0c5c6 360 m_bIconized = bShowCmd == SWP_MINIMIZE;
0367c1c0 361} // end of wxFrameOS2::DoShowWindow
21802234 362
0367c1c0 363bool wxFrameOS2::Show(
80d83cbc
DW
364 bool bShow
365)
0e320a79 366{
426d5745
DW
367 SWP vSwp;
368
369 DoShowWindow((int)bShow);
21802234 370
80d83cbc 371 if (bShow)
f38374d0 372 {
80d83cbc
DW
373 wxActivateEvent vEvent(wxEVT_ACTIVATE, TRUE, m_windowId);
374
51c1d535 375 ::WinQueryWindowPos(m_hFrame, &vSwp);
d8530167 376 m_bIconized = vSwp.fl & SWP_MINIMIZE;
51c1d535
DW
377 ::WinSendMsg(m_hFrame, WM_UPDATEFRAME, (MPARAM)~0, 0);
378 ::WinEnableWindow(m_hFrame, TRUE);
80d83cbc
DW
379 vEvent.SetEventObject(this);
380 GetEventHandler()->ProcessEvent(vEvent);
f38374d0
DW
381 }
382 else
383 {
80d83cbc 384 //
f38374d0 385 // Try to highlight the correct window (the parent)
80d83cbc
DW
386 //
387 if (GetParent())
f38374d0 388 {
80d83cbc
DW
389 HWND hWndParent = GetHwndOf(GetParent());
390
426d5745 391 ::WinQueryWindowPos(hWndParent, &vSwp);
d8530167 392 m_bIconized = vSwp.fl & SWP_MINIMIZE;
f38374d0 393 if (hWndParent)
80d83cbc
DW
394 ::WinSetWindowPos( hWndParent
395 ,HWND_TOP
426d5745
DW
396 ,vSwp.x
397 ,vSwp.y
398 ,vSwp.cx
399 ,vSwp.cy
400 ,SWP_ZORDER | SWP_ACTIVATE | SWP_SHOW | SWP_MOVE
80d83cbc 401 );
a0606634 402 ::WinEnableWindow(hWndParent, TRUE);
f38374d0
DW
403 }
404 }
f38374d0 405 return TRUE;
0367c1c0 406} // end of wxFrameOS2::Show
f38374d0 407
0367c1c0 408void wxFrameOS2::Iconize(
80d83cbc
DW
409 bool bIconize
410)
f38374d0 411{
80d83cbc 412 DoShowWindow(bIconize ? SWP_MINIMIZE : SWP_RESTORE);
0367c1c0 413} // end of wxFrameOS2::Iconize
0e320a79 414
0367c1c0 415void wxFrameOS2::Maximize(
80d83cbc 416 bool bMaximize)
0e320a79 417{
80d83cbc 418 DoShowWindow(bMaximize ? SWP_MAXIMIZE : SWP_RESTORE);
0367c1c0 419} // end of wxFrameOS2::Maximize
f38374d0 420
0367c1c0 421void wxFrameOS2::Restore()
f38374d0 422{
80d83cbc 423 DoShowWindow(SWP_RESTORE);
0367c1c0 424} // end of wxFrameOS2::Restore
0e320a79 425
0367c1c0 426bool wxFrameOS2::IsIconized() const
0e320a79 427{
80d83cbc 428 SWP vSwp;
80d83cbc 429
51c1d535 430 ::WinQueryWindowPos(m_hFrame, &vSwp);
a885d89a 431
80d83cbc
DW
432 if (vSwp.fl & SWP_MINIMIZE)
433 ((wxFrame*)this)->m_bIconized = TRUE;
434 else
435 ((wxFrame*)this)->m_bIconized = FALSE;
436 return m_bIconized;
0367c1c0 437} // end of wxFrameOS2::IsIconized
0e320a79 438
21802234 439// Is it maximized?
0367c1c0 440bool wxFrameOS2::IsMaximized() const
0e320a79 441{
80d83cbc
DW
442 SWP vSwp;
443 bool bIconic;
444
51c1d535 445 ::WinQueryWindowPos(m_hFrame, &vSwp);
80d83cbc 446 return (vSwp.fl & SWP_MAXIMIZE);
0367c1c0 447} // end of wxFrameOS2::IsMaximized
0e320a79 448
0367c1c0 449void wxFrameOS2::SetIcon(
0fe536e3
DW
450 const wxIcon& rIcon
451)
0e320a79 452{
0fe536e3 453 wxFrameBase::SetIcon(rIcon);
f38374d0 454
426d5745 455 if ((m_icon.GetHICON()) != NULLHANDLE)
f38374d0 456 {
51c1d535 457 ::WinSendMsg( m_hFrame
f23208ca 458 ,WM_SETICON
426d5745 459 ,(MPARAM)((HPOINTER)m_icon.GetHICON())
f23208ca
DW
460 ,NULL
461 );
51c1d535 462 ::WinSendMsg( m_hFrame
f23208ca
DW
463 ,WM_UPDATEFRAME
464 ,(MPARAM)FCF_ICON
465 ,(MPARAM)0
466 );
f38374d0 467 }
0367c1c0 468} // end of wxFrameOS2::SetIcon
0e320a79 469
21802234 470#if wxUSE_STATUSBAR
0367c1c0 471wxStatusBar* wxFrameOS2::OnCreateStatusBar(
0fe536e3 472 int nNumber
a885d89a 473, long lulStyle
0fe536e3
DW
474, wxWindowID vId
475, const wxString& rName
476)
0e320a79 477{
0fe536e3 478 wxStatusBar* pStatusBar = NULL;
f6bcfd97
BP
479 SWP vSwp;
480 ERRORID vError;
481 wxString sError;
0e320a79 482
0fe536e3 483 pStatusBar = wxFrameBase::OnCreateStatusBar( nNumber
a885d89a 484 ,lulStyle
0fe536e3
DW
485 ,vId
486 ,rName
5b3ed311
DW
487 );
488
489 if( !pStatusBar )
f6bcfd97 490 return NULL;
f6bcfd97 491
51c1d535
DW
492 ::WinSetParent( pStatusBar->GetHWND()
493 ,m_hFrame
494 ,FALSE
495 );
496 ::WinSetOwner( pStatusBar->GetHWND()
497 ,m_hFrame
498 );
7e99520b 499 //
5b3ed311 500 // to show statusbar
f6bcfd97 501 //
51c1d535
DW
502 if(::WinIsWindowShowing(m_hFrame))
503 ::WinSendMsg(m_hFrame, WM_UPDATEFRAME, (MPARAM)~0, 0);
7e99520b 504
0fe536e3 505 return pStatusBar;
0367c1c0 506} // end of wxFrameOS2::OnCreateStatusBar
0e320a79 507
0367c1c0 508void wxFrameOS2::PositionStatusBar()
0e320a79 509{
f6bcfd97
BP
510 SWP vSwp;
511 ERRORID vError;
512 wxString sError;
513
0fe536e3
DW
514 //
515 // Native status bar positions itself
516 //
517 if (m_frameStatusBar)
f38374d0 518 {
a885d89a 519 int nWidth;
a885d89a 520 int nStatbarWidth;
0fe536e3
DW
521 int nStatbarHeight;
522 HWND hWndClient;
523 RECTL vRect;
51c1d535 524 RECTL vFRect;
0fe536e3 525
51c1d535
DW
526 ::WinQueryWindowRect(m_hFrame, &vRect);
527 ::WinMapWindowPoints(m_hFrame, HWND_DESKTOP, (PPOINTL)&vRect, 2);
528 vFRect = vRect;
529 ::WinCalcFrameRect(m_hFrame, &vRect, TRUE);
0fe536e3 530 nWidth = vRect.xRight - vRect.xLeft;
a885d89a 531
0fe536e3
DW
532 m_frameStatusBar->GetSize( &nStatbarWidth
533 ,&nStatbarHeight
534 );
f38374d0 535
0fe536e3 536 //
f38374d0
DW
537 // Since we wish the status bar to be directly under the client area,
538 // we use the adjusted sizes without using wxSIZE_NO_ADJUSTMENTS.
0fe536e3 539 //
51c1d535
DW
540 m_frameStatusBar->SetSize( vRect.xLeft - vFRect.xLeft
541 ,vRect.yBottom - vFRect.yBottom
0fe536e3
DW
542 ,nWidth
543 ,nStatbarHeight
544 );
f6bcfd97
BP
545 if (!::WinQueryWindowPos(m_frameStatusBar->GetHWND(), &vSwp))
546 {
547 vError = ::WinGetLastError(vHabmain);
548 sError = wxPMErrorToStr(vError);
51c1d535 549 wxLogError("Error setting parent for StautsBar. Error: %s\n", sError);
f6bcfd97
BP
550 return;
551 }
f38374d0 552 }
0367c1c0 553} // end of wxFrameOS2::PositionStatusBar
21802234 554#endif // wxUSE_STATUSBAR
0e320a79 555
0367c1c0 556void wxFrameOS2::DetachMenuBar()
0e320a79 557{
21802234 558 if (m_frameMenuBar)
0e320a79 559 {
29435d81 560 m_frameMenuBar->Detach();
0e320a79 561 m_frameMenuBar = NULL;
21802234 562 }
0367c1c0 563} // end of wxFrameOS2::DetachMenuBar
21802234 564
0367c1c0 565void wxFrameOS2::SetMenuBar(
a885d89a 566 wxMenuBar* pMenuBar
0fe536e3 567)
21802234 568{
c3cea748
DW
569 ERRORID vError;
570 wxString sError;
dae16775
DW
571 HWND hTitlebar = NULLHANDLE;
572 HWND hHScroll = NULLHANDLE;
573 HWND hVScroll = NULLHANDLE;
574 HWND hMenuBar = NULLHANDLE;
575 SWP vSwp;
576 SWP vSwpTitlebar;
577 SWP vSwpVScroll;
578 SWP vSwpHScroll;
579 SWP vSwpMenu;
c3cea748 580
0fe536e3 581 if (!pMenuBar)
21802234
DW
582 {
583 DetachMenuBar();
29a99be3 584
64e0c5c6
DW
585 //
586 // Actually remove the menu from the frame
587 //
588 m_hMenu = (WXHMENU)0;
589 InternalSetMenuBar();
29a99be3 590 }
64e0c5c6 591 else // set new non NULL menu bar
c3cea748 592 {
64e0c5c6 593 m_frameMenuBar = NULL;
c3cea748 594
64e0c5c6
DW
595 //
596 // Can set a menubar several times.
597 // TODO: how to prevent a memory leak if you have a currently-unattached
598 // menubar? wxWindows assumes that the frame will delete the menu (otherwise
599 // there are problems for MDI).
600 //
601 if (pMenuBar->GetHMenu())
602 {
603 m_hMenu = pMenuBar->GetHMenu();
604 }
605 else
606 {
607 pMenuBar->Detach();
608 m_hMenu = pMenuBar->Create();
609 if (!m_hMenu)
610 return;
611 }
612 InternalSetMenuBar();
613 m_frameMenuBar = pMenuBar;
0367c1c0 614 pMenuBar->Attach((wxFrame*)this);
c3cea748 615 }
0367c1c0 616} // end of wxFrameOS2::SetMenuBar
0e320a79 617
893758d5
DW
618void wxFrameOS2::AttachMenuBar(
619 wxMenuBar* pMenubar
620)
621{
622 m_frameMenuBar = pMenubar;
623
624 if (!pMenubar)
625 {
626 //
627 // Actually remove the menu from the frame
628 //
629 m_hMenu = (WXHMENU)0;
630 InternalSetMenuBar();
631 }
632 else // Set new non NULL menu bar
633 {
634 //
635 // Can set a menubar several times.
636 //
637 if (pMenubar->GetHMenu())
638 {
639 m_hMenu = pMenubar->GetHMenu();
640 }
641 else
642 {
643 if (pMenubar->IsAttached())
644 pMenubar->Detach();
645
646 m_hMenu = pMenubar->Create();
647
648 if (!m_hMenu)
649 return;
650 }
651 InternalSetMenuBar();
652 }
653} // end of wxFrameOS2::AttachMenuBar
654
0367c1c0 655void wxFrameOS2::InternalSetMenuBar()
0e320a79 656{
64e0c5c6
DW
657 ERRORID vError;
658 wxString sError;
659 //
660 // Set the parent and owner of the menubar to be the frame
661 //
51c1d535 662 if (!::WinSetParent(m_hMenu, m_hFrame, FALSE))
64e0c5c6
DW
663 {
664 vError = ::WinGetLastError(vHabmain);
665 sError = wxPMErrorToStr(vError);
666 wxLogError("Error setting parent for submenu. Error: %s\n", sError);
667 }
668
51c1d535 669 if (!::WinSetOwner(m_hMenu, m_hFrame))
64e0c5c6
DW
670 {
671 vError = ::WinGetLastError(vHabmain);
672 sError = wxPMErrorToStr(vError);
673 wxLogError("Error setting parent for submenu. Error: %s\n", sError);
674 }
b7084589 675 ::WinSendMsg(m_hFrame, WM_UPDATEFRAME, (MPARAM)FCF_MENU, (MPARAM)0);
0367c1c0 676} // end of wxFrameOS2::InternalSetMenuBar
0e320a79 677
a885d89a
DW
678//
679// Responds to colour changes, and passes event on to children
680//
0367c1c0 681void wxFrameOS2::OnSysColourChanged(
a885d89a
DW
682 wxSysColourChangedEvent& rEvent
683)
0e320a79
DW
684{
685 SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_APPWORKSPACE));
686 Refresh();
687
7e99520b 688#if wxUSE_STATUSBAR
a885d89a 689 if (m_frameStatusBar)
0e320a79 690 {
a885d89a
DW
691 wxSysColourChangedEvent vEvent2;
692
693 vEvent2.SetEventObject(m_frameStatusBar);
694 m_frameStatusBar->GetEventHandler()->ProcessEvent(vEvent2);
0e320a79 695 }
7e99520b 696#endif //wxUSE_STATUSBAR
0e320a79 697
a885d89a 698 //
0e320a79 699 // Propagate the event to the non-top-level children
a885d89a
DW
700 //
701 wxWindow::OnSysColourChanged(rEvent);
0367c1c0 702} // end of wxFrameOS2::OnSysColourChanged
21802234 703
542875a8 704// Pass TRUE to show full screen, FALSE to restore.
0367c1c0 705bool wxFrameOS2::ShowFullScreen(
542875a8
DW
706 bool bShow
707, long lStyle
708)
709{
64e0c5c6 710 if (bShow)
542875a8
DW
711 {
712 if (IsFullScreen())
713 return FALSE;
714
64e0c5c6
DW
715 m_bFsIsShowing = TRUE;
716 m_lFsStyle = lStyle;
542875a8 717
7e99520b 718#if wxUSE_TOOLBAR
64e0c5c6 719 wxToolBar* pTheToolBar = GetToolBar();
7e99520b
DW
720#endif //wxUSE_TOOLBAR
721
722#if wxUSE_STATUSBAR
64e0c5c6 723 wxStatusBar* pTheStatusBar = GetStatusBar();
7e99520b 724#endif //wxUSE_STATUSBAR
542875a8 725
64e0c5c6 726 int nDummyWidth;
542875a8 727
7e99520b 728#if wxUSE_TOOLBAR
64e0c5c6
DW
729 if (pTheToolBar)
730 pTheToolBar->GetSize(&nDummyWidth, &m_nFsToolBarHeight);
7e99520b
DW
731#endif //wxUSE_TOOLBAR
732
733#if wxUSE_STATUSBAR
64e0c5c6
DW
734 if (pTheStatusBar)
735 pTheStatusBar->GetSize(&nDummyWidth, &m_nFsStatusBarHeight);
7e99520b 736#endif //wxUSE_STATUSBAR
542875a8 737
7e99520b 738#if wxUSE_TOOLBAR
64e0c5c6
DW
739 //
740 // Zap the toolbar, menubar, and statusbar
741 //
742 if ((lStyle & wxFULLSCREEN_NOTOOLBAR) && pTheToolBar)
542875a8 743 {
64e0c5c6
DW
744 pTheToolBar->SetSize(-1,0);
745 pTheToolBar->Show(FALSE);
542875a8 746 }
7e99520b 747#endif //wxUSE_TOOLBAR
542875a8 748
64e0c5c6
DW
749 if (lStyle & wxFULLSCREEN_NOMENUBAR)
750 {
b7084589
DW
751 ::WinSetParent(m_hMenu, m_hFrame, FALSE);
752 ::WinSetOwner(m_hMenu, m_hFrame);
753 ::WinSendMsg((HWND)m_hFrame, WM_UPDATEFRAME, (MPARAM)FCF_MENU, (MPARAM)0);
64e0c5c6 754 }
542875a8 755
7e99520b 756#if wxUSE_STATUSBAR
64e0c5c6 757 //
542875a8 758 // Save the number of fields in the statusbar
64e0c5c6
DW
759 //
760 if ((lStyle & wxFULLSCREEN_NOSTATUSBAR) && pTheStatusBar)
542875a8 761 {
64e0c5c6 762 m_nFsStatusBarFields = pTheStatusBar->GetFieldsCount();
542875a8 763 SetStatusBar((wxStatusBar*) NULL);
64e0c5c6 764 delete pTheStatusBar;
542875a8
DW
765 }
766 else
64e0c5c6 767 m_nFsStatusBarFields = 0;
7e99520b 768#endif //wxUSE_STATUSBAR
542875a8 769
64e0c5c6
DW
770 //
771 // Zap the frame borders
772 //
542875a8 773
64e0c5c6
DW
774 //
775 // Save the 'normal' window style
776 //
b7084589 777 m_lFsOldWindowStyle = ::WinQueryWindowULong(m_hFrame, QWL_STYLE);
542875a8 778
64e0c5c6 779 //
b7084589 780 // Save the old position, width & height, maximize state
64e0c5c6
DW
781 //
782 m_vFsOldSize = GetRect();
783 m_bFsIsMaximized = IsMaximized();
542875a8 784
64e0c5c6 785 //
b7084589 786 // Decide which window style flags to turn off
64e0c5c6
DW
787 //
788 LONG lNewStyle = m_lFsOldWindowStyle;
789 LONG lOffFlags = 0;
542875a8 790
64e0c5c6
DW
791 if (lStyle & wxFULLSCREEN_NOBORDER)
792 lOffFlags |= FCF_BORDER;
793 if (lStyle & wxFULLSCREEN_NOCAPTION)
794 lOffFlags |= (FCF_TASKLIST | FCF_SYSMENU);
542875a8 795
64e0c5c6 796 lNewStyle &= (~lOffFlags);
542875a8 797
64e0c5c6
DW
798 //
799 // Change our window style to be compatible with full-screen mode
800 //
b7084589 801 ::WinSetWindowULong((HWND)m_hFrame, QWL_STYLE, (ULONG)lNewStyle);
542875a8 802
64e0c5c6
DW
803 //
804 // Resize to the size of the desktop
805 int nWidth;
806 int nHeight;
542875a8 807
64e0c5c6 808 RECTL vRect;
542875a8 809
64e0c5c6
DW
810 ::WinQueryWindowRect(HWND_DESKTOP, &vRect);
811 nWidth = vRect.xRight - vRect.xLeft;
812 //
813 // Rmember OS/2 is backwards!
814 //
815 nHeight = vRect.yTop - vRect.yBottom;
542875a8 816
64e0c5c6
DW
817 SetSize( nWidth
818 ,nHeight
819 );
542875a8 820
64e0c5c6
DW
821 //
822 // Now flush the window style cache and actually go full-screen
823 //
824 ::WinSetWindowPos( (HWND) GetParent()->GetHWND()
825 ,HWND_TOP
826 ,0
827 ,0
828 ,nWidth
829 ,nHeight
830 ,SWP_SIZE | SWP_SHOW
831 );
832
833 wxSizeEvent vEvent( wxSize( nWidth
834 ,nHeight
835 )
836 ,GetId()
837 );
542875a8 838
64e0c5c6 839 GetEventHandler()->ProcessEvent(vEvent);
542875a8
DW
840 return TRUE;
841 }
842 else
843 {
844 if (!IsFullScreen())
845 return FALSE;
846
64e0c5c6 847 m_bFsIsShowing = FALSE;
542875a8 848
7e99520b 849#if wxUSE_TOOLBAR
64e0c5c6 850 wxToolBar* pTheToolBar = GetToolBar();
542875a8 851
64e0c5c6
DW
852 //
853 // Restore the toolbar, menubar, and statusbar
854 //
855 if (pTheToolBar && (m_lFsStyle & wxFULLSCREEN_NOTOOLBAR))
542875a8 856 {
64e0c5c6
DW
857 pTheToolBar->SetSize(-1, m_nFsToolBarHeight);
858 pTheToolBar->Show(TRUE);
542875a8 859 }
7e99520b 860#endif //wxUSE_TOOLBAR
542875a8 861
7e99520b 862#if wxUSE_STATUSBAR
64e0c5c6 863 if ((m_lFsStyle & wxFULLSCREEN_NOSTATUSBAR) && (m_nFsStatusBarFields > 0))
542875a8 864 {
64e0c5c6 865 CreateStatusBar(m_nFsStatusBarFields);
5b3ed311 866// PositionStatusBar();
542875a8 867 }
7e99520b 868#endif //wxUSE_STATUSBAR
542875a8 869
64e0c5c6
DW
870 if ((m_lFsStyle & wxFULLSCREEN_NOMENUBAR) && (m_hMenu != 0))
871 {
b7084589
DW
872 ::WinSetParent(m_hMenu, m_hFrame, FALSE);
873 ::WinSetOwner(m_hMenu, m_hFrame);
874 ::WinSendMsg(m_hFrame, WM_UPDATEFRAME, (MPARAM)FCF_MENU, (MPARAM)0);
64e0c5c6
DW
875 }
876 Maximize(m_bFsIsMaximized);
877
b7084589 878 ::WinSetWindowULong( m_hFrame
64e0c5c6
DW
879 ,QWL_STYLE
880 ,(ULONG)m_lFsOldWindowStyle
881 );
882 ::WinSetWindowPos( (HWND) GetParent()->GetHWND()
883 ,HWND_TOP
884 ,m_vFsOldSize.x
885 ,m_vFsOldSize.y
886 ,m_vFsOldSize.width
887 ,m_vFsOldSize.height
888 ,SWP_SIZE | SWP_SHOW
889 );
542875a8
DW
890 return TRUE;
891 }
0367c1c0 892} // end of wxFrameOS2::ShowFullScreen
542875a8 893
a885d89a
DW
894//
895// Frame window
896//
0367c1c0 897bool wxFrameOS2::OS2Create(
a885d89a
DW
898 int nId
899, wxWindow* pParent
900, const wxChar* zWclass
901, wxWindow* pWxWin
902, const wxChar* zTitle
903, int nX
904, int nY
905, int nWidth
906, int nHeight
907, long ulStyle
908)
21802234 909{
f23208ca
DW
910 ULONG ulCreateFlags = 0L;
911 ULONG ulStyleFlags = 0L;
914589c2 912 ULONG ulExtraFlags = 0L;
f23208ca
DW
913 FRAMECDATA vFrameCtlData;
914 HWND hParent = NULLHANDLE;
f23208ca
DW
915 HWND hTitlebar = NULLHANDLE;
916 HWND hHScroll = NULLHANDLE;
917 HWND hVScroll = NULLHANDLE;
51c1d535
DW
918 HWND hFrame = NULLHANDLE;
919 HWND hClient = NULLHANDLE;
b963e7d5
DW
920 SWP vSwp[10];
921 RECTL vRect[10];
40bd6154 922 USHORT uCtlCount;
51c1d535
DW
923 ERRORID vError;
924 wxString sError;
a885d89a
DW
925
926 m_hDefaultIcon = (WXHICON) (wxSTD_FRAME_ICON ? wxSTD_FRAME_ICON : wxDEFAULT_FRAME_ICON);
a0606634 927
f23208ca
DW
928 if (pParent)
929 hParent = GetWinHwnd(pParent);
930 else
931 hParent = HWND_DESKTOP;
a885d89a 932
914589c2 933 if (ulStyle == wxDEFAULT_FRAME_STYLE)
f23208ca 934 ulCreateFlags = FCF_SIZEBORDER | FCF_TITLEBAR | FCF_SYSMENU |
f6bcfd97 935 FCF_MINMAX | FCF_TASKLIST;
a885d89a 936 else
a885d89a 937 {
914589c2 938 if ((ulStyle & wxCAPTION) == wxCAPTION)
f23208ca 939 ulCreateFlags = FCF_TASKLIST;
914589c2 940 else
f23208ca 941 ulCreateFlags = FCF_NOMOVEWITHOWNER;
914589c2 942
f6bcfd97
BP
943 if ((ulStyle & wxVSCROLL) == wxVSCROLL)
944 ulCreateFlags |= FCF_VERTSCROLL;
945 if ((ulStyle & wxHSCROLL) == wxHSCROLL)
946 ulCreateFlags |= FCF_HORZSCROLL;
914589c2 947 if (ulStyle & wxMINIMIZE_BOX)
f23208ca 948 ulCreateFlags |= FCF_MINBUTTON;
914589c2 949 if (ulStyle & wxMAXIMIZE_BOX)
f23208ca 950 ulCreateFlags |= FCF_MAXBUTTON;
914589c2 951 if (ulStyle & wxTHICK_FRAME)
f23208ca 952 ulCreateFlags |= FCF_DLGBORDER;
914589c2 953 if (ulStyle & wxSYSTEM_MENU)
f23208ca 954 ulCreateFlags |= FCF_SYSMENU;
914589c2 955 if (ulStyle & wxCAPTION)
f23208ca 956 ulCreateFlags |= FCF_TASKLIST;
914589c2
DW
957 if (ulStyle & wxCLIP_CHILDREN)
958 {
959 // Invalid for frame windows under PM
960 }
a885d89a 961
914589c2 962 if (ulStyle & wxTINY_CAPTION_VERT)
f23208ca 963 ulCreateFlags |= FCF_TASKLIST;
914589c2 964 if (ulStyle & wxTINY_CAPTION_HORIZ)
f23208ca
DW
965 ulCreateFlags |= FCF_TASKLIST;
966
914589c2 967 if ((ulStyle & wxTHICK_FRAME) == 0)
f23208ca 968 ulCreateFlags |= FCF_BORDER;
914589c2
DW
969 if (ulStyle & wxFRAME_TOOL_WINDOW)
970 ulExtraFlags = kFrameToolWindow;
21802234 971
914589c2 972 if (ulStyle & wxSTAY_ON_TOP)
f23208ca 973 ulCreateFlags |= FCF_SYSMODAL;
914589c2 974 }
f23208ca
DW
975 if ((ulStyle & wxMINIMIZE) || (ulStyle & wxICONIZE))
976 ulStyleFlags |= WS_MINIMIZED;
977 if (ulStyle & wxMAXIMIZE)
978 ulStyleFlags |= WS_MAXIMIZED;
979
a885d89a
DW
980 //
981 // Clear the visible flag, we always call show
982 //
f23208ca 983 ulStyleFlags &= (unsigned long)~WS_VISIBLE;
a885d89a 984 m_bIconized = FALSE;
f23208ca
DW
985
986 //
987 // Set the frame control block
988 //
989 vFrameCtlData.cb = sizeof(vFrameCtlData);
990 vFrameCtlData.flCreateFlags = ulCreateFlags;
991 vFrameCtlData.hmodResources = 0L;
992 vFrameCtlData.idResources = 0;
993
994 //
51c1d535
DW
995 // Create the frame window: We break ranks with other ports now
996 // and instead of calling down into the base wxWindow class' OS2Create
997 // we do all our own stuff here. We will set the needed pieces
998 // of wxWindow manually, here.
f23208ca 999 //
f23208ca 1000
51c1d535
DW
1001 hFrame = ::WinCreateStdWindow( hParent
1002 ,ulStyleFlags // frame-window style
1003 ,&ulCreateFlags // window style
1004 ,(PSZ)zWclass // class name
1005 ,(PSZ)zTitle // window title
1006 ,0L // default client style
1007 ,NULLHANDLE // resource in executable file
1008 ,0 // resource id
1009 ,&hClient // receives client window handle
1010 );
1011 if (!hFrame)
f23208ca 1012 {
51c1d535
DW
1013 vError = ::WinGetLastError(vHabmain);
1014 sError = wxPMErrorToStr(vError);
1015 wxLogError("Error creating frame. Error: %s\n", sError);
f23208ca
DW
1016 return FALSE;
1017 }
dae16775 1018
7e99520b 1019 //
51c1d535 1020 // wxWindow class' m_hWnd set here and needed associations
5b3ed311 1021 //
51c1d535
DW
1022 m_hFrame = hFrame;
1023 m_hWnd = hClient;
1024 wxAssociateWinWithHandle(m_hWnd, this);
1025 wxAssociateWinWithHandle(m_hFrame, this);
5b3ed311 1026
8d854fa9
DW
1027 m_backgroundColour.Set(wxString("GREY"));
1028
1029 LONG lColor = (LONG)m_backgroundColour.GetPixel();
1030
1031 if (!::WinSetPresParam( m_hWnd
1032 ,PP_BACKGROUNDCOLOR
1033 ,sizeof(LONG)
1034 ,(PVOID)&lColor
1035 ))
1036 {
1037 vError = ::WinGetLastError(vHabmain);
1038 sError = wxPMErrorToStr(vError);
1039 wxLogError("Error creating frame. Error: %s\n", sError);
1040 return FALSE;
1041 }
1042
51c1d535
DW
1043 //
1044 // Now need to subclass window. Instead of calling the SubClassWin in wxWindow
1045 // we manually subclass here because we don't want to use the main wxWndProc
1046 // by default
1047 //
1048 m_fnOldWndProc = (WXFARPROC) ::WinSubclassWindow(m_hFrame, (PFNWP)wxFrameMainWndProc);
5b3ed311 1049
f23208ca
DW
1050 //
1051 // Now size everything. If adding a menu the client will need to be resized.
1052 //
e604d44b 1053
51c1d535 1054 if (!::WinSetWindowPos( m_hFrame
f23208ca
DW
1055 ,HWND_TOP
1056 ,nX
1057 ,nY
1058 ,nWidth
1059 ,nHeight
f6bcfd97 1060 ,SWP_SIZE | SWP_MOVE | SWP_ACTIVATE | SWP_ZORDER
f23208ca 1061 ))
51c1d535
DW
1062 {
1063 vError = ::WinGetLastError(vHabmain);
1064 sError = wxPMErrorToStr(vError);
1065 wxLogError("Error sizing frame. Error: %s\n", sError);
1066 return FALSE;
1067 }
1068 //
1069 // We may have to be smarter here when variable sized toolbars are added!
1070 //
1071 if (!::WinSetWindowPos( m_hWnd
1072 ,HWND_TOP
fb83aca5
DW
1073 ,nX // + 20
1074 ,nY // + 20
1075 ,nWidth // - 60
1076 ,nHeight // - 60
51c1d535
DW
1077 ,SWP_SIZE | SWP_MOVE | SWP_ACTIVATE | SWP_ZORDER
1078 ))
1079 {
1080 vError = ::WinGetLastError(vHabmain);
1081 sError = wxPMErrorToStr(vError);
1082 wxLogError("Error sizing client. Error: %s\n", sError);
f23208ca 1083 return FALSE;
51c1d535 1084 }
a885d89a 1085 return TRUE;
0367c1c0 1086} // end of wxFrameOS2::OS2Create
0e320a79 1087
a885d89a 1088//
0e320a79
DW
1089// Default activation behaviour - set the focus for the first child
1090// subwindow found.
a885d89a 1091//
0367c1c0 1092void wxFrameOS2::OnActivate(
a885d89a
DW
1093 wxActivateEvent& rEvent
1094)
0e320a79 1095{
c4955899 1096 if ( rEvent.GetActive() )
0e320a79 1097 {
c4955899
DW
1098 // restore focus to the child which was last focused
1099 wxLogTrace(_T("focus"), _T("wxFrame %08x activated."), m_hWnd);
21802234 1100
c4955899
DW
1101 wxWindow* pParent = m_pWinLastFocused ? m_pWinLastFocused->GetParent()
1102 : NULL;
1103 if (!pParent)
1104 {
1105 pParent = this;
1106 }
21802234 1107
c4955899
DW
1108 wxSetFocusToChild( pParent
1109 ,&m_pWinLastFocused
1110 );
1111 }
1112 else // deactivating
1113 {
1114 //
1115 // Remember the last focused child if it is our child
1116 //
1117 m_pWinLastFocused = FindFocus();
1118
1119 for (wxWindowList::Node* pNode = GetChildren().GetFirst();
1120 pNode;
1121 pNode = pNode->GetNext())
1122 {
1123 // FIXME all this is totally bogus - we need to do the same as wxPanel,
1124 // but how to do it without duplicating the code?
1125
1126 // restore focus
1127 wxWindow* pChild = pNode->GetData();
1128
1129 if (!pChild->IsTopLevel()
21802234 1130#if wxUSE_TOOLBAR
c4955899 1131 && !wxDynamicCast(pChild, wxToolBar)
21802234
DW
1132#endif // wxUSE_TOOLBAR
1133#if wxUSE_STATUSBAR
c4955899 1134 && !wxDynamicCast(pChild, wxStatusBar)
21802234 1135#endif // wxUSE_STATUSBAR
c4955899
DW
1136 )
1137 {
1138 pChild->SetFocus();
1139 return;
1140 }
21802234 1141 }
0e320a79 1142 }
0367c1c0 1143} // end of wxFrameOS2::OnActivate
0e320a79 1144
f38374d0
DW
1145// ----------------------------------------------------------------------------
1146// wxFrame size management: we exclude the areas taken by menu/status/toolbars
1147// from the client area, so the client area is what's really available for the
1148// frame contents
1149// ----------------------------------------------------------------------------
0e320a79
DW
1150
1151// Checks if there is a toolbar, and returns the first free client position
0367c1c0 1152wxPoint wxFrameOS2::GetClientAreaOrigin() const
0e320a79 1153{
a885d89a
DW
1154 wxPoint vPoint(0, 0);
1155
7e99520b 1156#if wxUSE_TOOLBAR
0e320a79
DW
1157 if (GetToolBar())
1158 {
a885d89a
DW
1159 int nWidth;
1160 int nHeight;
1161
1162 GetToolBar()->GetSize( &nWidth
1163 ,&nHeight
1164 );
0e320a79
DW
1165
1166 if (GetToolBar()->GetWindowStyleFlag() & wxTB_VERTICAL)
1167 {
a885d89a 1168 vPoint.x += nWidth;
0e320a79
DW
1169 }
1170 else
1171 {
a885d89a
DW
1172 // PM is backwards from windows
1173 vPoint.y += nHeight;
0e320a79
DW
1174 }
1175 }
7e99520b 1176#endif //wxUSE_TOOLBAR
a885d89a 1177 return vPoint;
0367c1c0 1178} // end of wxFrameOS2::GetClientAreaOrigin
0e320a79 1179
f38374d0
DW
1180// ----------------------------------------------------------------------------
1181// tool/status bar stuff
1182// ----------------------------------------------------------------------------
1183
21802234 1184#if wxUSE_TOOLBAR
f38374d0 1185
0367c1c0 1186wxToolBar* wxFrameOS2::CreateToolBar(
a885d89a
DW
1187 long lStyle
1188, wxWindowID vId
1189, const wxString& rName
1190)
0e320a79 1191{
a885d89a
DW
1192 if (wxFrameBase::CreateToolBar( lStyle
1193 ,vId
1194 ,rName
1195 ))
0e320a79 1196 {
0e320a79 1197 PositionToolBar();
0e320a79 1198 }
f38374d0 1199 return m_frameToolBar;
0367c1c0 1200} // end of wxFrameOS2::CreateToolBar
0e320a79 1201
0367c1c0 1202void wxFrameOS2::PositionToolBar()
0e320a79 1203{
a885d89a
DW
1204 HWND hWndClient;
1205 RECTL vRect;
1206
40bd6154 1207 ::WinQueryWindowRect(GetHwnd(), &vRect);
0e320a79 1208
f38374d0 1209#if wxUSE_STATUSBAR
a885d89a 1210 if (GetStatusBar())
0e320a79 1211 {
a885d89a
DW
1212 int nStatusX;
1213 int nStatusY;
1214
1215 GetStatusBar()->GetClientSize( &nStatusX
1216 ,&nStatusY
1217 );
1218 // PM is backwards from windows
1219 vRect.yBottom += nStatusY;
0e320a79 1220 }
f38374d0 1221#endif // wxUSE_STATUSBAR
0e320a79 1222
1c84ee88 1223 if ( m_frameToolBar )
0e320a79 1224 {
a885d89a
DW
1225 int nToolbarWidth;
1226 int nToolbarHeight;
1227
1c84ee88 1228 m_frameToolBar->GetSize( &nToolbarWidth
a885d89a
DW
1229 ,&nToolbarHeight
1230 );
0e320a79 1231
a885d89a 1232 if (GetToolBar()->GetWindowStyleFlag() & wxTB_VERTICAL)
0e320a79 1233 {
a885d89a 1234 nToolbarHeight = vRect.yBottom;
0e320a79
DW
1235 }
1236 else
1237 {
a885d89a 1238 nToolbarWidth = vRect.xRight;
21802234 1239 }
f38374d0 1240
a885d89a
DW
1241 //
1242 // Use the 'real' PM position here
1243 //
1244 GetToolBar()->SetSize( 0
1245 ,0
1246 ,nToolbarWidth
1247 ,nToolbarHeight
1248 ,wxSIZE_NO_ADJUSTMENTS
1249 );
21802234 1250 }
0367c1c0 1251} // end of wxFrameOS2::PositionToolBar
21802234
DW
1252#endif // wxUSE_TOOLBAR
1253
f38374d0
DW
1254// ----------------------------------------------------------------------------
1255// frame state (iconized/maximized/...)
1256// ----------------------------------------------------------------------------
1257
a885d89a 1258//
21802234
DW
1259// propagate our state change to all child frames: this allows us to emulate X
1260// Windows behaviour where child frames float independently of the parent one
1261// on the desktop, but are iconized/restored with it
a885d89a 1262//
0367c1c0 1263void wxFrameOS2::IconizeChildFrames(
a885d89a
DW
1264 bool bIconize
1265)
21802234 1266{
a885d89a
DW
1267 for (wxWindowList::Node* pNode = GetChildren().GetFirst();
1268 pNode;
1269 pNode = pNode->GetNext() )
21802234 1270 {
a885d89a 1271 wxWindow* pWin = pNode->GetData();
21802234 1272
a885d89a 1273 if (pWin->IsKindOf(CLASSINFO(wxFrame)) )
21802234 1274 {
a885d89a 1275 ((wxFrame *)pWin)->Iconize(bIconize);
0e320a79
DW
1276 }
1277 }
0367c1c0 1278} // end of wxFrameOS2::IconizeChildFrames
0e320a79 1279
21802234
DW
1280// ===========================================================================
1281// message processing
1282// ===========================================================================
1283
1284// ---------------------------------------------------------------------------
1285// preprocessing
1286// ---------------------------------------------------------------------------
0367c1c0 1287bool wxFrameOS2::OS2TranslateMessage(
a885d89a
DW
1288 WXMSG* pMsg
1289)
21802234 1290{
a885d89a 1291 //
21802234 1292 // try the menu bar accels
a885d89a
DW
1293 //
1294 wxMenuBar* pMenuBar = GetMenuBar();
1295
1296 if (!pMenuBar )
21802234
DW
1297 return FALSE;
1298
7e99520b 1299#if wxUSE_ACCEL
a885d89a 1300 const wxAcceleratorTable& rAcceleratorTable = pMenuBar->GetAccelTable();
e604d44b 1301 return rAcceleratorTable.Translate(GetHWND(), pMsg);
7e99520b
DW
1302#else
1303 return FALSE;
1304#endif //wxUSE_ACCEL
0367c1c0 1305} // end of wxFrameOS2::OS2TranslateMessage
21802234
DW
1306
1307// ---------------------------------------------------------------------------
1308// our private (non virtual) message handlers
1309// ---------------------------------------------------------------------------
0367c1c0 1310bool wxFrameOS2::HandlePaint()
21802234 1311{
a885d89a
DW
1312 RECTL vRect;
1313
e604d44b 1314 if (::WinQueryUpdateRect(GetHWND(), &vRect))
29435d81 1315 {
a885d89a 1316 if (m_bIconized)
29435d81 1317 {
a885d89a
DW
1318 //
1319 // Icons in PM are the same as "pointers"
1320 //
1321 HPOINTER hIcon;
29435d81 1322
a885d89a 1323 if (m_icon.Ok())
b7084589 1324 hIcon = (HPOINTER)::WinSendMsg(m_hFrame, WM_QUERYICON, 0L, 0L);
a885d89a
DW
1325 else
1326 hIcon = (HPOINTER)m_hDefaultIcon;
1327
1328 //
21802234
DW
1329 // Hold a pointer to the dc so long as the OnPaint() message
1330 // is being processed
a885d89a
DW
1331 //
1332 RECTL vRect2;
64e0c5c6 1333 HPS hPs = ::WinBeginPaint(GetHwnd(), NULLHANDLE, &vRect2);
29435d81 1334
a885d89a 1335 //
29435d81 1336 // Erase background before painting or we get white background
a885d89a
DW
1337 //
1338 OS2DefWindowProc(WM_ERASEBACKGROUND, (MPARAM)hPs, (MPARAM)&vRect2);
29435d81 1339
a885d89a 1340 if (hIcon)
29435d81 1341 {
a885d89a
DW
1342 HWND hWndClient;
1343 RECTL vRect3;
21802234 1344
40bd6154 1345 ::WinQueryWindowRect(GetHwnd(), &vRect3);
29435d81 1346
a885d89a
DW
1347 static const int nIconWidth = 32;
1348 static const int nIconHeight = 32;
1349 int nIconX = (int)((vRect3.xRight - nIconWidth)/2);
1350 int nIconY = (int)((vRect3.yBottom + nIconHeight)/2);
29435d81 1351
a885d89a 1352 ::WinDrawPointer(hPs, nIconX, nIconY, hIcon, DP_NORMAL);
29435d81 1353 }
a885d89a 1354 ::WinEndPaint(hPs);
29435d81
DW
1355 return TRUE;
1356 }
1357 else
1358 {
8d854fa9 1359 return(wxWindow::HandlePaint());
29435d81
DW
1360 }
1361 }
1362 else
1363 {
1364 // nothing to paint - processed
1365 return TRUE;
1366 }
29435d81 1367 return FALSE;
0367c1c0 1368} // end of wxFrameOS2::HandlePaint
21802234 1369
0367c1c0 1370bool wxFrameOS2::HandleSize(
a885d89a
DW
1371 int nX
1372, int nY
1373, WXUINT nId
1374)
21802234 1375{
a885d89a 1376 bool bProcessed = FALSE;
21802234 1377
a885d89a 1378 switch (nId)
21802234 1379 {
a885d89a
DW
1380 case kSizeNormal:
1381 //
1382 // Only do it it if we were iconized before, otherwise resizing the
21802234
DW
1383 // parent frame has a curious side effect of bringing it under it's
1384 // children
a885d89a 1385 if (!m_bIconized )
21802234
DW
1386 break;
1387
a885d89a 1388 //
21802234 1389 // restore all child frames too
a885d89a 1390 //
21802234 1391 IconizeChildFrames(FALSE);
3febf684 1392 (void)SendIconizeEvent(FALSE);
21802234 1393
a885d89a 1394 //
21802234 1395 // fall through
a885d89a 1396 //
21802234 1397
a885d89a
DW
1398 case kSizeMax:
1399 m_bIconized = FALSE;
21802234
DW
1400 break;
1401
a885d89a
DW
1402 case kSizeMin:
1403 //
1404 // Iconize all child frames too
1405 //
21802234 1406 IconizeChildFrames(TRUE);
3febf684 1407 (void)SendIconizeEvent();
a885d89a 1408 m_bIconized = TRUE;
21802234
DW
1409 break;
1410 }
f38374d0 1411
a885d89a 1412 if (!m_bIconized)
21802234 1413 {
a885d89a 1414 //
29435d81 1415 // forward WM_SIZE to status bar control
a885d89a 1416 //
f38374d0
DW
1417#if wxUSE_NATIVE_STATUSBAR
1418 if (m_frameStatusBar && m_frameStatusBar->IsKindOf(CLASSINFO(wxStatusBar95)))
1419 {
a885d89a
DW
1420 wxSizeEvent vEvent( wxSize( nX
1421 ,nY
1422 )
1423 ,m_frameStatusBar->GetId()
1424 );
f38374d0 1425
a885d89a
DW
1426 vEvent.SetEventObject(m_frameStatusBar);
1427 m_frameStatusBar->OnSize(vEvent);
f38374d0
DW
1428 }
1429#endif // wxUSE_NATIVE_STATUSBAR
1430
51c1d535 1431 PositionStatusBar();
7e99520b 1432#if wxUSE_TOOLBAR
21802234 1433 PositionToolBar();
7e99520b
DW
1434#endif // wxUSE_TOOLBAR
1435
a885d89a
DW
1436 wxSizeEvent vEvent( wxSize( nX
1437 ,nY
1438 )
1439 ,m_windowId
1440 );
21802234 1441
a885d89a
DW
1442 vEvent.SetEventObject(this);
1443 bProcessed = GetEventHandler()->ProcessEvent(vEvent);
21802234 1444 }
a885d89a 1445 return bProcessed;
0367c1c0 1446} // end of wxFrameOS2::HandleSize
21802234 1447
0367c1c0 1448bool wxFrameOS2::HandleCommand(
a885d89a
DW
1449 WXWORD nId
1450, WXWORD nCmd
1451, WXHWND hControl
1452)
21802234 1453{
a885d89a 1454 if (hControl)
21802234 1455 {
a885d89a 1456 //
21802234 1457 // In case it's e.g. a toolbar.
a885d89a
DW
1458 //
1459 wxWindow* pWin = wxFindWinFromHandle(hControl);
1460
1461 if (pWin)
1462 return pWin->OS2Command( nCmd
1463 ,nId
1464 );
21802234
DW
1465 }
1466
a885d89a
DW
1467 //
1468 // Handle here commands from menus and accelerators
1469 //
5b3ed311 1470 if (nCmd == CMDSRC_MENU || nCmd == CMDSRC_ACCELERATOR)
21802234 1471 {
a885d89a 1472 if (wxCurrentPopupMenu)
21802234 1473 {
a885d89a
DW
1474 wxMenu* pPopupMenu = wxCurrentPopupMenu;
1475
21802234
DW
1476 wxCurrentPopupMenu = NULL;
1477
a885d89a
DW
1478 return pPopupMenu->OS2Command( nCmd
1479 ,nId
1480 );
21802234
DW
1481 }
1482
a885d89a 1483 if (ProcessCommand(nId))
21802234
DW
1484 {
1485 return TRUE;
1486 }
1487 }
21802234 1488 return FALSE;
0367c1c0 1489} // end of wxFrameOS2::HandleCommand
21802234 1490
0367c1c0 1491bool wxFrameOS2::HandleMenuSelect(
a885d89a
DW
1492 WXWORD nItem
1493, WXWORD nFlags
1494, WXHMENU hMenu
1495)
21802234 1496{
e604d44b
DW
1497 if( !nFlags )
1498 {
1499 MENUITEM mItem;
1500 MRESULT rc;
1501
51c1d535 1502 rc = ::WinSendMsg(hMenu, MM_QUERYITEM, MPFROM2SHORT(nItem, TRUE), (MPARAM)&mItem);
e604d44b
DW
1503
1504 if(rc && !(mItem.afStyle & (MIS_SUBMENU | MIS_SEPARATOR)))
1505 {
1506 wxMenuEvent vEvent(wxEVT_MENU_HIGHLIGHT, nItem);
1507
1508 vEvent.SetEventObject(this);
1509 GetEventHandler()->ProcessEvent(vEvent); // return value would be ignored by PM
1510 }
1511 }
1512 return TRUE;
0367c1c0 1513} // end of wxFrameOS2::HandleMenuSelect
21802234
DW
1514
1515// ---------------------------------------------------------------------------
51c1d535 1516// Main Frame window proc
21802234 1517// ---------------------------------------------------------------------------
51c1d535
DW
1518MRESULT EXPENTRY wxFrameMainWndProc(
1519 HWND hWnd
1520, ULONG ulMsg
1521, MPARAM wParam
1522, MPARAM lParam
1523)
1524{
1525 MRESULT rc = (MRESULT)0;
1526 bool bProcessed = FALSE;
1527 wxFrame* pWnd = NULL;
1528
1529 pWnd = (wxFrame*) wxFindWinFromHandle((WXHWND) hWnd);
1530 switch (ulMsg)
1531 {
1532 case WM_QUERYFRAMECTLCOUNT:
1533 if(pWnd && pWnd->m_fnOldWndProc)
1534 {
1535 USHORT uItemCount = SHORT1FROMMR(pWnd->m_fnOldWndProc(hWnd, ulMsg, wParam, lParam));
1536
1537 rc = MRFROMSHORT(uItemCount);
1538 }
1539 break;
1540
1541 case WM_FORMATFRAME:
1542/////////////////////////////////////////////////////////////////////////////////
1543// Applications that subclass frame controls may find that the frame is already
1544// subclassed the number of frame controls is variable.
1545// The WM_FORMATFRAME and WM_QUERYFRAMECTLCOUNT messages must always be
1546// subclassed by calling the previous window procedure and modifying its result.
1547////////////////////////////////////////////////////////////////////////////////
1548 {
1549 int nItemCount;
1550 int i;
1551 PSWP pSWP = NULL;
1552 SWP vSwpStb;
1553 RECTL vRectl;
1554 RECTL vRstb;
1555 int nHeight=0;
1556
1557 pSWP = (PSWP)PVOIDFROMMP(wParam);
1558 nItemCount = SHORT1FROMMR(pWnd->m_fnOldWndProc(hWnd, ulMsg, wParam, lParam));
1559 if(pWnd->m_frameStatusBar)
1560 {
1561 ::WinQueryWindowRect(pWnd->m_frameStatusBar->GetHWND(), &vRstb);
1562 pWnd->m_frameStatusBar->GetSize(NULL, &nHeight);
1563 ::WinQueryWindowRect(pWnd->m_hFrame, &vRectl);
1564 ::WinMapWindowPoints(pWnd->m_hFrame, HWND_DESKTOP, (PPOINTL)&vRectl, 2);
1565 vRstb = vRectl;
1566 ::WinCalcFrameRect(pWnd->m_hFrame, &vRectl, TRUE);
1567
1568 vSwpStb.x = vRectl.xLeft - vRstb.xLeft;
1569 vSwpStb.y = vRectl.yBottom - vRstb.yBottom;
1570 vSwpStb.cx = vRectl.xRight - vRectl.xLeft - 1; //?? -1 ??
1571 vSwpStb.cy = nHeight;
1572 vSwpStb.fl = SWP_SIZE |SWP_MOVE | SWP_SHOW;
1573 vSwpStb.hwnd = pWnd->m_frameStatusBar->GetHWND();
1574 vSwpStb.hwndInsertBehind = HWND_TOP;
1575 }
1576 ::WinQueryWindowRect(pWnd->m_hFrame, &vRectl);
1577 ::WinMapWindowPoints(pWnd->m_hFrame, HWND_DESKTOP, (PPOINTL)&vRectl, 2);
1578 ::WinCalcFrameRect(pWnd->m_hFrame, &vRectl, TRUE);
1579 ::WinMapWindowPoints(HWND_DESKTOP, pWnd->m_hFrame, (PPOINTL)&vRectl, 2);
1580 for(i = 0; i < nItemCount; i++)
1581 {
1582 if(pWnd->m_hWnd && pSWP[i].hwnd == pWnd->m_hWnd)
1583 {
1584 pSWP[i].x = vRectl.xLeft;
1585 pSWP[i].y = vRectl.yBottom + nHeight;
1586 pSWP[i].cx = vRectl.xRight - vRectl.xLeft;
1587 pSWP[i].cy = vRectl.yTop - vRectl.yBottom - nHeight;
1588 pSWP[i].fl = SWP_SIZE | SWP_MOVE | SWP_SHOW;
1589 pSWP[i].hwndInsertBehind = HWND_TOP;
1590 }
1591 }
1592 bProcessed = TRUE;
1593 rc = MRFROMSHORT(nItemCount);
1594 }
1595 break;
1596
1597 default:
1598 if(pWnd && pWnd->m_fnOldWndProc)
1599 rc = pWnd->m_fnOldWndProc(hWnd, ulMsg, wParam, lParam);
1600 else
1601 rc = ::WinDefWindowProc(hWnd, ulMsg, wParam, lParam);
1602 }
1603 return rc;
1604} // end of wxFrameMainWndProc
1605
1606MRESULT EXPENTRY wxFrameWndProc(
1607 HWND hWnd
1608, ULONG ulMsg
1609, MPARAM wParam
1610, MPARAM lParam
1611)
1612{
1613 //
1614 // Trace all ulMsgs - useful for the debugging
1615 //
1616 HWND parentHwnd;
1617 wxFrame* pWnd = NULL;
1618
1619 parentHwnd = WinQueryWindow(hWnd,QW_PARENT);
1620 pWnd = (wxFrame*) wxFindWinFromHandle((WXHWND) hWnd);
1621
1622 //
1623 // When we get the first message for the HWND we just created, we associate
1624 // it with wxWindow stored in wxWndHook
1625 //
51c1d535
DW
1626
1627 MRESULT rc = (MRESULT)0;
1628 bool bProcessed = FALSE;
1629
1630 //
1631 // Stop right here if we don't have a valid handle in our wxWindow object.
1632 //
1633 if (pWnd && !pWnd->GetHWND())
1634 {
1635 pWnd->SetHWND((WXHWND) hWnd);
1636 rc = pWnd->OS2DefWindowProc(ulMsg, wParam, lParam );
1637 pWnd->SetHWND(0);
1638 }
1639 else
1640 {
d08f23a7
DW
1641 if (pWnd)
1642 rc = pWnd->OS2WindowProc(ulMsg, wParam, lParam);
1643 else
1644 rc = ::WinDefWindowProc(hWnd, ulMsg, wParam, lParam);
51c1d535
DW
1645 }
1646 return rc;
1647} // end of wxFrameWndProc
21802234 1648
0367c1c0 1649MRESULT wxFrameOS2::OS2WindowProc(
a885d89a
DW
1650 WXUINT uMessage
1651, WXWPARAM wParam
1652, WXLPARAM lParam
1653)
21802234 1654{
a885d89a
DW
1655 MRESULT mRc = 0L;
1656 bool bProcessed = FALSE;
21802234 1657
a885d89a 1658 switch (uMessage)
21802234
DW
1659 {
1660 case WM_CLOSE:
a885d89a
DW
1661 //
1662 // If we can't close, tell the system that we processed the
21802234 1663 // message - otherwise it would close us
a885d89a
DW
1664 //
1665 bProcessed = !Close();
21802234
DW
1666 break;
1667
d08f23a7 1668 case WM_PAINT:
8d854fa9
DW
1669 bProcessed = HandlePaint();
1670 mRc = (MRESULT)FALSE;
1671 break;
d08f23a7 1672
8d854fa9
DW
1673 case WM_ERASEBACKGROUND:
1674 //
1675 // Returning TRUE to requests PM to paint the window background
1676 // in SYSCLR_WINDOW. We capture this here because the PS returned
1677 // in Frames is the PS for the whole frame, which we can't really
1678 // use at all. If you want to paint a different background, do it
1679 // in an OnPaint using a wxPaintDC.
1680 //
1681 mRc = (MRESULT)(TRUE);
d08f23a7
DW
1682 break;
1683
8d854fa9 1684 case WM_COMMAND:
21802234 1685 {
a885d89a
DW
1686 WORD wId;
1687 WORD wCmd;
1688 WXHWND hWnd;
1689
1690 UnpackCommand( (WXWPARAM)wParam
d08f23a7
DW
1691 ,(WXLPARAM)lParam
1692 ,&wId
1693 ,&hWnd
1694 ,&wCmd
1695 );
5b3ed311 1696
a885d89a
DW
1697 bProcessed = HandleCommand( wId
1698 ,wCmd
1699 ,(WXHWND)hWnd
1700 );
21802234
DW
1701 }
1702 break;
1703
1704 case WM_MENUSELECT:
1705 {
a885d89a
DW
1706 WXWORD wItem;
1707 WXWORD wFlags;
1708 WXHMENU hMenu;
1709
1710 UnpackMenuSelect( wParam
1711 ,lParam
1712 ,&wItem
1713 ,&wFlags
1714 ,&hMenu
1715 );
1716 bProcessed = HandleMenuSelect( wItem
1717 ,wFlags
1718 ,hMenu
1719 );
e604d44b 1720 mRc = (MRESULT)TRUE;
21802234
DW
1721 }
1722 break;
1723
d08f23a7
DW
1724 case WM_SIZE:
1725 {
1726 SHORT nScxold = SHORT1FROMMP(wParam); // Old horizontal size.
1727 SHORT nScyold = SHORT2FROMMP(wParam); // Old vertical size.
1728 SHORT nScxnew = SHORT1FROMMP(lParam); // New horizontal size.
1729 SHORT nScynew = SHORT2FROMMP(lParam); // New vertical size.
1730
1731 lParam = MRFROM2SHORT( nScxnew - 20
1732 ,nScynew - 30
1733 );
1734 }
1735 bProcessed = HandleSize(LOWORD(lParam), HIWORD(lParam), (WXUINT)wParam);
1736 mRc = (MRESULT)FALSE;
21802234
DW
1737 break;
1738
a885d89a 1739 case CM_QUERYDRAGIMAGE:
21802234 1740 {
a885d89a
DW
1741 HPOINTER hIcon;
1742
1743 if (m_icon.Ok())
e604d44b 1744 hIcon = (HPOINTER)::WinSendMsg(GetHWND(), WM_QUERYICON, 0L, 0L);
a885d89a
DW
1745 else
1746 hIcon = (HPOINTER)m_hDefaultIcon;
1747 mRc = (MRESULT)hIcon;
1748 bProcessed = mRc != 0;
21802234
DW
1749 }
1750 break;
21802234 1751 }
f38374d0 1752
a885d89a
DW
1753 if (!bProcessed )
1754 mRc = wxWindow::OS2WindowProc( uMessage
1755 ,wParam
1756 ,lParam
1757 );
e604d44b 1758 return (MRESULT)mRc;
0367c1c0 1759} // wxFrameOS2::OS2WindowProc
21802234 1760
0367c1c0 1761void wxFrameOS2::SetClient(WXHWND c_Hwnd)
5b3ed311 1762{
51c1d535 1763 // Duh...nothing to do under OS/2
5b3ed311
DW
1764}
1765
0367c1c0 1766void wxFrameOS2::SetClient(
51c1d535
DW
1767 wxWindow* pWindow
1768)
5b3ed311 1769{
51c1d535
DW
1770 wxWindow* pOldClient = this->GetClient();
1771 bool bClientHasFocus = pOldClient && (pOldClient == wxWindow::FindFocus());
5b3ed311 1772
51c1d535 1773 if(pOldClient == pWindow) // nothing to do
5b3ed311 1774 return;
51c1d535
DW
1775 if(pWindow == NULL) // just need to remove old client
1776 {
1777 if(pOldClient == NULL) // nothing to do
1778 return;
5b3ed311 1779
51c1d535 1780 if(bClientHasFocus )
5b3ed311
DW
1781 this->SetFocus();
1782
51c1d535
DW
1783 pOldClient->Enable( FALSE );
1784 pOldClient->Show( FALSE );
1785 ::WinSetWindowUShort(pOldClient->GetHWND(), QWS_ID, (USHORT)pOldClient->GetId());
5b3ed311 1786 // to avoid OS/2 bug need to update frame
b7084589 1787 ::WinSendMsg((HWND)this->GetFrame(), WM_UPDATEFRAME, (MPARAM)~0, 0);
5b3ed311 1788 return;
51c1d535 1789 }
5b3ed311 1790
51c1d535
DW
1791 //
1792 // Else need to change client
1793 //
1794 if(bClientHasFocus)
5b3ed311
DW
1795 this->SetFocus();
1796
51c1d535
DW
1797 ::WinEnableWindowUpdate((HWND)GetHWND(), FALSE);
1798 if(pOldClient)
1799 {
1800 pOldClient->Enable(FALSE);
1801 pOldClient->Show(FALSE);
1802 ::WinSetWindowUShort(pOldClient->GetHWND(), QWS_ID, (USHORT)pOldClient->GetId());
1803 }
1804 pWindow->Reparent(this);
1805 ::WinSetWindowUShort(pWindow->GetHWND(), QWS_ID, FID_CLIENT);
1806 ::WinEnableWindowUpdate((HWND)GetHWND(), TRUE);
1807 pWindow->Enable();
1808 pWindow->Show(); // ensure client is showing
1809 if( this->IsShown() )
1810 {
1811 this->Show();
b7084589 1812 ::WinSendMsg(m_hFrame, WM_UPDATEFRAME, (MPARAM)~0, 0);
51c1d535 1813 }
5b3ed311
DW
1814}
1815
0367c1c0 1816wxWindow* wxFrameOS2::GetClient()
5b3ed311 1817{
b7084589 1818 return wxFindWinFromHandle((WXHWND)::WinWindowFromID(m_hFrame, FID_CLIENT));
5b3ed311 1819}