How do I write basic OWL Application.
OWL includes many classes you can use to write your applications more quickly and
easily. Also in a full-size application you need to use many of OWL's classes, in a
basic OWL application you need only draw on OWL's TApplication and TFrameWindow classes.
The TApplication class encapsulates the data and functions that make up an application,
whereas the TFrameWindow class encapsulates the data and functions that mame up an
application's main window.
The first step: creatin your application class, which should be derived from OWL's
TApplication class:
// usually in *.h file
class TMyApplication: public TApplication{
public:
TMyApplication() : TApplication("My Application"){}
void InitMainWindow();
};
In the body of the InitMainWindow() construct your main window and call
SetMainWindow(). SetMainWindow() gives OWL a pointer to your main window object:
void TMyApplication:InitMainWindow()
{
TFrameWindow* frame = new TWnd(0,_T("Basic OWL Application"));
SetMainWindow(frame);
}
You main window class usually derived from OWL's TFrameWindow. If you want to use
controlbar, status bar you will derive your class from TDecoratedFrame. In this
class you must provide at leas a constructor. You'll also alwas wan;t to provide a
response table, which enables your window to respond to Windows messages, and you'll often
need to everride the virtual funvtions SetupWindow() and CleanupWindow():
// usually in *.h file
class TMyFrame: public TFrameWindow{
public:
TMyFrame(TWindow* parent, LPCTSTR title);
~TMyFrame();
protected:
void SetupWindow();
void CleanupWindow();
DECLARE_RESPONCE_TABLE(TMyFrame);
};
// usually in *.cpp
DEFINE_RESPONSE_TABLE1(TMyFram, TFrameWindow)
// responce table entries will be here
END_RESPONSE_TABLE;
SetupWindow() and CleanupWindow() are like constructor and destructor in
that they provide initialization and cleanup services fr the window class. You will
use them to do inialization and cleanup that requires valid Window handle.
// usually in *.cpp
void TMyFrame::SetupWindow()
{
// always call base class function
TFrameWindow::SetupWindow();
// INSERT your initialization code here, that requires valid window handle
}
void TMyFrame::CleanupWindow()
{
// INSERT your cleanup code here, that requires valid window handle
// always call base class function
TFrameWindow::CleanupWindow();
}
In your main window's constructor you can perform other types of initialization that
no requires window handle.
TMyFrame::TMyFrame(TWindow* parent, LPCTSTR title)
: // always call base class function
TFrameWindow(parent, title)
{
// assighn menu for application
AssighnMenu(MENU_1);
// other stuff here
}
//
TMyFrame::~TMyFrame()
{
// cleanup here
}
And finally, almost every OWL programm begins execution at the OwlMain() function,
which you must provide:
int OwlMain(int argc, _TCHAR* argv[])
{
return TMyApplication().Run();
}