Re: Compiling a C++/Wx program

  • From: "jaffar" <jaffar@xxxxxxxxxxxxx>
  • To: <programmingblind@xxxxxxxxxxxxx>
  • Date: Wed, 28 Nov 2007 08:37:05 +0800

Hi Jamal.  Give me a a day or 2.  Cheers!
----- Original Message ----- From: "Jamal Mazrui" <empower@xxxxxxxxx>
To: <programmingblind@xxxxxxxxxxxxx>
Sent: Wednesday, November 28, 2007 6:47 AM
Subject: Compiling a C++/Wx program


Jaffar's tutorial helped me build the Wx libraries with Microsoft Visual
C++ 2005 Express.  I initially chose the ANSI and release options.  I now
have a fruit basket program that compiles but fails to link (many
unresolved symbols).  Can anyone help me write a batch file or make file
that builds an executable out of the code below?

Jamal
#include "wx/wx.h"

class FruitBasket : public wxApp {
public:
wxDialog *dlg;
wxListBox *lstBasket;
wxTextCtrl *txtFruit;
wxButton *btnAdd, *btnDelete;

bool OnInit() {
dlg = new wxDialog(NULL, wxID_ANY, "Fruit Basket", wxDefaultPosition,
wxSize(513, 176));
new wxStaticText(dlg, wxID_ANY, "&Fruit:", wxPoint(14, 14),
wxDefaultSize);
txtFruit = new wxTextCtrl(dlg, wxID_ANY, "", wxPoint(43, 14),
wxDefaultSize, wxTE_LEFT);

new wxStaticText(dlg, wxID_ANY, "&Basket:", wxPoint(251, 14),
wxDefaultSize);
lstBasket = new wxListBox(dlg, wxID_ANY, wxPoint(293,14), wxDefaultSize,
0);

btnAdd = new wxButton(dlg, wxID_ANY, "&Add", wxPoint(190, 121),
wxDefaultSize);
btnAdd->SetDefault();
dlg->Connect(btnAdd->GetId(), wxEVT_COMMAND_BUTTON_CLICKED,
wxCommandEventHandler(FruitBasket::OnAdd));

btnDelete = new wxButton(dlg, wxID_ANY, "&Delete", wxPoint(217, 121),
wxDefaultSize);
dlg->Connect(btnDelete->GetId(), wxEVT_COMMAND_BUTTON_CLICKED,
wxCommandEventHandler(FruitBasket::OnDelete));

dlg->Connect(wxEVT_CLOSE_WINDOW,
wxCommandEventHandler(FruitBasket::OnClose));
dlg->Centre();
dlg->Show(true);
return true;
} // OnInit

void OnAdd(wxCommandEvent& event) {
wxString sValue = txtFruit->GetValue();
if (sValue == "") {
wxMessageBox("No fruit to add!", "Alert", wxICON_EXCLAMATION, dlg);
}
else {
lstBasket->Append(sValue);
txtFruit->Clear();
int iFruit = lstBasket->GetCount() - 1;
lstBasket->SetSelection(iFruit);
}
} // OnAdd

void OnDelete(wxCommandEvent& event) {
int iFruit = lstBasket->GetSelection();
if (iFruit == -1) {
wxMessageBox("No fruit to delete!", "Alert", wxICON_EXCLAMATION, dlg);
}
else {
lstBasket->Delete(iFruit);
if (iFruit == lstBasket->GetCount()) {iFruit--;}
lstBasket->SetSelection(iFruit);
}
} // OnDelete

void OnClose(wxCommandEvent& event) {
if (wxMessageBox("Exit program?", "Confirm", wxYES_NO, dlg) == wxYES)
{dlg->Destroy();}
} // OnClose
};

IMPLEMENT_APP(FruitBasket)

__________
View the list's information and change your settings at //www.freelists.org/list/programmingblind

__________
View the list's information and change your settings at //www.freelists.org/list/programmingblind

Other related posts: