Version 2.9 and higher of the library will not support Visual C++ version 6.0 anymore. The library compiles cleanly under Visual Studio .NET 2003 with warning level 4. It should at least compile under Visual Studio .NET 2002 although this has not been tested. The provided solution is a Visual Studio .NET 2003 solution.
After having programmed mostly in C for about 10 years, I decided about a year ago that it was time to start learning C++. Because I was also trying to get to grips with the Win32 API, I decided to combine the two and create my very own class library. The result is what you see here. A library of C++ classes which mostly contain wrappers for Win32 data types etc.
I have always found that you learn the most from looking at other peoples' code. Do not be surprised if you find techniques and code in the library which are used in others code. Do not even be surprised when you see code which I have blatantly copied from the various sources I found on the net. I have tried to keep track of the source code and the people who originally wrote it. You will find a list further down.
The class library consists of:
- Wrapper classes for windows and dialogs.
- MDI support.
- Bitmapped menus.
- Wrappers for standard and common controls.
- New control classes like
Splitter and many more.
- XP style rendering support for the custom controls and an easy way to add XP style rendering to your own controls.
- A complete layout-engine which enables you to create resizable GUIs with a little extra effort.
- Collector classes for arrays, linked-lists and hash tables.
- Wrappers for the Win32 GDI system including some utility classes.
- A string class.
- Some utility classes like
I have never been one for writing documentation (my employer can vouch for that ) so there is no documentation for this library. However, the source code has been commented quite extensively so it should not be a problem to get going with it. Also because most classes are simple wrappers, MFC/Win32 programmers should be able to get familiar with it fast.
Next to the commented source code there are also several sample programs which should be a good starting point.
Before you can get started, you must extract the files you get with the distribution somewhere onto your hard disk. Once you have done that, you should make the following settings in Visual Studio:
- Under the menu Tools->Options...
- Select VC++ Directories under the Projects item in the tree view.
- Select Include files in the Show directories for combo box.
- Add the directory in which the files where extracted to the Include files search path. I.e., if you extracted the library source files at D:\ClassLib, you add this path to the include files.
- Select Library files in the Show directories for combo box.
- Add the Classes\LIB directory to the Library files search path. I.e, if you extracted the library source files at D:\ClassLib, you add D:\ClassLib\LIB here.
This should get you started. To keep the size of the distribution down, the link-libraries are not included. Instead, a Visual Studio .NET 2003 solution is included which will enable you to create these libraries yourself. Double-click on the ClassLib.sln file in the distribution directory and Visual Studio will open. In it, you can select to build the "Win32 Release", "Win32 Debug", "Win32 Release Multithread" and "Win32 Debug Multithread" versions of the linker library. For each of the mentioned libraries, you can also compile a Unicode version.
The Samples archive includes a solution and sources which will enable you to compile the sample programs for this library.
The debug versions of the library will track a couple of things for you. First of all, memory leaks up to a degree. If for some reason you forget to free memory allocated using the
new operator or using
calloc(), the code will assert upon exit showing a message that memory has not been freed. In addition to that, when you run the code under debugger control, the lines at which the unfreed memory was allocated are displayed. The standard Microsoft debug support in the C runtime library is used for this. Memory leaks caused by not freeing memory allocated not using the
new operator or the C runtime library are not reported.
The debug libraries will also track created windows, GDI, device contexts, and menu objects. These are tracked internally in a list and when this list is not empty when the code exists, the program will assert telling you which list(s) were not empty.
The debug libraries will also track the GDI and device context handles which are created. If they are not destroyed properly before the code exits the program asserts upon exit.
Except for making sure your code cleans up after itself, there is nothing which needs to be done for the code to exit without asserting.
Another thing I would like to mention is that the
new operator will throw an exception (see memoryexception.h) when it fails to allocate the requested memory.
As I mentioned above, some of the code in this library is based on the work of other people. Here is a list of the people whose code I have used as an example and sometimes as-is. Thanks to you all.
- Chris Maunder
ClsColorPopup (sorry for the American spelling ) class which I have adapted to run with this class library. The class has undergone several code changes which include blend or roll animation when the window opens and XP style rendering when the app is themed and running under XP. The
ClsComboCompletion class is also a class he wrote which I adapted for this library.
- Joshua Heyer:
ClsBalloonHelp class. I have adapted this class for this library. I have made several changes to the original code which include another way of blending using the
AnimateWindow() API instead of
SetLayeredWindowAttributes() and timers. I have also bypassed the need to use a timer for the hot-tracking of the close button. Last but not least, it supports text styles in the body text and it uses an XP style close button when running themed under XP.
- The Microsoft knowledge base article Q29240.
I have used the code from this article to create the
ClsRGBHLS class. This class can be used to convert RGB colors to HLS values and vice versa.
ClsString class uses a method of buffer-sharing which I found in a string class from a class library written for Windows CE. I am sorry to say that I do not remember who wrote the thing but if you know who, let me know so I can give credit where credit is due.
- Todd Osborne
I have used his VXCL library for two things. First, the Windows procedure used by the
ClsWindow class is largely based on his work. Secondly, the common dialog wrappers are partly based on his work.
- Joseph M. Newcomer
I have used his "Using Worker Threads" article to base the
ClsWorkerThread class on.
- Paolo Messina and Jerzy Kaczorowski
ClsHotButton code contains their
COddButton code which takes care of the problems you usually get when trying to combine ownerdraw buttons and a default state.
- Bruno Podetti
I have used his hooking / subclassing technique to enable custom frames on
ClsMenu derived menu classes.
- Christian Graus
GetGrayscaledBitmap() method in
ClsBitmap is based on the hit "Per-Pixel" filters article.
- Carlos Antollini
The ADO and ADOX classes are originally written by him.
- Daniel Bowen
The library contains a port of his
CustomTabCtrl code. Not all classes have been ported but the most important ones are. The library has a port of his
FolderTabCtrl. Of course the base
CustomTabCtrl has been ported as well.
I hope I did not forget anybody here. If I did it was by mistake, not by choice.
Changes (2.9 -> 3.0)
- Added solutions for compiling Unicode versions of the library. Note however that the Unicode support is untested.
- Made several small adjustments and additions to several classes.
- Added a port of Daniel Bowen's excellent
- Due to the port, I have also added a few macros which make message cracking a little bit easier. Though the macros are not compatible with the ATL/WTL message cracking macros, they do resemble them.
- Various tweaks and additions.
- Fixed numerous bugs.
Changes (2.7 -> 2.9)
A lot of fixes, tweaks and additions have been implemented in this release. Major changes for this release are:
- Ported the ADO and ADOX classes by Carlos Antollini.
- Added support for custom window frame rendering including standard and user defined buttons in the window frame.
- Added a RichEdit wrapper.
- Added classes for hot-trackable normal and XP style editboxes and comboboxes.
For a complete list of changes, take a look at the History.txt file in the source code Zip file.