开发者

Accessing GetValue() from wxWindow class

开发者 https://www.devze.com 2023-02-03 23:56 出处:网络
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?

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消