how do i enable a menu with a click of a button.
i open a new program and save menu is disabled by default. I want to enable it when i open a file.
i used wxformbuilder to generate the save code.
wxMenuItem* Save;
Save = new wxMenuItem( m_menu1, wxID_ANY, wxString( wxT("Save") ) , wxEmptyString, wxITEM_NORMAL );
m_menu1->Append( Save );
Save->Enable( false );
void wxfbIntegrationFrame::OpenOnMenuSelection(wxCommandEvent& event)
{
Save->Enable(true);
}
thanks
enable menu Topic is solved
- xaviou
- Super wx Problem Solver
- Posts: 437
- Joined: Mon Aug 21, 2006 3:18 pm
- Location: Annecy - France
- Contact:
Re: enable menu
Hi
You can use a wxWidgets defined Id for your "save" menu (wxID_SAVE) or a user defined one.
Then, you can retreive the menu by calling FindItem on the wxMenuBar of you frame, for example like this :
P.S: Do not forget the "CODE" tag when you have to post a piece of code on this forum : it is much more readable.
Regards.
Xav'
You can use a wxWidgets defined Id for your "save" menu (wxID_SAVE) or a user defined one.
Then, you can retreive the menu by calling FindItem on the wxMenuBar of you frame, for example like this :
Code: Select all
void wxfbIntegrationFrame::OpenOnMenuSelection(wxCommandEvent& event)
{
wxMenuItem* item = GetMenuBar()->FindItem(wxID_SAVE);
if (item!=NULL) item->Enable(true);
}
Regards.
Xav'
My wxWidgets stuff web page : X@v's wxStuff
Re: enable menu
Thanks for the help. that fixed it.
Re: enable menu
also see
http://wyoguide.sourceforge.net/guidelines/menus.html
is there any advantage to use wxID_SAVE over some random custom ID?
http://wyoguide.sourceforge.net/guidelines/menus.html
is there any advantage to use wxID_SAVE over some random custom ID?