Getting Started
From Win32++
|
Getting Started |
Before we begin
In order to use Win32++ you will need a C++ compiler. If you don't already have one, there are several free C++ compilers available for download from the internet. Some of the more popular choices are:
Different compilers have their various strengths and weaknesses. My personal favourite is Microsoft's Visual C++ 2008 Express. If you use Visual Studio 2010 Express, be sure to enable the "Expert Settings" to access features such as the Class View, and the ability to clean and rebuild a project.
You should also download and install a copy of the Windows Software Development Kit (SDK). The Windows SDK includes the documentation of the Windows API, which is the primary reference document for windows programming. This is a free download available from Microsoft. The Windows SDK can be downloaded at: http://msdn.microsoft.com/en-us/windows/bb980924.aspx
Finally if you are planning to develop dialog applications or work with resources, you will need a resource editor. The commercial compilers generally include a resource a resource editor, but the free ones don't. Fortunately there are some free resource editors available. One such resource editor is ResEdit, available for download at: http://www.resedit.net/
Installing Win32++
Win32++ is available for download as a zip archive from SourceForge at http://sourceforge.net/projects/win32-framework/. Extract the files into a directory of your choosing, perhaps a subdirectory of your documents folder. When extracting the files, be sure to retain Win32++'s directory structure.
The Win32++ zip archive contains the Win32++ library files in the "include" directory, as well as a number of program samples which demonstrate the various type of applications that Win32++ can be used to create. Each sample contains a "ProjectFiles" directory, which contains a collection of project files matching a range of commonly used compilers. To compile the sample code, run the project which matches your compiler.
Creating a new project
Perhaps the simplest way to create a new project is to take one of the samples, and copy it to a new directory within the same parent directory as the samples. Alternatively you could use one of the project files from the "Win32++\new projects" directory which are provided for this purpose.
If you are looking to create your own project from scratch, you will typically need to do the following:
- Start with a Win32 GUI application
- Add "..\..\include" to the C++ Additional Include Directories.
- Add "..\..\include" to the Resources Additional Include Directories.
- Add additional libraries to the Linker Additional Dependencies (usually comctl32.lib).
You can use the existing project files as a guide as to how this should be done.
A Simple Window Application
The following code is a complete program for creating and displaying a window using Win32++. This program creates a simple window, and ends the application when the window is closed.
///////////////////////////////////
// main.cpp
// Add the Win32++\include directory to project's additional include directories
#include "wincore.h"
class CView : public CWnd
{
public:
CView() {}
virtual ~CView() {}
virtual void OnDestroy() { PostQuitMessage(0); } // Ends the application
};
int APIENTRY WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
{
// Start Win32++
CWinApp MyApp;
// Create our view window
CView m_View;
m_View.Create();
// Run the application
return MyApp.Run();
}
In this code we inherit the CView class from CWnd to represent our view window. CView overrides the OnDestroy function which is called when the window is destroyed. There we call PostQuitMessage which ends the application.
The Tutorials
The tutorials contain a step by step guide to building a windows application using Win32++. The description of the each tutorial is contained within this help document, and the code is provided in the "tutorials" folder.