I am trying to create a custom control, so, I derived a class from wxPanel
However, whenever I am trying to display it, (the 'new' and the
construction is OK), in the MyApp calls frame->Show() I get the
following error:
"Can't create window of class wxWindowClassNR (error 1406: cannot create
a top-level child window.)"
This is the basic declaration of my class
============ My class ==============================
class USTabCtrlBar :
public wxPanel
{
DECLARE_DYNAMIC_CLASS( USTabCtrlBar )
DECLARE_EVENT_TABLE()
USTabCtrlBar(void);
~USTabCtrlBar(void);
USTabCtrlBar(wxWindow* parent, wxWindowID id = wxID_ANY, const
wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
long style = wxTAB_TRAVERSAL|wxSIMPLE_BORDER, const wxString& name =
"USTabCtrlBar");
virtual void Create(wxWindow* parent, wxWindowID id = wxID_ANY,
const wxPoint& pos = wxDefaultPosition, const wxSize& size =
wxDefaultSize, long style = wxTAB_TRAVERSAL|wxSIMPLE_BORDER, const
wxString& name = "USTabCtrlBar");
private:
wxPanel *m_buttonsPanel;
wxPanel *m_pagesPanel;
wxPanel *m_captionPanel;
wxBoxSizer *m_sizer;
bool m_controlCreated;
};
==================================================
Btw, I am using wx 2.6 on windows.
Can anyone suggest a solution to this?
Eran
HTH,
Kevin
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: wx-users-u...@lists.wxwidgets.org
> For additional commands, e-mail: wx-use...@lists.wxwidgets.org
>
>
In my class I have 2 panels, which are created in the Create() function
(no errors in this function):
void USTabCtrlBar::Create(wxWindow* parent, wxWindowID id, const
wxPoint& pos, const wxSize& size, long style, const wxString& name)
{
wxSize sz = size;
if(sz.GetHeight() < 200 && sz.GetWidth() < 200)
sz = wxSize(200, 200);
wxPanel::wxPanel(parent, id, pos, size, style, name);
m_buttonsPanel = new wxPanel(this, IDC_BUTTONS_PANEL, wxPoint(0, 0),
wxSize(sz.GetWidth(), 20));
m_buttonsPanel->SetBackgroundColour(BackgroudButtonsColor);
m_pagesPanel = new wxPanel(this, wxID_ANY, wxPoint(0, 20),
wxSize(sz.GetWidth(), sz.GetHeight()-20));
m_sizer = new wxBoxSizer(wxVERTICAL);
m_sizer->Add(m_buttonsPanel);
m_sizer->Add(m_pagesPanel);
SetSizerAndFit(m_sizer);
m_controlCreated = true;
}
And In the main frame I am doing to following:
void USMainFrame::InitSolutionBar(void)
{
:
m_wndSolutionBar = new wxDockWindow(...);
USTabCtrlBar *b = new USTabCtrlBar(m_wndSolutionBar, wxID_ANY,
wxDefaultPosition, wxSize(300, 300));
// Set the panel bar to the docking window
m_wndSolutionBar->SetClient( b );
:
}
Note that if i will try to set the panel directly on the wxDockWindow -
it works (i.e. I create 3 panels, the first panel is the parent of the
other 2, and the third one is set in the client area of the wxDockWindow)
Thx,
Eran
EI> I am trying to create a custom control, so, I derived a class from wxPanel
EI> However, whenever I am trying to display it, (the 'new' and the
EI> construction is OK), in the MyApp calls frame->Show() I get the
EI> following error:
EI>
EI> "Can't create window of class wxWindowClassNR (error 1406: cannot create
EI> a top-level child window.)"
This means that your parent window has never been created at Windows
level. Most likely reason is that you used default ctor for it and forgot
to call Create().
Regards,
VZ
--
TT-Solutions: wxWidgets consultancy and technical support
http://www.tt-solutions.com/
EI> Actually I am not using the default ctor, but the long one( wxWindow*, id,
EI> pos, size etc.),
EI> My ctor is something like this:
EI> myfram( ... ))
EI> {
EI> Create(parent, id, pos, size, style);
EI> }
EI>
EI> And in my Create function I am doing:
EI> MyFrame::Create( .. )
EI> {
EI> wxMDIParentFrame::Create(parent, id, pos, size, style);
EI> // Here I am trying to create my control
EI> }
EI>
EI> Do you think moving the creation of my control outside the Create() function
EI> will fix this?
The only thing it matters is that it should be created after the parent
window Create() had been called.
---------------------------------------------------------------------
To unsubscribe, e-mail: wx-users-u...@lists.wxwidgets.org
For additional commands, e-mail: wx-use...@lists.wxwidgets.org