I'm writing a program to display two forms. One is called Main, and the other is called Page_1. On execution, the program starts by displaying Main. When the user clicks the button, the display will show Page_1. Then the user clicks a button on Page_1 and the program displays Main again. Main, Page_1, Main, Page_1. Back and forth. Really simple.
My problem is that I cannot get my program to compile because I don't understand the syntax required in the main program to display Page_1. Does a new Page_1 need to be instantiated inside Main, in order to call the Main method to display the page? Why do my commands to instantiate Page_1 fail?
I'm not asking for anyone to write code for me. I could work from an example, if someone can send me a link. To try to figure this out, I've visited https://wiki.wxwidgets.org/Guides_%26_Tutorials, but these tutorials seem to be focused on building ONE page. Not jumping back and forth between pages. And I've visited http://svn.wxwidgets.org/viewvc/wx/wxWi ... s/display/, but I have no idea what to do when I look at that page. If it's not a CodeLite workspace file, I don't know what to do with it to compile and run it.
Here is what the two pages are supposed to look like. Here is MainFrame.cpp. Note the comments at the very end, showing my different attempts to call the method and the different error messages I got.
Code: Select all
#include <wx/aboutdlg.h>
#include <wx/msgdlg.h>
#include "MainFrame.h"
#include "Page_1_Class.h"
MainFrame::MainFrame(wxWindow* parent)
: MainFrameBaseClass(parent)
{
}
MainFrame::~MainFrame()
{
}
void MainFrame::OnExit(wxCommandEvent& event)
{
wxUnusedVar(event);
Close();
}
void MainFrame::OnAbout(wxCommandEvent& event)
{
wxUnusedVar(event);
wxAboutDialogInfo info;
info.SetCopyright(_("My MainFrame"));
info.SetLicence(_("GPL v2 or later"));
info.SetDescription(_("Short description goes here"));
::wxAboutBox(info);
}
void MainFrame::OnGotopage1_buttonButtonClicked(wxCommandEvent& event)
{
wxString a_st = "";
a_st = wxT("About to display Page 1...");
wxMessageBox(a_st, wxT("Navigating"), wxICON_NONE);
// How do I execute Build_Page_1? It resides in Page_1_Class.cpp.
// Here are my attempts and the error messages I've received.
// Page_1_BaseClass P1 = new(Page_1_BaseClass); // no matching function for call to 'Page_1_BaseClass::Page_1_BaseClass()'
// Page_1_Class P1 = new(Page_1_Class); // no matching function for call to 'Page_1_Class::Page_1_Class()'
// Build_Page_1 P1 = new(Build_Page_1); // FAIL: 'Build Page 1' was not declared in this scope
// Build_Page_1(); // 'Build_Page_1' was not declared in this scope
}
Code: Select all
// -----------------------------------------------------------------------------
// Page_1_Class.cpp
// -----------------------------------------------------------------------------
#include <wx/msgdlg.h>
#include "Page_1_Class.h"
Page_1_Class::Page_1_Class(wxWindow* parent)
: Page_1_BaseClass(parent)
{
}
Page_1_Class::~Page_1_Class()
{
}
void Page_1_Class::Build_Page_1(void)
{
wxString a_st = "";
a_st = wxT("Inside Build_Page_1!");
wxMessageBox(a_st, wxT("Made it!"), wxICON_HAND);
}
void Page_1_Class::OnGotomainButtonClicked(wxCommandEvent& event)
{
// What do I put here to return to the main page?
}
Code: Select all
#ifndef PAGE_1_CLASS_H
#define PAGE_1_CLASS_H
#include "wxcrafter.h"
class Page_1_Class : public Page_1_BaseClass
{
public:
Page_1_Class(wxWindow* parent);
virtual ~Page_1_Class();
virtual void Build_Page_1(void);
protected:
virtual void OnGotomainButtonClicked(wxCommandEvent& event);
};
#endif // PAGE_1_CLASS_H
Can someone please tell me what I'm doing wrong? Or better, give me a link where I can see an example of how this is done?
Thank you in advance!
Colleen
------------------
Software Versions:
------------------
CodeLite: 9.1.5
tdm-gcc: 5.1.0.3
Windows 7: 6.1
wxCrafter: 2.5
wxWidgets: 3.1.0
Target platform: 32-bit
Target build: debug