Search code examples
c++wxwidgets

Accessing GetValue() from wxWindow class


Is there any way to access the GetValue() member of a GUI control under wxWidgets, if it is declared as a wxWindow rather than a wxCheckBox or wxRadioButton etc? Thanks.


Solution

  • An object declared as WxWindow is NOT a GUI control. A pointer declared as a WxWindow* might point to a wxStaticText object or a wxCheckBox object. You'd have to do a dynamic_cast< > to find out. Once you know it's a wxCheckBox, you can call wxCheckBox::GetValue. Similarly, if it's a wxRadioButton, you can call wxRadioButton::GetValue.

    Note that per C++ rules, wxCheckBox::GetValue and wxRadioButton::GetValue are entirely unrelated. They just happen to have the same method name.