1 /////////////////////////////////////////////////////////////////////////////
4 // Author: Julian Smart
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 // ============================================================================
14 // ============================================================================
16 // ----------------------------------------------------------------------------
18 // ----------------------------------------------------------------------------
20 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
21 #pragma implementation "frame.h"
24 // For compilers that support precompilation, includes "wx.h".
25 #include "wx/wxprec.h"
36 #include "wx/dialog.h"
37 #include "wx/settings.h"
38 #include "wx/dcclient.h"
43 #include "wx/msw/private.h"
50 #include "wx/statusbr.h"
51 #include "wx/generic/statusbr.h"
52 #endif // wxUSE_STATUSBAR
55 #include "wx/toolbar.h"
56 #endif // wxUSE_TOOLBAR
58 #include "wx/menuitem.h"
61 #ifdef __WXUNIVERSAL__
62 #include "wx/univ/theme.h"
63 #include "wx/univ/colschem.h"
64 #endif // __WXUNIVERSAL__
66 // ----------------------------------------------------------------------------
68 // ----------------------------------------------------------------------------
70 #if wxUSE_MENUS_NATIVE
71 extern wxMenu
*wxCurrentPopupMenu
;
72 #endif // wxUSE_MENUS_NATIVE
74 // ----------------------------------------------------------------------------
76 // ----------------------------------------------------------------------------
78 BEGIN_EVENT_TABLE(wxFrame
, wxFrameBase
)
79 EVT_SYS_COLOUR_CHANGED(wxFrame::OnSysColourChanged
)
82 #if wxUSE_EXTENDED_RTTI
83 WX_DEFINE_FLAGS( wxFrameStyle
)
85 wxBEGIN_FLAGS( wxFrameStyle
)
86 // new style border flags, we put them first to
87 // use them for streaming out
88 wxFLAGS_MEMBER(wxBORDER_SIMPLE
)
89 wxFLAGS_MEMBER(wxBORDER_SUNKEN
)
90 wxFLAGS_MEMBER(wxBORDER_DOUBLE
)
91 wxFLAGS_MEMBER(wxBORDER_RAISED
)
92 wxFLAGS_MEMBER(wxBORDER_STATIC
)
93 wxFLAGS_MEMBER(wxBORDER_NONE
)
95 // old style border flags
96 wxFLAGS_MEMBER(wxSIMPLE_BORDER
)
97 wxFLAGS_MEMBER(wxSUNKEN_BORDER
)
98 wxFLAGS_MEMBER(wxDOUBLE_BORDER
)
99 wxFLAGS_MEMBER(wxRAISED_BORDER
)
100 wxFLAGS_MEMBER(wxSTATIC_BORDER
)
101 wxFLAGS_MEMBER(wxBORDER
)
103 // standard window styles
104 wxFLAGS_MEMBER(wxTAB_TRAVERSAL
)
105 wxFLAGS_MEMBER(wxCLIP_CHILDREN
)
106 wxFLAGS_MEMBER(wxTRANSPARENT_WINDOW
)
107 wxFLAGS_MEMBER(wxWANTS_CHARS
)
108 wxFLAGS_MEMBER(wxFULL_REPAINT_ON_RESIZE
)
109 wxFLAGS_MEMBER(wxALWAYS_SHOW_SB
)
110 wxFLAGS_MEMBER(wxVSCROLL
)
111 wxFLAGS_MEMBER(wxHSCROLL
)
114 wxFLAGS_MEMBER(wxSTAY_ON_TOP
)
115 wxFLAGS_MEMBER(wxCAPTION
)
116 wxFLAGS_MEMBER(wxTHICK_FRAME
)
117 wxFLAGS_MEMBER(wxSYSTEM_MENU
)
118 wxFLAGS_MEMBER(wxRESIZE_BORDER
)
119 wxFLAGS_MEMBER(wxRESIZE_BOX
)
120 wxFLAGS_MEMBER(wxCLOSE_BOX
)
121 wxFLAGS_MEMBER(wxMAXIMIZE_BOX
)
122 wxFLAGS_MEMBER(wxMINIMIZE_BOX
)
124 wxFLAGS_MEMBER(wxFRAME_TOOL_WINDOW
)
125 wxFLAGS_MEMBER(wxFRAME_FLOAT_ON_PARENT
)
127 wxFLAGS_MEMBER(wxFRAME_SHAPED
)
129 wxEND_FLAGS( wxFrameStyle
)
131 IMPLEMENT_DYNAMIC_CLASS_XTI(wxFrame
, wxTopLevelWindow
,"wx/frame.h")
133 wxBEGIN_PROPERTIES_TABLE(wxFrame
)
134 wxEVENT_PROPERTY( Menu
, wxEVT_COMMAND_MENU_SELECTED
, wxCommandEvent
)
136 wxPROPERTY( Title
,wxString
, SetTitle
, GetTitle
, wxString() , 0 /*flags*/ , wxT("Helpstring") , wxT("group"))
137 wxPROPERTY_FLAGS( WindowStyle
, wxFrameStyle
, long , SetWindowStyleFlag
, GetWindowStyleFlag
, EMPTY_MACROVALUE
, 0 /*flags*/ , wxT("Helpstring") , wxT("group")) // style
138 wxPROPERTY( MenuBar
, wxMenuBar
* , SetMenuBar
, GetMenuBar
, EMPTY_MACROVALUE
, 0 /*flags*/ , wxT("Helpstring") , wxT("group"))
139 wxEND_PROPERTIES_TABLE()
141 wxBEGIN_HANDLERS_TABLE(wxFrame
)
142 wxEND_HANDLERS_TABLE()
144 wxCONSTRUCTOR_6( wxFrame
, wxWindow
* , Parent
, wxWindowID
, Id
, wxString
, Title
, wxPoint
, Position
, wxSize
, Size
, long , WindowStyle
)
147 IMPLEMENT_DYNAMIC_CLASS(wxFrame
, wxTopLevelWindow
)
150 // ============================================================================
152 // ============================================================================
154 // ----------------------------------------------------------------------------
155 // static class members
156 // ----------------------------------------------------------------------------
159 #if wxUSE_NATIVE_STATUSBAR
160 bool wxFrame::m_useNativeStatusBar
= TRUE
;
162 bool wxFrame::m_useNativeStatusBar
= FALSE
;
164 #endif // wxUSE_NATIVE_STATUSBAR
166 // ----------------------------------------------------------------------------
167 // creation/destruction
168 // ----------------------------------------------------------------------------
176 // Data to save/restore when calling ShowFullScreen
177 m_fsStatusBarFields
= 0;
178 m_fsStatusBarHeight
= 0;
179 m_fsToolBarHeight
= 0;
181 m_wasMinimized
= FALSE
;
184 bool wxFrame::Create(wxWindow
*parent
,
186 const wxString
& title
,
190 const wxString
& name
)
192 if ( !wxTopLevelWindow::Create(parent
, id
, title
, pos
, size
, style
, name
) )
195 SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_APPWORKSPACE
));
197 wxModelessWindows
.Append(this);
204 m_isBeingDeleted
= TRUE
;
208 // ----------------------------------------------------------------------------
209 // wxFrame client size calculations
210 // ----------------------------------------------------------------------------
212 void wxFrame::DoSetClientSize(int width
, int height
)
214 // leave enough space for the status bar if we have (and show) it
216 wxStatusBar
*statbar
= GetStatusBar();
217 if ( statbar
&& statbar
->IsShown() )
219 height
+= statbar
->GetSize().y
;
221 #endif // wxUSE_STATUSBAR
223 // call GetClientAreaOrigin() to take the toolbar into account
224 wxPoint pt
= GetClientAreaOrigin();
228 wxTopLevelWindow::DoSetClientSize(width
, height
);
231 // Get size *available for subwindows* i.e. excluding menu bar, toolbar etc.
232 void wxFrame::DoGetClientSize(int *x
, int *y
) const
234 wxTopLevelWindow::DoGetClientSize(x
, y
);
236 // account for the possible toolbar
237 wxPoint pt
= GetClientAreaOrigin();
245 // adjust client area height to take the status bar into account
248 wxStatusBar
*statbar
= GetStatusBar();
249 if ( statbar
&& statbar
->IsShown() )
251 *y
-= statbar
->GetClientSize().y
;
254 #endif // wxUSE_STATUSBAR
257 // ----------------------------------------------------------------------------
258 // wxFrame: various geometry-related functions
259 // ----------------------------------------------------------------------------
261 void wxFrame::Raise()
263 ::SetForegroundWindow(GetHwnd());
266 // generate an artificial resize event
267 void wxFrame::SendSizeEvent()
271 RECT r
= wxGetWindowRect(GetHwnd());
273 (void)::PostMessage(GetHwnd(), WM_SIZE
,
274 IsMaximized() ? SIZE_MAXIMIZED
: SIZE_RESTORED
,
275 MAKELPARAM(r
.right
- r
.left
, r
.bottom
- r
.top
));
280 wxStatusBar
*wxFrame::OnCreateStatusBar(int number
,
283 const wxString
& name
)
285 wxStatusBar
*statusBar
= NULL
;
287 #if wxUSE_NATIVE_STATUSBAR
288 if ( !UsesNativeStatusBar() )
290 statusBar
= (wxStatusBar
*)new wxStatusBarGeneric(this, id
, style
);
295 statusBar
= new wxStatusBar(this, id
, style
, name
);
298 statusBar
->SetFieldsCount(number
);
303 void wxFrame::PositionStatusBar()
305 if ( !m_frameStatusBar
|| !m_frameStatusBar
->IsShown() )
309 GetClientSize(&w
, &h
);
311 m_frameStatusBar
->GetSize(&sw
, &sh
);
313 // Since we wish the status bar to be directly under the client area,
314 // we use the adjusted sizes without using wxSIZE_NO_ADJUSTMENTS.
315 m_frameStatusBar
->SetSize(0, h
, w
, sh
);
317 #endif // wxUSE_STATUSBAR
319 #if wxUSE_MENUS_NATIVE
321 void wxFrame::AttachMenuBar(wxMenuBar
*menubar
)
323 #if defined(__WXWINCE__) && (_WIN32_WCE < 400 || defined(WIN32_PLATFORM_PSPC) || defined(WIN32_PLATFORM_WFSP))
326 wxToolBar
* toolBar
= new wxToolBar(this, -1,
327 wxDefaultPosition
, wxDefaultSize
,
328 wxBORDER_NONE
| wxTB_HORIZONTAL
,
329 wxToolBarNameStr
, menubar
);
331 menubar
->SetToolBar(toolBar
);
333 // Now adjust size for menu bar
336 //When the main window is created using CW_USEDEFAULT the height of the
337 // is created is not taken into account). So we resize the window after
338 // if a menubar is present
341 ::GetWindowRect((HWND
) GetHWND(), &rc
);
342 // adjust for menu / titlebar height
343 rc
.bottom
-= (2*menuHeight
-1);
345 MoveWindow((HWND
) GetHWND(), rc
.left
, rc
.top
, rc
.right
, rc
.bottom
, FALSE
);
349 wxFrameBase::AttachMenuBar(menubar
);
353 // actually remove the menu from the frame
354 m_hMenu
= (WXHMENU
)0;
355 InternalSetMenuBar();
357 else // set new non NULL menu bar
359 #if !defined(__WXWINCE__) || (_WIN32_WCE >= 400 && !defined(WIN32_PLATFORM_PSPC) && !defined(WIN32_PLATFORM_WFSP))
360 // Can set a menubar several times.
361 if ( menubar
->GetHMenu() )
363 m_hMenu
= menubar
->GetHMenu();
367 m_hMenu
= menubar
->Create();
371 wxFAIL_MSG( _T("failed to create menu bar") );
376 InternalSetMenuBar();
380 void wxFrame::InternalSetMenuBar()
382 #if defined(__WXMICROWIN__) || defined(__WXWINCE__)
385 if ( !::SetMenu(GetHwnd(), (HMENU
)m_hMenu
) )
387 wxLogLastError(wxT("SetMenu"));
392 #endif // wxUSE_MENUS_NATIVE
394 // Responds to colour changes, and passes event on to children.
395 void wxFrame::OnSysColourChanged(wxSysColourChangedEvent
& event
)
397 SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_APPWORKSPACE
));
401 if ( m_frameStatusBar
)
403 wxSysColourChangedEvent event2
;
404 event2
.SetEventObject( m_frameStatusBar
);
405 m_frameStatusBar
->GetEventHandler()->ProcessEvent(event2
);
407 #endif // wxUSE_STATUSBAR
409 // Propagate the event to the non-top-level children
410 wxWindow::OnSysColourChanged(event
);
413 // Pass TRUE to show full screen, FALSE to restore.
414 bool wxFrame::ShowFullScreen(bool show
, long style
)
416 if ( IsFullScreen() == show
)
422 #if defined(__WXWINCE__) && (_WIN32_WCE < 400 || defined(WIN32_PLATFORM_PSPC) || defined(WIN32_PLATFORM_WFSP))
423 // TODO: hide commandbar
425 wxToolBar
*theToolBar
= GetToolBar();
427 theToolBar
->GetSize(NULL
, &m_fsToolBarHeight
);
429 // zap the toolbar, menubar, and statusbar
431 if ((style
& wxFULLSCREEN_NOTOOLBAR
) && theToolBar
)
433 theToolBar
->SetSize(-1,0);
434 theToolBar
->Show(FALSE
);
436 #endif // __WXWINCE__
437 #endif // wxUSE_TOOLBAR
439 #if defined(__WXMICROWIN__)
440 #elif defined(__WXWINCE__)
441 // TODO: make it work for WinCE
443 if (style
& wxFULLSCREEN_NOMENUBAR
)
444 SetMenu((HWND
)GetHWND(), (HMENU
) NULL
);
448 wxStatusBar
*theStatusBar
= GetStatusBar();
450 theStatusBar
->GetSize(NULL
, &m_fsStatusBarHeight
);
452 // Save the number of fields in the statusbar
453 if ((style
& wxFULLSCREEN_NOSTATUSBAR
) && theStatusBar
)
455 //m_fsStatusBarFields = theStatusBar->GetFieldsCount();
456 //SetStatusBar((wxStatusBar*) NULL);
457 //delete theStatusBar;
458 theStatusBar
->Show(FALSE
);
461 m_fsStatusBarFields
= 0;
462 #endif // wxUSE_STATUSBAR
467 #if defined(__WXWINCE__) && (_WIN32_WCE < 400 || defined(WIN32_PLATFORM_PSPC) || defined(WIN32_PLATFORM_WFSP))
468 // TODO: show commandbar
470 wxToolBar
*theToolBar
= GetToolBar();
472 // restore the toolbar, menubar, and statusbar
473 if (theToolBar
&& (m_fsStyle
& wxFULLSCREEN_NOTOOLBAR
))
475 theToolBar
->SetSize(-1, m_fsToolBarHeight
);
476 theToolBar
->Show(TRUE
);
478 #endif // __WXWINCE__
479 #endif // wxUSE_TOOLBAR
482 if ( m_fsStyle
& wxFULLSCREEN_NOSTATUSBAR
)
484 //CreateStatusBar(m_fsStatusBarFields);
487 GetStatusBar()->Show(TRUE
);
491 #endif // wxUSE_STATUSBAR
493 #if defined(__WXMICROWIN__)
494 #elif defined(__WXWINCE__)
495 // TODO: make it work for WinCE
497 if ((m_fsStyle
& wxFULLSCREEN_NOMENUBAR
) && (m_hMenu
!= 0))
498 SetMenu((HWND
)GetHWND(), (HMENU
)m_hMenu
);
502 return wxFrameBase::ShowFullScreen(show
, style
);
505 // ----------------------------------------------------------------------------
506 // tool/status bar stuff
507 // ----------------------------------------------------------------------------
511 wxToolBar
* wxFrame::CreateToolBar(long style
, wxWindowID id
, const wxString
& name
)
513 #if defined(__WXWINCE__) && (_WIN32_WCE < 400 || defined(WIN32_PLATFORM_PSPC) || defined(WIN32_PLATFORM_WFSP))
514 // We may already have a toolbar from calling SetMenuBar.
518 if ( wxFrameBase::CreateToolBar(style
, id
, name
) )
523 return m_frameToolBar
;
526 void wxFrame::PositionToolBar()
528 wxToolBar
*toolbar
= GetToolBar();
529 if ( toolbar
&& toolbar
->IsShown() )
531 #if defined(__WXWINCE__) && (_WIN32_WCE < 400 || defined(WIN32_PLATFORM_PSPC) || defined(WIN32_PLATFORM_WFSP))
532 // We want to do something different in WinCE, because
533 // the toolbar should be associated with the commandbar,
534 // and not an independent window.
537 // don't call our (or even wxTopLevelWindow) version because we want
538 // the real (full) client area size, not excluding the tool/status bar
540 wxWindow::DoGetClientSize(&width
, &height
);
543 wxStatusBar
*statbar
= GetStatusBar();
544 if ( statbar
&& statbar
->IsShown() )
546 height
-= statbar
->GetClientSize().y
;
548 #endif // wxUSE_STATUSBAR
552 toolbar
->GetPosition(&tx
, &ty
);
553 toolbar
->GetSize(&tw
, &th
);
556 if (ty
< 0 && (-ty
== th
))
558 if (tx
< 0 && (-tx
== tw
))
564 if ( toolbar
->GetWindowStyleFlag() & wxTB_VERTICAL
)
571 // if ( toolbar->GetWindowStyleFlag() & wxTB_FLAT )
575 // use the 'real' MSW position here, don't offset relativly to the
576 // client area origin
578 // Optimise such that we don't have to always resize the toolbar
579 // when the frame changes, otherwise we'll get a lot of flicker.
580 bool heightChanging
= TRUE
;
581 bool widthChanging
= TRUE
;
583 if ( toolbar
->GetWindowStyleFlag() & wxTB_VERTICAL
)
585 // It's OK if the current height is greater than what can be shown.
586 heightChanging
= (desiredH
> th
) ;
587 widthChanging
= (desiredW
!= tw
) ;
589 // The next time around, we may not have to set the size
591 desiredH
= desiredH
+ 200;
595 // It's OK if the current width is greater than what can be shown.
596 widthChanging
= (desiredW
> tw
) ;
597 heightChanging
= (desiredH
!= th
) ;
599 // The next time around, we may not have to set the size
601 desiredW
= desiredW
+ 200;
604 if (tx
!= 0 || ty
!= 0 || widthChanging
|| heightChanging
)
605 toolbar
->SetSize(0, 0, desiredW
, desiredH
, wxSIZE_NO_ADJUSTMENTS
);
607 #endif // __WXWINCE__
611 #endif // wxUSE_TOOLBAR
613 // ----------------------------------------------------------------------------
614 // frame state (iconized/maximized/...)
615 // ----------------------------------------------------------------------------
617 // propagate our state change to all child frames: this allows us to emulate X
618 // Windows behaviour where child frames float independently of the parent one
619 // on the desktop, but are iconized/restored with it
620 void wxFrame::IconizeChildFrames(bool bIconize
)
622 for ( wxWindowList::compatibility_iterator node
= GetChildren().GetFirst();
624 node
= node
->GetNext() )
626 wxWindow
*win
= node
->GetData();
628 // iconizing the frames with this style under Win95 shell puts them at
629 // the bottom of the screen (as the MDI children) instead of making
630 // them appear in the taskbar because they are, by virtue of this
631 // style, not managed by the taskbar - instead leave Windows take care
634 if ( win
->GetWindowStyle() & wxFRAME_TOOL_WINDOW
)
638 // the child MDI frames are a special case and should not be touched by
639 // the parent frame - instead, they are managed by the user
640 wxFrame
*frame
= wxDynamicCast(win
, wxFrame
);
642 #if wxUSE_MDI_ARCHITECTURE
643 && !wxDynamicCast(frame
, wxMDIChildFrame
)
644 #endif // wxUSE_MDI_ARCHITECTURE
647 // we don't want to restore the child frames which had been
648 // iconized even before we were iconized, so save the child frame
649 // status when iconizing the parent frame and check it when
653 frame
->m_wasMinimized
= frame
->IsIconized();
656 // note that we shouldn't touch the hidden frames neither because
657 // iconizing/restoring them would show them as a side effect
658 if ( !frame
->m_wasMinimized
&& frame
->IsShown() )
659 frame
->Iconize(bIconize
);
664 WXHICON
wxFrame::GetDefaultIcon() const
666 // we don't have any standard icons (any more)
670 // ===========================================================================
671 // message processing
672 // ===========================================================================
674 // ---------------------------------------------------------------------------
676 // ---------------------------------------------------------------------------
678 bool wxFrame::MSWTranslateMessage(WXMSG
* pMsg
)
680 if ( wxWindow::MSWTranslateMessage(pMsg
) )
683 #if wxUSE_MENUS && wxUSE_ACCEL && !defined(__WXUNIVERSAL__)
684 // try the menu bar accels
685 wxMenuBar
*menuBar
= GetMenuBar();
689 const wxAcceleratorTable
& acceleratorTable
= menuBar
->GetAccelTable();
690 return acceleratorTable
.Translate(this, pMsg
);
693 #endif // wxUSE_MENUS && wxUSE_ACCEL
696 // ---------------------------------------------------------------------------
697 // our private (non virtual) message handlers
698 // ---------------------------------------------------------------------------
700 bool wxFrame::HandlePaint()
703 if ( GetUpdateRect(GetHwnd(), &rect
, FALSE
) )
705 #if !defined(__WXMICROWIN__) && !defined(__WXWINCE__)
708 const wxIcon
& icon
= GetIcon();
709 HICON hIcon
= icon
.Ok() ? GetHiconOf(icon
)
710 : (HICON
)GetDefaultIcon();
712 // Hold a pointer to the dc so long as the OnPaint() message
713 // is being processed
715 HDC hdc
= ::BeginPaint(GetHwnd(), &ps
);
717 // Erase background before painting or we get white background
718 MSWDefWindowProc(WM_ICONERASEBKGND
, (WORD
)(LONG
)ps
.hdc
, 0L);
723 ::GetClientRect(GetHwnd(), &rect
);
725 // FIXME: why hardcoded?
726 static const int icon_width
= 32;
727 static const int icon_height
= 32;
729 int icon_x
= (int)((rect
.right
- icon_width
)/2);
730 int icon_y
= (int)((rect
.bottom
- icon_height
)/2);
732 ::DrawIcon(hdc
, icon_x
, icon_y
, hIcon
);
735 ::EndPaint(GetHwnd(), &ps
);
742 return wxWindow::HandlePaint();
747 // nothing to paint - processed
752 bool wxFrame::HandleSize(int x
, int y
, WXUINT id
)
754 bool processed
= FALSE
;
755 #if !defined(__WXMICROWIN__) && !defined(__WXWINCE__)
760 // only do it it if we were iconized before, otherwise resizing the
761 // parent frame has a curious side effect of bringing it under it's
766 // restore all child frames too
767 IconizeChildFrames(FALSE
);
769 (void)SendIconizeEvent(FALSE
);
778 // iconize all child frames too
779 IconizeChildFrames(TRUE
);
781 (void)SendIconizeEvent();
792 #endif // wxUSE_STATUSBAR
796 #endif // wxUSE_TOOLBAR
798 processed
= wxWindow::HandleSize(x
, y
, id
);
804 bool wxFrame::HandleCommand(WXWORD id
, WXWORD cmd
, WXHWND control
)
808 // In case it's e.g. a toolbar.
809 wxWindow
*win
= wxFindWinFromHandle(control
);
811 return win
->MSWCommand(cmd
, id
);
814 // handle here commands from menus and accelerators
815 if ( cmd
== 0 || cmd
== 1 )
817 #if wxUSE_MENUS_NATIVE
818 if ( wxCurrentPopupMenu
)
820 wxMenu
*popupMenu
= wxCurrentPopupMenu
;
821 wxCurrentPopupMenu
= NULL
;
823 return popupMenu
->MSWCommand(cmd
, id
);
825 #endif // wxUSE_MENUS_NATIVE
827 if ( ProcessCommand(id
) )
836 bool wxFrame::HandleMenuSelect(WXWORD nItem
, WXWORD flags
, WXHMENU hMenu
)
839 if ( flags
== 0xFFFF && hMenu
== 0 )
841 // menu was removed from screen
844 #ifndef __WXMICROWIN__
845 else if ( !(flags
& MF_POPUP
) && !(flags
& MF_SEPARATOR
) )
852 // don't give hints for separators (doesn't make sense) nor for the
853 // items opening popup menus (they don't have them anyhow) but do clear
854 // the status line - otherwise, we would be left with the help message
855 // for the previous item which doesn't apply any more
856 DoGiveHelp(wxEmptyString
, FALSE
);
861 wxMenuEvent
event(wxEVT_MENU_HIGHLIGHT
, item
);
862 event
.SetEventObject(this);
864 return GetEventHandler()->ProcessEvent(event
);
867 bool wxFrame::HandleMenuLoop(const wxEventType
& evtType
, WXWORD isPopup
)
869 // we don't have the menu id here, so we use the id to specify if the event
870 // was from a popup menu or a normal one
871 wxMenuEvent
event(evtType
, isPopup
? -1 : 0);
872 event
.SetEventObject(this);
874 return GetEventHandler()->ProcessEvent(event
);
877 // ---------------------------------------------------------------------------
878 // the window proc for wxFrame
879 // ---------------------------------------------------------------------------
881 WXLRESULT
wxFrame::MSWWindowProc(WXUINT message
, WXWPARAM wParam
, WXLPARAM lParam
)
884 bool processed
= FALSE
;
889 // if we can't close, tell the system that we processed the
890 // message - otherwise it would close us
891 processed
= !Close();
895 processed
= HandleSize(LOWORD(lParam
), HIWORD(lParam
), wParam
);
902 UnpackCommand((WXWPARAM
)wParam
, (WXLPARAM
)lParam
,
905 processed
= HandleCommand(id
, cmd
, (WXHWND
)hwnd
);
910 processed
= HandlePaint();
913 case WM_INITMENUPOPUP
:
914 processed
= HandleInitMenuPopup((WXHMENU
) wParam
);
917 #if !defined(__WXMICROWIN__) && !defined(__WXWINCE__)
922 UnpackMenuSelect(wParam
, lParam
, &item
, &flags
, &hmenu
);
924 processed
= HandleMenuSelect(item
, flags
, hmenu
);
928 case WM_EXITMENULOOP
:
929 processed
= HandleMenuLoop(wxEVT_MENU_CLOSE
, wParam
);
932 case WM_QUERYDRAGICON
:
934 const wxIcon
& icon
= GetIcon();
935 HICON hIcon
= icon
.Ok() ? GetHiconOf(icon
)
936 : (HICON
)GetDefaultIcon();
941 #endif // !__WXMICROWIN__
945 rc
= wxFrameBase::MSWWindowProc(message
, wParam
, lParam
);
950 // handle WM_INITMENUPOPUP message
951 bool wxFrame::HandleInitMenuPopup(WXHMENU hMenu
)
956 int nCount
= GetMenuBar()->GetMenuCount();
957 for (int n
= 0; n
< nCount
; n
++)
959 if (GetMenuBar()->GetMenu(n
)->GetHMenu() == hMenu
)
961 menu
= GetMenuBar()->GetMenu(n
);
967 wxMenuEvent
event(wxEVT_MENU_OPEN
, 0, menu
);
968 event
.SetEventObject(this);
970 return GetEventHandler()->ProcessEvent(event
);