wxAUI, wxPanel and XRC

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
romeo9423
Experienced Solver
Experienced Solver
Posts: 72
Joined: Mon Nov 08, 2004 3:36 pm

wxAUI, wxPanel and XRC

Post by romeo9423 » Sat Jan 14, 2006 7:44 pm

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 ?

DavidHart
Site Admin
Site Admin
Posts: 4008
Joined: Thu Jan 12, 2006 6:23 pm
Location: IoW, UK

Post by DavidHart » Sat Jan 14, 2006 9:28 pm

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

Post Reply