I'm new to wxwidgets, and I'm trying to port a console project to enable more features, buttons to control some stuff, display database entries and so on. However I have trouble understanding how to adapt my code.
A simplified version of it is :
Code: Select all
#include <stdio.h>
...
#include <string>
#include "tree.hh"
#define LIMITESCR 10
#define IDKEY 5002177
typedef struct Structexample
{
std::array<long long, 5> longlongarray;
sqlite3 *db;
std::vector<std::array<long long, 5> > vectorofarray;
int sleep;
} structexample;
//function declare
void functionexample(structexample *gm);
//function code
void functionexample(structexample *gm){
//do some stuff on the structexample
}
int main(int argc, char* argv[]) {
//Initialisation
structexample gm;
gm.longlongarray = {0,0,0,0,0};
gm.sleep = 0;
int rc = sqlite3_open("memory.db", &gm.db);
while(1){
if(gm.sleep==0) {
//do some stuff, call some functions....
functionexample(&gm);
}
}
sqlite3_close(gm.db);
return 0;
}
Meanwhile having a table to show the database which is being updated by the loop.
And some wxTextCtrl to input some values in the structexample at run time.
But I am not sure how and where to do this as there is no main() function in the xxxMain.cpp. There's onInit() function in xxxApp.cpp but I don't understand, if I initialize the structexample here for example, how can I access it from handler functions?
And where to put the main loop?
Thanks for your help and sorry if it's noob questions.