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