neoWidgets
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Pages
Usage

Table of Contents

Hello World

Lets start with getting neoWidgets to run at all. The following code is the most barebones program which just starts a message loop and creates a window with some text in it. This should be a good example for how we do things here.

#include "neo\neo.h"
using namespace neo;
class HelloNeo : public Window
{
public:
HelloNeo()
{
// set a message handler
Bind(WM_DESTROY, &HelloNeo::OnDestroy, this);
// create the window
Create(WindowParam().Style(WS_OVERLAPPEDWINDOW)
.InnerSize(300, 300)
.Text(L"Hello World!"));
// create a control for this window
// NOTE: the control lives on even when this StaticCtrl instance goes out of scope
// because all controls are in lightweight mode
StaticCtrl(*this, _T("Hello World!"), Rect(5, 5, 200, 25)).Shrink();
// window was hidden until now
Show();
}
void OnDestroy(Message& m)
{
// quit the app
PostQuitMessage(0);
}
};
int WINAPI WinMain(HINSTANCE instance, HINSTANCE prevInstance, LPSTR cmdLine, int cmdShow)
{
InitCommonControls();
// create main window
HelloNeo main;
// run message loop
MSG msg;
while(GetMessage(&msg, 0, 0, 0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return msg.wParam;
}