Click here to Skip to main content
13,250,043 members (66,500 online)
Click here to Skip to main content
Add your own
alternative version


29 bookmarked
Posted 11 Oct 2004

A Library for Quick and Easy Development of Win32 Applications

, 5 Nov 2004
Rate this:
Please Sign up or sign in to vote.
win32easy is a static library that makes win32 programing as easy as old good C-like programming with a "main" routine.


Windows programming can be a very tedious task even for experienced programmers. Numerous API functions and windows messages, Component Object Model and other things on one hand make applications very powerful, on the other hand it can be very discouraging since even for a simple application one has to invest a lot of time and effort to build it. The latter is especially true for people in computer related sciences like bioinformatics when the scientist is primary concentrated on its scientific stuff and doesn’t really want to understand all bells and whistles of win32 API. As the result, in the scientific world we have a lot of software with extremely poor and unobvious interface.

Very often what we need from the Windows application is a decent looking input and handy output. It is very annoying to convert data for example from Excel into a text file, process them through an application and then reformat back to Excel. Unfortunately this is the case for most of the programs in the scientific world.

Win32Easy is a static library that facilitates and speeds up the process of development of Win32 applications. Win32Easy provides several classes that handle windowing and interaction with other applications (like IE and Excel) via COM. These classes hide complexity from the programmer, but the code of the library is very much transparent and easy to understand unlike Microsoft Foundation Classes (MFC). In addition, the library does not overwhelm with the number of classes, instead it provides the most important ones. The library is not intended to avoid completely win32 native code; instead it helps to use it in a seamless manner.

Using Win32Easy

A typical application code looks like this:

int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
             LPSTR lpCmdLine, int nCmdShow)
    /*no panic, just initializing OLE - we are communicating with Office */
    HRESULT hr;
    if(FAILED(hr = OleInitialize(0)) )
       throw ole_exception(hr); 

    HtmlWin htmlWindow(hInstance);
    htmlWindow.OpenURL(L"<A href="" target=_blank></A>");

    //do some work
   TextOutWindow tow(hInstance);
   tow.PrintText(TEXT("Some text"));

   Chart ch(hInstance);
   double dx[] = {10,20,30,40,50,60,70};
   double dy[] = {100,400,900,1600,2500,3600,4900};
   ch.Setx(0, dx, 7);
   ch.Sety(0, dy, 7);

   return 0;

That is it. You will not find in the main routine anything like a message loop or a hassle with hundreds of parameters for window creation. This hassle indeed exists in the implementation of the HtmlWin or TextOutWindow classes, but this does not disturb the clarity of the code and its primary focus – the calculations that the program has to perform. It looks like an old good C++ program with a main routine. In fact, old command-line code with the main routine can be easily ported to a GUI application.

How does it work?

The mechanism how this works is straightforward: the objects representing windows create their own thread and do all GUI job there. The program flow is concentrated in the main thread in the WinMain procedure, while message handling and other windows related operations are hidden in the implementation of the objects. Naturally, win32easy library assists development of the master-like applications, which guide the user through the entire calculation process, rather than just waiting for the user actions. Such a behavior is often very welcome especially when the developer wants to save potential users of his application from reading voluminous manuals.

Example of Some Classes

The purpose of this section is to provide examples of some useful classes and show some of their member functions in order to demonstrate how it is easy to perform tasks with the library being described that are quite complicated to accomplish otherwise using just native win32 code.


Should you read or save results of your computation in an Excel file, this class is very convenient. It provides functionality for creating new, opening and saving existing files. Doing this through straightforward OLE one has to create numerous interfaces for many intermediate objects making code very difficult to manage. Just some member functions:

int OpenFile(LPOLESTR fname);
int SaveAs(LPOLESTR Fname);
int SetCellsArray(LPOLESTR lpSheet, LPRECT lpr, int *pdx);
int GetCellsArray(LPOLESTR lpSheet, LPRECT lpr, double *parr) const;
int CellValue(LPOLESTR lpSheet, int iRow, int iColumn, double *d);


Many times it is necessary to inform the user about the process that is going on at the moment or provide some textual information. Using just TextOut(HDC...) function is not a very convenient way since one has to take care of text lines on the screen, scrolling, possible conversion of numbers to text. It would be great to have something like old printf(...) function that takes care about all of this but in a window and it would be also great to be able to copy that text to clipboard. TerminalWindow does all of it:

bool PrintText(int iResID, va_list args) const;
bool PrintText(LPCTSTR format, va_list args) const;
bool PrintText(int iResID) const; 
bool PrintText(LPCTSTR lszText) const;

Library Homepage

Detailed information about the library and description of each object and its member functions is available here. Also, you'll find a molecular dynamic application which is powered by win32easy that uses all modern technologies like GUI, COM and DirectX.

Enjoy easy win32 development.


This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


About the Author

Dr. APo
Team Leader University of Washington
United States United States
I was born in Moscow, USSR. In 1998, I earned Master’s degree in Chemistry from the Moscow State University. In 2000, I moved to Germany to pursue a PhD degree in Genetics. Currently I live with my family in the United States.
I have been always involved is a multidisciplinary research side-by-side with biologists. The research involves physical chemistry, bioinformatics and electrical engineering.

You may also be interested in...


Comments and Discussions

GeneralCatching results of operations Pin
Karl N M6-May-05 16:38
memberKarl N M6-May-05 16:38 
GeneralRe: Catching results of operations Pin
pozhit7-May-05 6:19
memberpozhit7-May-05 6:19 
GeneralHire me! Pin
John R. Shaw14-Nov-04 12:23
memberJohn R. Shaw14-Nov-04 12:23 
GeneralRe: Hire me! Pin
pozhit14-Nov-04 15:42
memberpozhit14-Nov-04 15:42 
GeneralNeeds a tad bit of work... Pin
Anonymous13-Oct-04 11:19
sussAnonymous13-Oct-04 11:19 
GeneralRe: Needs a tad bit of work... Pin
pozhit13-Oct-04 11:37
memberpozhit13-Oct-04 11:37 
QuestionWhy not just make a console app? Pin
Don Clugston11-Oct-04 19:02
memberDon Clugston11-Oct-04 19:02 
AnswerRe: Why not just make a console app? Pin
pozhit12-Oct-04 5:12
memberpozhit12-Oct-04 5:12 
Dear Don,
Thank you for the comment, in fact people make this console applications, especially in science. But the application then looks ugly - a black "ms-dos" window doesn't look very professional Wink | ;) . It will be even more funny to have an "ms-dos" window and other windows created on top of it. It reminds me many Java applications that look like this.
OleInitialize() was necessary since we were going to use a Microsoft Office Chart object (OLE object) in the demo project. The demo project can be used as a template for other applications, people can leave this API call there, It won't harm even if they don't use OLE.
Concerning Chart object, please take a look at the demo code, it is easy to follow. Chart is public from Window, whose constructor requires HINSTANCE.

GeneralRe: Why not just make a console app? Pin
Jim Crafton12-Oct-04 5:41
memberJim Crafton12-Oct-04 5:41 
GeneralRe: Why not just make a console app? Pin
Jim Crafton12-Oct-04 5:52
memberJim Crafton12-Oct-04 5:52 
GeneralRe: Why not just make a console app? Pin
pozhit12-Oct-04 8:41
memberpozhit12-Oct-04 8:41 
GeneralRe: Why not just make a console app? Pin
Jim Crafton12-Oct-04 12:05
memberJim Crafton12-Oct-04 12:05 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.171114.1 | Last Updated 5 Nov 2004
Article Copyright 2004 by Dr. APo
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid