start-up event 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
geese
In need of some credit
In need of some credit
Posts: 4
Joined: Tue Jul 15, 2008 1:57 am

start-up event

Post by geese » Fri Aug 08, 2008 8:04 pm

Quick question . . .
I have a simple frame with a wxListBox (nothing else) and I want to "read" some data from a text file into it.
I know how to read the data into the wxListBox but my issue is that I want to do it on start-up.

How can I get this done on start-up?

I am very new to wxWidgets and a couple lines of code will be very helpful.


Thanks.

FlyingIsFun1217
Super wx Problem Solver
Super wx Problem Solver
Posts: 497
Joined: Mon Nov 06, 2006 9:58 pm

Post by FlyingIsFun1217 » Fri Aug 08, 2008 8:55 pm

Lets say that wxWidgets wasn't involved at all. How would you get something to happen on startup? Even a VERY basic program: How would you get the terminal to echo "Hello World" out?

FlyingIsFun1217 ;)

geese
In need of some credit
In need of some credit
Posts: 4
Joined: Tue Jul 15, 2008 1:57 am

Post by geese » Fri Aug 08, 2008 9:10 pm

Code: Select all

int main()
{
    cout << "Hello world!" << endl;
    return 0;
}
I am sort of okay with c++ but not very good.

I still don't see how it falls in here -

Code: Select all

class MyApp : public wxApp
{
    public:
        virtual bool OnInit();
};

DECLARE_APP(MyApp)
IMPLEMENT_APP( MyApp )

bool MyApp::OnInit()
{
    wxInitAllImageHandlers();
    mainFrame *frame = new mainFrame(NULL);
    frame->Show(true);
    SetTopWindow(frame);
    return true;
}
or should I just buy the book . . .?

FlyingIsFun1217
Super wx Problem Solver
Super wx Problem Solver
Posts: 497
Joined: Mon Nov 06, 2006 9:58 pm

Post by FlyingIsFun1217 » Fri Aug 08, 2008 9:31 pm

Think of OnInit as your main().

And where are you creating your wxListBox? Why not just load what you need there, since you KNOW it's being initialized there?

FlyingIsFun1217

geese
In need of some credit
In need of some credit
Posts: 4
Joined: Tue Jul 15, 2008 1:57 am

Post by geese » Fri Aug 08, 2008 9:39 pm

Ah. . .cool.
Thanks, figured it out.

FlyingIsFun1217
Super wx Problem Solver
Super wx Problem Solver
Posts: 497
Joined: Mon Nov 06, 2006 9:58 pm

Post by FlyingIsFun1217 » Fri Aug 08, 2008 9:56 pm

For future reference, you click 'Accept!' on the post that solved your error / problem, not your own. And no, clicking on your own post does not give you wxPoints ;)

FlyingIsFun1217

geese
In need of some credit
In need of some credit
Posts: 4
Joined: Tue Jul 15, 2008 1:57 am

Post by geese » Sat Aug 09, 2008 3:38 am

FlyingIsFun1217 wrote:For future reference, you click 'Accept!' on the post that solved your error / problem, not your own. And no, clicking on your own post does not give you wxPoints ;)

FlyingIsFun1217
Yeah, I was not trying to give myself wxPoints, I just was not sure what to click on. :?

FlyingIsFun1217
Super wx Problem Solver
Super wx Problem Solver
Posts: 497
Joined: Mon Nov 06, 2006 9:58 pm

Post by FlyingIsFun1217 » Sat Aug 09, 2008 2:25 pm

No biggie ;)

FlyingIsFun1217

Post Reply