Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 683205
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T01:40:54+00:00 2026-05-14T01:40:54+00:00

I’m working on a program for my C++ programming class, using wxWidgets. I’m having

  • 0

I’m working on a program for my C++ programming class, using wxWidgets. I’m having a huge problem in that my event handlers (I assume) are not getting called, because when I click on the button to trigger the event, nothing happens. My question is: Can you help me find the problem and explain why they would not be getting called?

The event handlers OnAbout and OnQuit are working, just not OnCompute or OnClear. I’m really frustrated as I can’t figure this out. Thanks a bunch in advance!

#include "wx/wx.h"
#include "time.h"
#include <string>
using std::string;

// create object of Time class
Time first;

class App: public wxApp
{
virtual bool OnInit();
};

class MainPanel : public wxPanel
{
 public:
   // Constructor for panel class
   // Constructs my panel class 
   // Params - wxWindow pointer
   // no return type
   // pre-conditions: none
   // post-conditions: none
   MainPanel(wxWindow* parent);
   // OnCompute is the event handler for the Compute button
   // params - none
   // preconditions - none
   // postconditions - tasks will have been carried otu successfully
   // returns void
   void OnCompute(wxCommandEvent& WXUNUSED(event));
   // OnClear is the event handler for the Clear button
   // params - none
   // preconditions - none
   // postconditions - all text areas will be cleared of data
   // returns void
   void OnClear(wxCommandEvent& WXUNUSED(event));
   // Destructor for panel class
   // params none
   // preconditions - none
   // postconditions - none
   // no return type
   ~MainPanel( );
  private:
wxStaticText *startLabel;
wxStaticText *endLabel;
wxStaticText *pCLabel;
wxStaticText *newEndLabel;
wxTextCtrl *start;
wxTextCtrl *end;
wxTextCtrl *pC;
wxTextCtrl *newEnd;
wxButton *compute;
wxButton *clear;

     DECLARE_EVENT_TABLE()
    };


class MainFrame: public wxFrame
{
private:
wxPanel *mainPanel;
public:
MainFrame(const wxString& title, const wxPoint& pos, const wxSize& size);

void OnQuit(wxCommandEvent& event);
void OnAbout(wxCommandEvent& event);

~MainFrame();

  DECLARE_EVENT_TABLE()
  };

enum
{
ID_Quit = 1,
ID_About,
BUTTON_COMPUTE = 100,
BUTTON_CLEAR = 200
};

IMPLEMENT_APP(App)

BEGIN_EVENT_TABLE(MainFrame, wxFrame)
    EVT_MENU(ID_Quit, MainFrame::OnQuit)
    EVT_MENU(ID_About, MainFrame::OnAbout)
END_EVENT_TABLE()

BEGIN_EVENT_TABLE(MainPanel, wxPanel)
EVT_MENU(BUTTON_COMPUTE, MainPanel::OnCompute)
EVT_MENU(BUTTON_CLEAR, MainPanel::OnClear)
END_EVENT_TABLE()

bool App::OnInit()
{
MainFrame *frame = new MainFrame( _("Good Guys Delivery Time Calculator"), wxPoint(50,       50),
                              wxSize(450,340) );
frame->Show(true);
SetTopWindow(frame);
return true;
} 

MainPanel::MainPanel(wxWindow* parent) : wxPanel(parent) 
{
startLabel = new wxStaticText(this, -1, "Start Time:", wxPoint(75, 35));
start = new wxTextCtrl(this, -1, "", wxPoint(135, 35), wxSize(40, 21));

endLabel = new wxStaticText(this, -1, "End Time:", wxPoint(200, 35));
end = new wxTextCtrl(this, -1, "", wxPoint(260, 35), wxSize(40, 21));

pCLabel = new wxStaticText(this, -1, "Percent Change:", wxPoint(170, 85));
pC = new wxTextCtrl(this, -1, "", wxPoint(260, 85), wxSize(40, 21));

newEndLabel = new wxStaticText(this, -1, "New End Time:", wxPoint(180, 130));
newEnd = new wxTextCtrl(this, -1, "", wxPoint(260, 130), wxSize(40, 21));

compute = new wxButton(this, BUTTON_COMPUTE, "Compute", wxPoint(135, 185),  wxSize(75, 35));
clear = new wxButton(this, BUTTON_CLEAR, "Clear", wxPoint(230, 185), wxSize(75, 35));
}

MainPanel::~MainPanel() {}

MainFrame::MainFrame(const wxString& title, const wxPoint& pos, const wxSize& size)
: wxFrame( NULL, -1, title, pos, size )
{
mainPanel = new MainPanel(this);
wxMenu *menuFile = new wxMenu;

menuFile->Append( ID_About, _("&About...") );
menuFile->AppendSeparator();
menuFile->Append( ID_Quit, _("E&xit") );

wxMenuBar *menuBar = new wxMenuBar;
menuBar->Append( menuFile, _("&File") );

SetMenuBar( menuBar );

CreateStatusBar();
SetStatusText( _("Hi") );
}

MainFrame::~MainFrame() {}

void MainFrame::OnQuit(wxCommandEvent& WXUNUSED(event))
{
Close(TRUE);
}

void MainFrame::OnAbout(wxCommandEvent& WXUNUSED(event))
{
wxMessageBox( _("Alex Olson\nProject 11"),
              _("About"),
              wxOK | wxICON_INFORMATION, this);
}

void MainPanel::OnCompute(wxCommandEvent& WXUNUSED(event))
{
int startT;
int endT;
int newEndT;
double tD;

wxString startTString = start->GetValue();
wxString endTString = end->GetValue();

startT = wxAtoi(startTString);
endT = wxAtoi(endTString);

pC->GetValue().ToDouble(&tD);

first.SetStartTime(startT);
first.SetEndTime(endT);
first.SetTimeDiff(tD);

try {
    first.ValidateData();
    newEndT = first.ComputeEndTime();
    *newEnd << newEndT;
}
catch (BaseException& e) {
    wxMessageBox(_(e.GetMessage()), 
                 _("Something Went Wrong!"),
                 wxOK | wxICON_INFORMATION, this);
}
}

void MainPanel::OnClear(wxCommandEvent& WXUNUSED(event))
{
start->Clear();
end->Clear();
pC->Clear();
newEnd->Clear();
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T01:40:54+00:00Added an answer on May 14, 2026 at 1:40 am

    EVT_MENU(BUTTON_COMPUTE,
    MainPanel::OnCompute)
    EVT_MENU(BUTTON_CLEAR,
    MainPanel::OnClear)

    In the above statements use EVT_BUTTON instead of EVT_MENU.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I am doing a simple coin flipping experiment for class that involves flipping a
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
I need a function that will clean a strings' special characters. I do NOT
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace
I am reading a book about Javascript and jQuery and using one of the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.