I'm developping an app with db access throught the SQLAPI classe, so my class to access data base is no wx derived. I create one class called MyDB it is derived from SAConnection (the classe to create a connection object). My app has a frame with icons to access db, ie, connect and disconnect.
Until now my db access is working because a put at MyFrame class (derived from wxFrame) the connect method, and I create a instance of MyDB called db_con. So my problem is, I want to put all my method to access data base (connect, disconnect, query...) in the MyDB class.
I know with this is possible, but I need to use event, and.. so .. do dont know anything about how to get and send event between class. I only work with event in the same class. Someone could help me with this?
my_frame.h
Code: Select all
#ifndef __myframe_H
#define __myframe_H
class MyFrame: public wxFrame
{
public:
...//other methods
void OnConnect( wxCommandEvent& event );
void OnDisconnect( wxCommandEvent& event );
void OnQuery( wxCommandEvent& event );
private:
...//other methods
DECLARE_EVENT_TABLE()
};
#endif
Code: Select all
...
#include "myframe.h"
#include "mydb.h"
...
MyDB *db_con = new MyDB;
BEGIN_EVENT_TABLE( MyFrame, wxFrame )
...
EVT_MENU( ID_Connect , MyFrame::OnConnect)
EVT_MENU( ID_Disconnect , MyFrame::OnDisconnect )
EVT_MENU( ID_Query , MyFrame::OnQuery )
...
END_EVENT_TABLE()
void MyFrame::OnConnect(wxCommandEvent& WXUNUSED(event))
{
...
db_con->setClient(SA_SQLServer_Client);
db_con->Connect(... the necessery parameters...);
...
}
Code: Select all
#ifndef __mydb_H
#define __mydb_H
class MyDB: public SAConnection
{
public:
bool QueryDB( MyDB *con , MyFrame *frame );
private:
};
#endif
[]s.