Navigation

News
About
Tutorials
Downloads
Forums

Creating a Simple Application

Before we begin, make sure you have set up the library for your compiler.
Create a new file called SimpleApplication.cpp. Now the first thing you have to do is include the WAL library, like so:
#include "wal.h"
Okay. The next thing that must be done is to create an instance of WAL and an entry point to the application:
WAL::WAL *wal;
INT WINAPI WinMain( HINSTANCE hInst, HINSTANCE, LPSTR strCmdLine, INT )
{
   wal = new WAL::WAL( hInst, strCmdLine );
     
With this done, the attributes for the main window can now be chosen. These can be chosen using the data member WAL::WAL::mAPIWindowProperties:
   wal->mAPIWindowProperties->Width = 640;
   wal->mAPIWindowProperties->Height = 480;
   wal->mAPIWindowProperties->Title = "Simple Application";
Now it's time to create the main window. This is done like so:
   wal->createMainWindow();
To spruce things up a bit, we'll create a text widget. Notice that the widgets are created before the window begins rendering. This is because when the window begins rendering, the only way to create new widgets is from inside of the application loop.
   wal->createText( "text1" );
That's the minimum required to create a text widget. Now let's go ahead and start the application loop and close up the main block:
   wal->startRendering();
}
We aren't done yet. If we were try and compile at this point, there would be linker errors because we haven't created the application loop functions which give us runtime control over the application.
void WAL::Listener::buttonPushed( int ButtonNumber )
{
}

void WAL::Listener::createCalled()
{
}

void WAL::Listener::closeCalled()
{
}

void WAL::Listener::destroyCalled()
{
}

void WAL::Listener::paintCalled()
{
}

void WAL::Listener::activateCalled()
{
}

void WAL::Listener::entersizemoveCalled()
{
}

void WAL::Listener::exitsizemoveCalled()
{
}

void WAL::Listener::moveCalled()
{
}

void WAL::Listener::sizeCalled()
{
}

void WAL::Listener::getminmaxinfoCalled()
{
}

void WAL::Listener::mousemoveCalled( int x, int y )
{
}

void WAL::Listener::lbuttondownCalled()
{
}

void WAL::Listener::iteration()
{
}
Don't worry about what those do for now. Their relevance will be revealed in a different tutorial. Go ahead and compile. If everything went okay, when you run the application, you will see a 640 x 480 pixel windows application with a text widget at location 50, 50 that says "default". If something went wrong, compare your code with the source file below. If something is still wrong, post on the forums (see the navigation bar for a link).
Source code