Access violation error on togglebutton->getValue during runtime in wxwidgets?
fxButtonYesNo = new wxToggleButton( this, wxID_ANY, wxT("OFF") );
fxButtonYesNo->Connect( wxEVT_COMMAND_TOGGLEBUTTON_CLICKED,
wxCommandEventHandler(fxButtonYesNoState) );
void fxButtonYesNoState( wxCommandEvent& event )
{ bool fxPressedValue = fxButtonYesNo->GetValue();
if(fxPressedValue)
{ fxTextPre->SetLabel("FX ON "); }
else { fxTextPre->SetLabel("FX OFF ");
} }>
Ok, the error was found! The Connect function to the togglebutton was not complete and hence an access violation error! The complete Connect function is:
fxButtonYesNo->Connect( wxEVT_COMMAND_TOGGLEBUTTON_CLICKED, wxCommandEventHandler(fxButtonYesNoState), nulltpr, this );