need help in c++/wxwidgets project Topic is solved
I've read the whole thread. I think you're drowning in a glass of water (nda: french idioma). wxWidgets is nothing more than a C++ framework (in fact, C++/Python/C#/Perl).
It provides a set of classes, and an obvious part of them is aimed to design GUI.
So, the framework is built and works upon this principle : GUI application. So, no main(), but a wxApp class which has merely the same purpose.
Generally, a main() is only made of functions/methods calls. Relevant code is inside functions and methods.
That's the same thing here : wxApp class creates a wxFrame object and keeps on running into an invisible loop (the "return TRUE" at the end of wxApp code). As a GUI application is designed to wait for user commands, relevant code is in wxFrame object (and objects it uses and creates).
That's all.
All other stuff is pure C++ stuff.
It provides a set of classes, and an obvious part of them is aimed to design GUI.
So, the framework is built and works upon this principle : GUI application. So, no main(), but a wxApp class which has merely the same purpose.
Generally, a main() is only made of functions/methods calls. Relevant code is inside functions and methods.
That's the same thing here : wxApp class creates a wxFrame object and keeps on running into an invisible loop (the "return TRUE" at the end of wxApp code). As a GUI application is designed to wait for user commands, relevant code is in wxFrame object (and objects it uses and creates).
That's all.
All other stuff is pure C++ stuff.
-
- Earned some good credits
- Posts: 120
- Joined: Sun Sep 21, 2008 7:23 am
- Location: Somwhere nearby...
- Contact:
many tanx dear . yeah , and it is located in wxApp::OnInit() right? so what ever i want to do , i should use wApp::OnIt(). and place the objects there ! cause its the starting function! just like int main() in a console application. ( Dear Auria thank you for your correction)TrV wrote:I've read the whole thread. I think you're drowning in a glass of water (nda: french idioma). wxWidgets is nothing more than a C++ framework (in fact, C++/Python/C#/Perl).
It provides a set of classes, and an obvious part of them is aimed to design GUI.
So, the framework is built and works upon this principle : GUI application. So, no main(), but a wxApp class which has merely the same purpose.
Generally, a main() is only made of functions/methods calls. Relevant code is inside functions and methods.
That's the same thing here : wxApp class creates a wxFrame object and keeps on running into an invisible loop (the "return TRUE" at the end of wxApp code). As a GUI application is designed to wait for user commands, relevant code is in wxFrame object (and objects it uses and creates).
That's all.
All other stuff is pure C++ stuff.
Add-on Components (90)
Applications (183)
Development Tools (27)
Icons and Resources (1)
Sample Code and Project Templates (10)
Utilities (4)
wxWidgets (10)
http://www.wxcommunity.com/
Applications (183)
Development Tools (27)
Icons and Resources (1)
Sample Code and Project Templates (10)
Utilities (4)
wxWidgets (10)
http://www.wxcommunity.com/
For classic GUI, wxApp::OnInit() contains a MyFrame instanciation (MyFrame inherits from wxFrame), and a few initializations, like parameters retrieved from the command line, which generally are passed to the MyFrame object (like size and position of frame) : around 10-50 lines for wxApp::OnInit().Hossein wrote:many tanx dear . yeah , and it is located in wxApp::OnInit() right? so what ever i want to do , i should use wApp::OnIt(). and place the objects there ! cause its the starting function! just like int main() in a console application. ( Dear Auria thank you for your correction)
I repeat, most part of relevant code is owned by MyFrame object (and its objects) : > 1000 lines for a tiny application.
The principle purpose of wxApp::OnInit() is to - what a big deal - do some initializations.
-
- Ultimate wxWidgets Guru
- Posts: 536
- Joined: Fri Jan 07, 2005 3:44 pm
- Location: Finland
- Contact:
1) You commonly initialize your application resources (create a frame, load configs etc.) in YourApp::OnInit. This corresponds to int main (...) in an console app. It doesn't matter what the name of the cpp file is (usually YourApp.cpp)
2) Nobody can tell you where you should create the instances of your classes since that really depends on what the classes will do, when/where they are needed and how long they are supposed to exist. You could for example create instances in the event handler functions or as member variable in some GUI class. Example:
HTH
2) Nobody can tell you where you should create the instances of your classes since that really depends on what the classes will do, when/where they are needed and how long they are supposed to exist. You could for example create instances in the event handler functions or as member variable in some GUI class. Example:
Code: Select all
class YourFrame : public wxFrame
{
public:
.
.
.
private:
SomeClass mInst;
void OnMenuDoSomethingClicked ( wxCommandEvent &rEvt );
void OnMenuDoSomethingElseClicked ( wxCommandEvent &rEvt );
};
void YourFrame::OnMenuDoSomethingClicked ( wxCommandEvent &rEvt )
{
mInst.DoSomething();
}
void YourFrame::OnMenuDoSomethingElseClicked ( wxCommandEvent &rEvt )
{
SomeOtherClass inst;
inst.DoSomething();
}
Visual C++ 9.0 / Windows XP Pro SP3 / wxWidgets 2.9.0 (SVN) | Colligere
-
- Earned some good credits
- Posts: 120
- Joined: Sun Sep 21, 2008 7:23 am
- Location: Somwhere nearby...
- Contact:
thank you very very much , i really appreciate it.
by the way do you mind if i have a problem, i post it here?!
by the way do you mind if i have a problem, i post it here?!
Add-on Components (90)
Applications (183)
Development Tools (27)
Icons and Resources (1)
Sample Code and Project Templates (10)
Utilities (4)
wxWidgets (10)
http://www.wxcommunity.com/
Applications (183)
Development Tools (27)
Icons and Resources (1)
Sample Code and Project Templates (10)
Utilities (4)
wxWidgets (10)
http://www.wxcommunity.com/
-
- Ultimate wxWidgets Guru
- Posts: 536
- Joined: Fri Jan 07, 2005 3:44 pm
- Location: Finland
- Contact:
No, please don't reuse an old topic for new questions. It's best to create a new one.Hossein wrote:by the way do you mind if i have a problem, i post it here?!
Visual C++ 9.0 / Windows XP Pro SP3 / wxWidgets 2.9.0 (SVN) | Colligere