0

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?

1
  • There is nothing wrong in the code you show, so there must be something wrong in the code you do not show, namely ActorDetails ctor. Commented Dec 23, 2015 at 17:28

2 Answers 2

1

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

Sign up to request clarification or add additional context in comments.

Comments

0

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).

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.