I have completed a wxform called Siotest. It complies and runs perfectly.
The question now is, Where is the 'MAIN' proceedure (new to c++) and
where do I enter my code.
I think this might be the equivalent to 'MAIN'
In 'Siotestapp.cpp'
bool SiotestFrmApp::OnInit()
{
SiotestFrm "myFrame = new SiotestFrm(NULL);
SetTopWindow(myFrame);
myFrame->Show(TRUE);
return TRUE;
}
Where do I enter my code for my Sio Test application ?
Where is MAIN ?
Re: Where is MAIN ?
Hi!
The "main" function (or "WinMain" on Windows) gets implemented automatically by using the IMPLEMENT_APP() macro. This macro expands to the correct "main" form for your platform.
Where you enter your code is up to you... Most likely you create a frame like "myFrame" and add your code and event handlers there.
Check out NinjaNLs tutorial hosted on my site http://www.upcase.de/wxDevCpp_tutorial/ ... nimal.html
You're right, OnInit() is the main entrance to your application as it starts the main event loop.johnb wrote: The question now is, Where is the 'MAIN' proceedure (new to c++) and
where do I enter my code.
I think this might be the equivalent to 'MAIN'
In 'Siotestapp.cpp'
bool SiotestFrmApp::OnInit()
{
SiotestFrm "myFrame = new SiotestFrm(NULL);
SetTopWindow(myFrame);
myFrame->Show(TRUE);
return TRUE;
}
Where do I enter my code for my Sio Test application ?
The "main" function (or "WinMain" on Windows) gets implemented automatically by using the IMPLEMENT_APP() macro. This macro expands to the correct "main" form for your platform.
Where you enter your code is up to you... Most likely you create a frame like "myFrame" and add your code and event handlers there.
Check out NinjaNLs tutorial hosted on my site http://www.upcase.de/wxDevCpp_tutorial/ ... nimal.html
OS: OpenSuSE, Ubuntu, Win XP Pro
wx: svn
Compiler: gcc 4.5.1, VC 2008, eVC 4
"If it was hard to write it should be hard to read..." - the unknown coder
"Try not! Do. Or do not. There is no try." - Yoda
wx: svn
Compiler: gcc 4.5.1, VC 2008, eVC 4
"If it was hard to write it should be hard to read..." - the unknown coder
"Try not! Do. Or do not. There is no try." - Yoda
Re: Where is MAIN ?
Hi, I read and studied this very old post.upCASE wrote: ↑Tue Apr 26, 2005 2:24 pm You're right, OnInit() is the main entrance to your application as it starts the main event loop.
The "main" function (or "WinMain" on Windows) gets implemented automatically by using the IMPLEMENT_APP() macro. This macro expands to the correct "main" form for your platform.
Where you enter your code is up to you... Most likely you create a frame like "myFrame" and add your code and event handlers there.
Check out NinjaNLs tutorial hosted on my site http://www.upcase.de/wxDevCpp_tutorial/ ... nimal.html
I met a problem, my main(...) has some setup in between the myFrame.
The simple flow as follow:
main() {
//initial some files handle
//read, update data to file
//show the ui
//myApp, myFrame process
//need to get the response from UI
//write data to file
//close the file handle
}
There is a OnInit and OnExit in myApp.
The main problem is the initialization and write files in between the UI display. It is difficult to split such initialization process in OnInit, then update and close files handle in OnExit.
Is there any method to keep the main() like structure?
Thanks
Re: Where is MAIN ?
Please do not revive ancient threads.
If you prefer to keep your main() / WinMain(), you can use one of wxEntry*() functions or wxInitializer.
But I think you should have a really good reason to break the usual pattern.
If you prefer to keep your main() / WinMain(), you can use one of wxEntry*() functions or wxInitializer.
But I think you should have a really good reason to break the usual pattern.
Re: Where is MAIN ?
Many thanks.
I have tried the wxEntry(), the UI resolution is a bit lower, not sure the reason.
Felt that if open a new topic, the question will be duplicated.
Re: Where is MAIN ?
Hi,
First of all - there is no duplication of the thread with the question, only duplication of the code.
Second - it is generally very good idea to close file handle(s) after you are done and not keep them open until the application is closed.
Essentially you application will keep the file exclusively open just for itself and nobody else will be able to do anything with them - not even you on another thread/Terminal. You don't want to do that.
And what happen if you accidentally forget to close one of the handles? You will have to reboot and spend some time researching why you can't run the progrm second time...
Now in regards to keeping the main() - why?
Is your application a GUI or console based? Is it a C++ or C based?
Are you yourself coming from the C background?
What is it that you can't do in the OnInit() that will absolutely have to happen in a matter of milliseconds after the user starts an application and it absolutely can't happen in 1 second? Please be as detailed as possible here.
Thank you.
First of all - there is no duplication of the thread with the question, only duplication of the code.
Second - it is generally very good idea to close file handle(s) after you are done and not keep them open until the application is closed.
Essentially you application will keep the file exclusively open just for itself and nobody else will be able to do anything with them - not even you on another thread/Terminal. You don't want to do that.
And what happen if you accidentally forget to close one of the handles? You will have to reboot and spend some time researching why you can't run the progrm second time...
Now in regards to keeping the main() - why?
Is your application a GUI or console based? Is it a C++ or C based?
Are you yourself coming from the C background?
What is it that you can't do in the OnInit() that will absolutely have to happen in a matter of milliseconds after the user starts an application and it absolutely can't happen in 1 second? Please be as detailed as possible here.
Thank you.
Re: Where is MAIN ?
Hello, thanks a lot.
The existing code is redirect the stdio to file, so it open the file handle until close. The main purpose is to trace any exception in other library.
That's a good suggestion to close other file handle, will try it.
Yes, myself coming from C background.
The original application is console based, will parse the argc, argv then pass the value into other library (black box). It is c++ based code with very minimal c code internal (e.g. c like pointer casting). When shift to GUI based, some design need to keep, that's why open the file handle until terminate.
Haven't realize this, the original design redirect the stdio to file and then will copy that file to another file after user quit the UI. Thinking how to optimize the program flow.
Thanks again.