Jeg er nu kommet lidt videre, med hjælp fra dit eksempel. Status er, at mit program har tre TextCtrl som er navngivet a, b og c. Desuden er der en button, som jeg senere skal have lavet en onClick (eller hvad vi nu kaldet det) funktion til.
<pre>
#include "wx/wx.h"
#include <sstream>
#include <string>
// The panel, a panel is what make it behave as a dialog box
class PanelClass: public wxPanel
{
public:
PanelClass(wxFrame *frame, int x, int y, int w, int h) : wxPanel(frame, wxID_ANY, wxPoint(x, y), wxSize(w, h))
{
a = new wxTextCtrl(this, Text1Id, "", wxPoint(5, 5), wxSize(50, 20));
b = new wxTextCtrl(this, Text2Id, "", wxPoint(5, 30), wxSize(50, 20));
c = new wxTextCtrl(this, Text3Id, "", wxPoint(5, 55), wxSize(50, 20));
Button1 = new wxButton(this, ButtonId, "Beregn", wxPoint(5, 80), wxSize(100, 20));
}
~PanelClass()
{
delete a;
delete b;
delete c;
delete Button1;
}
private:
// Some id's for my controls
enum CtrlId
{
Text1Id = 1001,
Text2Id,
Text3Id,
ButtonId
};
// Resize my Controls when I'm resized
wxTextCtrl *a;
wxTextCtrl *b;
wxTextCtrl *c;
wxButton *Button1;
void OnAddButton(wxCommandEvent &event);
DECLARE_EVENT_TABLE()
};
// The event table for the panel, this routes messages/events to functions
BEGIN_EVENT_TABLE(PanelClass, wxPanel)
EVT_BUTTON(ButtonId, PanelClass:
nAddButton)
EVT_SIZE(PanelClass:
nSize)
END_EVENT_TABLE()
// The Frame, this is the topleve windows, which hosts the panel
class FrameClass : public wxFrame
{
public:
FrameClass(wxFrame *frame, const wxChar *title, int x, int y, int w, int h) :
wxFrame(frame, wxID_ANY, title, wxPoint(x, y), wxSize(w, h))
{
Panel = new PanelClass(this, x, y, w, h);
}
~FrameClass()
{
delete Panel;
}
PanelClass *Panel;
};
// The application, all applications has one
class AppClass: public wxApp
{
public:
bool OnInit()
{
Frame = new FrameClass(0, "Andengradsligning", 100, 100, 300, 200);
Frame->Show(true);
SetTopWindow(Frame);
return true;
}
FrameClass *Frame;
};
IMPLEMENT_APP(AppClass)
// The function that is called when the user hits the Add button.
void PanelClass:
nAddButton(wxCommandEvent &WXUNUSED(event))
{ }
</pre>
Lige nu, er mit spørgsmål, hvordan jeg får indsat nogle "labels" hvor jeg f.eks kan skrive "Indtast a:".. altså muligheden for at smide noget tekst på vinduet.
Mange tak for din store hjælp. Bare sig til, hvis det her bliver for besværligt.
Mvh Dennis Madsen
http://www.demaweb.dk