WTL is relatively unknown library for most of C++ developers. Even in its current state (with no official Microsoft support as far as I know) it could compete with MFC as tool for development GUI applications a especially small standalone applications. It is template library and if you design your application right, then it would depend on minimal or none other dll.
So I decided to write WTL application just for sake of experience to see how hard to do it. It turns out to easy enough for a programmer with experience in MFC and WinAPI. Most of the classes match names of MFC classes serving the same purpose. And I did not have to wonder if I got right version of MFC dlls on any other machine where I copied my application. I wanted to do something which would not be too boring, so it was a logical choice to write something funny and useless: a game. WTLSeaBattle is simple version of widely known game “Sea Battle”, it sole purpose is to give an example of dialog based WTL application.
This application was developed using VC++ 6.0 SP6 and WTL70, and tested under Windows XP.
WTLSeaBattle is dialog-based application written using WTL. Its main class is
CMainDlg (files maindlg.*) which deals with managing controls in dialog, “battle field” classes and communications between objects inside application. Classes
CMyShips (MyShips.cpp) and
CEnemyShips (EnemyShips.cpp) implement player’s and computer’s game fields respectively.
CEnemyShips derived from common base class
CDisplayAreaWnd which contains common functionality.
CMyShips allows user to place ships,
CEnemyShips places computer’s ships and handles calculation of next “shot” during game.