sourabh grover
sourabh grover

Reputation: 19

How to popup a dialog box in c++ wxidgets using main() not init()

I am popuping a dialogbox from displaying logs using wxwidgets of c++, which contains init() for initialization. i want to know that can init() is necessary to popup a dialog or same can be done using only main() only in c++. please guide me.

Upvotes: 1

Views: 2191

Answers (3)

baxit
baxit

Reputation: 242

You can find a lengthy discussion on how to initialize a wx-application from a custom main routine here: wxApp without Macros

from my experience i can tell you that it is ok to show modal dialogs (e.g. wxMessageDialog::ShowModal) in the wxApp::OnInit implementation.

this is just a quess but, using the information provided in the link above you should be able to show modal dialogs after calling:

   wxApp::SetInstance( new MyWxApp() );
   wxEntryStart( argc, argv );

Upvotes: 1

ravenspoint
ravenspoint

Reputation: 20492

It is very hard to understand your question.

I am guessing you are asking about WHERE to call the constructor and other methods of the controls you want to create. This is best answered by looking at the sample applications that come with the wxWidgets distribution.

You should not call anything from the main()function of your program. You should call the constructor for your top level frame fromthe wxAPP method Init(). The rest should probably be called from the top level window constructor and its methods. It is hard to answer these questions in general. Please look at the sample code to see how things are done.

Upvotes: 0

Thomas Matthews
Thomas Matthews

Reputation: 57718

Are you talking about a dialog box:
wxMessageDialog

Or a Splash Screen: wxSplashScreen

You could always use the underlying OS API to draw your own windows; although that may take a lot of setup.

Upvotes: 0

Related Questions