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 wxRa开发者_如何学PythondioButton etc? Thanks.
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.
You can't call a derivative's function from a base pointer unless it's through a virtual function call, so no.
You can downcast though and get access to that function.
精彩评论