#include <Application.h>
A program that uses Vaca library must to create one instance of this class, or an instance of a derived class.
Public Member Functions | |
Application () | |
Initializes the variables of the Application class. | |
virtual | ~Application () |
Finishes the application. | |
virtual void | run () |
The common way to start the application. | |
Static Public Member Functions | |
static Application * | getInstance () |
Returns the Application's singleton. | |
static HINSTANCE | getHandle () |
Returns the Win32's HINSTANCE . | |
Private Member Functions | |
virtual void | main () |
The application entry point. | |
Static Private Attributes | |
static HINSTANCE | m_HINSTANCE = NULL |
The HINSTANCE (W32). | |
static Application * | m_instance = NULL |
The singleton, the only instance of Application (or a class derived from Application) that a program can contain. |
Application::Application | ( | ) |
Initializes the variables of the Application class.
It calls Win32's CoInitialize
and InitCommonControls
.
Application::~Application | ( | ) | [virtual] |
Finishes the application.
It calls Win32's CoUninitialize
.
Application * Application::getInstance | ( | ) | [static] |
Returns the Application's singleton.
A program using Vaca must have one instance of Applicaton or a class derived from it.
HINSTANCE Application::getHandle | ( | ) | [static] |
Returns the Win32's HINSTANCE
.
For internal use only.
void Application::run | ( | ) | [virtual] |
The common way to start the application.
You should call this method from main or WinMain, using the instance of Application.
The work of this routine is really simple: it calls main and then doMessageLoop. You can make your own class derived from Application and override main so you can customized the initialization (e.g. show a Frame).
Example:
int PASCAL WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { Application app; Frame frm("My frame"); frm.setVisible(true); app.run(); return 0; }
The same example with a variation:
class MyApp : public Application { Frame frm; public: MyApp() : frm("My frame") { } virtual void main() { frm.setVisible(true); } }; int PASCAL WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { MyApp app; app.run(); return 0; }
void Application::main | ( | ) | [private, virtual] |
The application entry point.
After calling run, main is executed and when it finishes, the doMessageLoop is automatically executed (to process messages for visible frames).
HINSTANCE Application::m_HINSTANCE = NULL [static, private] |
Application * Application::m_instance = NULL [static, private] |
The singleton, the only instance of Application (or a class derived from Application) that a program can contain.