开发者

RTTI ?? create multiple object at runtime wxwidgets?

hi sorry for my stupid question

what are the right way to create multiple control 开发者_C百科object from a list of array of label of object ...?

thank


The function wxCreateDynamicObject can be used to construct a new object of a given type, by supplying a string name. If you have a pointer to the wxClassInfo object instead, then you can simply call wxClassInfo::CreateObject.

You must include the IMPLEMENT_DYNAMIC_CLASS macro in every class you want to be able to dynamically create objects. IMPLEMENT_DYNAMIC_CLASS is a macro that not only initialises the static wxClassInfo member, but defines a global function capable of creating a dynamic object of the class in question.

Example

In a header file:

class wxFrame : public wxWindow
{
DECLARE_DYNAMIC_CLASS(wxFrame)

private:
    wxString m_title;

public:
    ...
};

In a C++ file:

IMPLEMENT_DYNAMIC_CLASS(wxFrame, wxWindow)

wxFrame::wxFrame()
{
...
}
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜