Reputation: 3
I want to create a second independent window using C++/wxWidgets and I get an error "cannot create window of class wxWindowNR" at runtime and the second window doesn't show up. No compiler/linker errors.
The offending code is:
void test_gui(){
ActorDetails *ac = new ActorDetails(wxGetApp().GetTopWindow(),wxID_ANY,wxDefaultPosition,wxDefaultSize); //ActorDetails inherits wxFrame
wxPanel *Panel1 = new wxPanel(ac, wxNewId(), wxPoint(256,224), wxDefaultSize, wxTAB_TRAVERSAL, _T("ID_PANEL1"));
ac->Show(true);
}
Any idea what's going on/going wrong?
Upvotes: 0
Views: 788
Reputation: 11
I'd the same error message today. Most probably you forgot to call the wxFrame constructor from your ActorDetails constructor.
Upvotes: 1
Reputation: 3
replacing
ActorDetails *ac = new ActorDetails(wxGetApp().GetTopWindow(),wxID_ANY,wxDefaultPosition,wxDefaultSize);
with
ActorDetails *ac = new ActorDetails();
ac->Create(wxGetApp().GetTopWindow(), wxNewId(), _("Existenz Console"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_FRAME_STYLE, _T("id"));
now produces a window as expected. Unfortunately I do not know what the difference is, but the second variant of code successfully instantiates and shows the second wxFrame.
This of course required the addition of a new empty constructor no parameter constructor to the class ActorDetails (not shown here).
Upvotes: 0