Getting Started
This chapter is idented to get you start programming with the WVL. But before you go through the tutorial you first have to get the WVL installed on your system.
A very simple WVL application.
This will explain the very basic stuff about creating a "Hello world"
application with the WVL.
Every WVL application has to include the head file "wvl.h"
#include<wvl/wvl.h>
Every Windows application has an entry function called
WinMain()
int WINAPI
WinMain(HINSTANCE hinstance, HINSTANCE, char*, int)
{
return 0;
}
Then, define a Window to be used as a
startup window.
class my_first_form:
public wvl::form
{
public:
my_first_form()
{
this->text("Hello world");
this->show();
}
};
now, I got the class my_first_form, and I will
start an instance of it as a startup window
wvl::executer<my_first_form>
runner;
runner.run();
OK, Let's take a look at the whole program
#include<wvl/wvl.h>
class my_first_form: public
wvl::form
{
public:
my_first_form()
{
this->text("Hello
world");
this->show();
}
};
int WINAPI WinMain(HINSTANCE
hinstance, HINSTANCE, char*, int)
{
wvl::executer<my_first_form> runner;
runner.run();
return 0;
}
Now, I want to add a button to the form
my_first_form, and click it to exit the application, so I insert a
private member into the class
wvl::button btn_exit_;
And create the button when the form is creating
btn_exit_.create(*this, "Exit",
wvl::point(100, 50), wvl::size(100, 20));
but until now, the button btn_exit_ is useless, I
have to install a click event for it. Before installing the event, I must write
a function in responding to the click event.
void on_click_btn_exit()
{
this->close();
}
OK, I get an answering function now, so I can
install the click event for the button.
btn_exit_.make_event<wvl::event::mouse_click>(wvl::bind_mem_fun(this,
&my_first_form::on_click_btn_exit));
the application is finished now. Let's take a look at the whole program.
#include<wvl/wvl.h>
class my_first_form: public
wvl::form
{
public:
my_first_form()
{
btn_exit_.create(*this,
"Exit", wvl::point(100,
50), wvl::size(100,
20));
btn_exit_.make_event<wvl::event::mouse_click>(wvl::bind_mem_fun(this,
&my_first_form::on_click_btn_exit));
this->text("Hello
world");
this->show();
}
private:
void on_click_btn_exit()
{
this->close();
}
private:
wvl::button btn_exit_;
};
int WINAPI WinMain(HINSTANCE
hinstance, HINSTANCE, char*, int)
{
wvl::executer<my_first_form> runner;
runner.run();
return 0;
}
There is an important concept have to be understood.
It is startup window
the so-called startup window actually is the first started window. Let's see
the following codes
wvl::executer<my_first_form>
runner;
runner.run();
the runner will construct an object of the class my_first_form,
the WVL will hold a map between the window and the instance of
my_first_form, the window is the first window started and the WVL will manage
the window as a startup window. If the
startup window is closed, the WVL will close all the another windows
and stop current instance.