I try to use wxWidgets in my C project.
As far as I know, for wxWidgets I need to use wxIMPLEMENT_APP(MyAPP );
instead of the main()
function.
I don't understand how to write other functions to do other work before my wxWidgets graphics object is created.
In other words, I would like to understand how to get a result like this:
int main(int argc, char* argv[]) {
configure_application_1();
app_config app_cfg;
app_configuration(app_cfg);
other_functions();
___create_wxWidgets________
}
CodePudding user response:
According to the official doc:
A wxWidgets application does not have a main procedure; the equivalent is the wxApp::OnInit member defined for a class derived from wxApp.
So put your code in wxApp::OnInit
function.
CodePudding user response:
The main()
, or WinMain()
(or other entry points that used to exist, but don't any more because the corresponding platforms have gone extinct), is part of wxIMPLEMENT_APP() macro expansion. If you don't want it to define your entry point, you can use wxIMPLEMENT_APP_NO_MAIN()
, but then you're responsible for initializing the library yourself.
However typically you would just leave it be and put your initialization code in your overridden MyApp::OnInit()
, where MyApp
is your class inheriting from wxApp
.