Will Kydd
Will Kydd

Reputation: 3

Cannot create window of class wxWindowNR

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

Answers (2)

S.K.
S.K.

Reputation: 11

I'd the same error message today. Most probably you forgot to call the wxFrame constructor from your ActorDetails constructor.

Upvotes: 1

Will Kydd
Will Kydd

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

Related Questions