Hi! Everything changes with sizers :)
#include <wx/wx.h>
#include <wx/image.h>
#ifndef MYFRAME_H
#define MYFRAME_H
class MyFrame: public wxFrame {
wxStaticText* label;
wxPanel* panel;
public:
MyFrame(wxWindow* parent, int id, const wxString& title, const wxPoint& pos=wxDefaultPosition, const wxSize& size=wxDefaultSize, long style=wxDEFAULT_FRAME_STYLE);
};
#endif
#include "MyFrame.h"
MyFrame::MyFrame(wxWindow* parent, int id, const wxString& title, const wxPoint& pos, const wxSize& size, long style):
wxFrame(parent, id, title, pos, size, wxDEFAULT_FRAME_STYLE)
{
panel = new wxPanel(this, -1);
label = new wxStaticText(panel, -1, wxT("I am the label"), wxDefaultPosition, wxDefaultSize, wxALIGN_CENTRE);
SetTitle(wxT("Frame"));
wxBoxSizer* topSizer = new wxBoxSizer(wxVERTICAL);
wxBoxSizer* sizer = new wxBoxSizer(wxHORIZONTAL);
sizer->Add(label, 1, wxALIGN_CENTER_VERTICAL, 0);
panel->SetAutoLayout(true);
panel->SetSizer(sizer);
sizer->Fit(panel);
sizer->SetSizeHints(panel);
topSizer->Add(panel, 1, wxEXPAND, 0);
SetAutoLayout(true);
SetSizer(topSizer);
topSizer->Fit(this);
topSizer->SetSizeHints(this);
Layout();
} upCASE ----------------------------------- If it was hard to write, it should be hard to read!- Do. Or do not. There is no try! |