Multiple Event Tables Topic is solved

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
xtreampb
Earned some good credits
Earned some good credits
Posts: 136
Joined: Fri Jul 31, 2009 8:20 pm
Location: Virginia
Contact:

Multiple Event Tables

Post by xtreampb »

Is it Possible to have multiple event tables for multiple frames. I create a Class and call it "main frame" and that class has it's own event table, Then i create a second class and call that 'Frame 2" and give that class an event table. They are in the same project, is it ok for them to each have an event table, or am I only allowed to have one event table in my solution?

~Xtreampb~
spectrum
Filthy Rich wx Solver
Filthy Rich wx Solver
Posts: 207
Joined: Sat Jul 21, 2007 12:17 pm

Post by spectrum »

every wxFrame or wxWindow derive from other classes, one of them is "wxEvtHandler".
So the answer is yes, you have always an event handler for every window.
Then, decalring an event table for every frame you can have multiple event table. About declaring and using the tables,sSee the samples included in the library.

regards
spectrum
xtreampb
Earned some good credits
Earned some good credits
Posts: 136
Joined: Fri Jul 31, 2009 8:20 pm
Location: Virginia
Contact:

Post by xtreampb »

ok so this leads to my next question. I am getting linking errors similar to this
Error 8 error LNK2005: "protected: virtual struct wxEventTable const * __thiscall Add_Edit::GetEventTable(void)const " (?GetEventTable@Add_Edit@@MBEPBUwxEventTable@@XZ) already defined in Main.obj Add_Edit.obj


I am using wxWidgets 2.9.0

What happens is that i got all of my frames declared in a main frame. the the Main frame is hits the constructor, it creates all of my other frames. they are shown and hidden based off of buttons in their own frame and event tables. here is some code.

Code: Select all

MainFrame::MainFrame(const wxString&Title):wxFrame(NULL,wxID_ANY,Title,wxDefaultPosition,wxSize(681,277))
{
	SetIcon(wxICON(sample));
	
	//Create the other frames
	this->Add_EditFrame=new Add_Edit(_T("Add Edit Employee"),wxDefaultPosition,wxSize(621, 255));
	this->Mod_SchOpt=new wxFrame(NULL,wxID_ANY,_T("Modify Schedule Options"),wxDefaultPosition,wxSize(385,156),wxMINIMIZE_BOX | wxMAXIMIZE_BOX | wxRESIZE_BORDER | wxSYSTEM_MENU | wxCAPTION | wxCLIP_CHILDREN);
//Create the other frames
	//more code
}
//that was the main frame constructor.  here is the add edit constructor
Add_Edit::Add_Edit(const wxString &title, const wxPoint &pos, const wxSize &size):wxFrame(NULL,wxID_ANY,title, wxDefaultPosition, wxSize(621, 255),wxMINIMIZE_BOX | wxMAXIMIZE_BOX | wxRESIZE_BORDER | wxSYSTEM_MENU | wxCAPTION | wxCLIP_CHILDREN)
{
//constructor code
}

i think it might be how i have the base class set up for my add edit class
spectrum
Filthy Rich wx Solver
Filthy Rich wx Solver
Posts: 207
Joined: Sat Jul 21, 2007 12:17 pm

Post by spectrum »

You have to declare correctly the event tables, please see the samples.

In every derived frame class you need:

Code: Select all


class YourFrame : public wxFrame
{

....

DECLARE_EVENT_TABLE();

};

in every cpp you need:

BEGIN_EVENT_TABLE (YourFrame , wxFrame)
	EVT_BUTTON (wxID_OK, YourFrame ::OnOk)
	EVT_CLOSE (YourFrame ::OnClose)
END_EVENT_TABLE()

Put attention that the "YourFrame" in every BEGIN_EVENT_TABLE of every frame must be correct.

regards
spectrum
Post Reply