Vaca::Application Class Reference

#include <Application.h>

Inheritance diagram for Vaca::Application:

Vaca::Thread Vaca::NonCopyable

List of all members.


Detailed Description

The main class of Vaca: initializes and destroys the GUI library resources.

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 ApplicationgetInstance ()
 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 Applicationm_instance = NULL
 The singleton, the only instance of Application (or a class derived from Application) that a program can contain.


Constructor & Destructor Documentation

Application::Application (  ) 

Initializes the variables of the Application class.

It calls Win32's CoInitialize and InitCommonControls.

See also:
run

Application::~Application (  )  [virtual]

Finishes the application.

It calls Win32's CoUninitialize.


Member Function Documentation

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;
 }

See also:
Thread::doMessageLoop

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).


Member Data Documentation

HINSTANCE Application::m_HINSTANCE = NULL [static, private]

The HINSTANCE(W32).

For internal use only.

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.