Page 1 of 1

wxAUI, wxPanel and XRC

Posted: Sat Jan 14, 2006 7:44 pm
by romeo9423
Hi,

I would like to create a wxPAnel from XRC so I am trying this :

Code: Select all

class ReaderPropPanel : public wxPanel
{
    public:
		// class constructor
		ReaderPropPanel(wxWindow* parent);

		// class destructor
		~ReaderPropPanel();
};

ReaderPropPanel::ReaderPropPanel(wxWindow* parent):
wxPanel(parent, -1, wxDefaultPosition, wxDefaultSize)
{
	wxXmlResource::Get()->LoadPanel(parent, _T("MyPanel1"));

	wxBitmap bmp;
}

// MainFrame
void MainFrame::CreateIDE()
{
    CreateMenubar();

    CreateToolbars();

    m_pReaderPanel = new ReaderPropPanel(this);
    m_pReaderPanel->Show(false);
    
m_FrmMgr.AddPane(m_pReaderPanel, wxPaneInfo().Name(wxT("reader_panel")).
    CenterPane().Hide());
    m_FrmMgr.Update();

   ...

But it doesn't work since my wxPanel is displayed.

If I do this it works but this is not what I want :

Code: Select all

// MainFrame
void MainFrame::CreateIDE()
{
    CreateMenubar();

    CreateToolbars();

m_pReaderPanel = (ReaderPropPanel*) wxXmlResource::Get()->LoadPanel(this, _T("MyPanel1"));
    
m_FrmMgr.AddPane(m_pReaderPanel, wxPaneInfo().Name(wxT("reader_panel")).
    CenterPane().Hide());
    m_FrmMgr.Update();

   ...


What's wrong with that, why when I do

Code: Select all

m_pReaderPanel = new ReaderPropPanel(this);
m_pReaderPanel->Show(false);
my panel is displayed ?

Posted: Sat Jan 14, 2006 9:28 pm
by DavidHart
Hi,

I'm not quite sure what you're trying to do, but on a quick look there are 2 errors in your code:
  • You are doing something in the ReaderPropPanel constructor. When loading from xrc, this doesn't get called.

    You seem to be trying to load the panel from within the class. Instead you need to call it from outside. So instead of your non-xrc m_pReaderPanel = new ReaderPropPanel(this);
    do something like: m_pReaderPanel = (ReaderPropPanel*)wxXmlResource::Get()->LoadPanel(this, _T("MyPanel1"));
Also, see my recent post in http://forums.wxwidgets.org/viewtopic.php?t=5986 about subclassing, in case this applies to you too.

HTH,

David