我正在使用wxXmlResource()
. 这很好地加载了窗口,但我不确定如何获取对命名窗口元素的对象引用。
这是我的代码:
// Load the window
$resource = new wxXmlResource();
$resource->InitAllHandlers();
$resource->Load(__DIR__ . '/forms.xrc.xml');
// Get a reference to a window
$frame = new wxFrame();
$resource->LoadFrame($frame, NULL, 'frmOne');
$frame->Show();
// Fetch a named element - the class returned is the base class
$textCtrl = $frame->FindWindow('m_staticText12');
echo get_class($textCtrl) . "\n";
该$textCtrl
项目应该是一个wxStaticText
对象,但它已作为一个wxWindow
(它是一个父类)返回。由于它没有被转换为正确的对象类型,所以我不能调用属于控件自己的类的方法(例如Wrap()
)。
我认为这个FindWindow()
电话是有效的,因为如果我故意弄错名字,它会返回null
.
我究竟做错了什么?