turrier.fr

Source : ct|23.04.08

< Tutorials Computer, Multimedia, Chinese

Creating little Windows program in c++

Introduction

Littles C++ programs, written in Windows version, require a number of code lines relatively important, compared with littles program written in console version.The following example make exception to this rule. To write then to compile him, i have used the free (GPL) integrated development environment Codeblocks.The integrated development environments Devcpp, or Visual Studio Express 2008 can also be free downloaded on internet and allow of course to obtain the same result.

Create the project

Run Codeblocks, then choose "File/New/Project". Choose a project type "Win32 GUI".

image1

Then choose the application type "Frame Based" (and not "Dialog Based").

image2

By default, Codeblocks generates, in the file "main.cpp", the souce code of a Windows application .

image3

Delete all this code and replace him by the following code.

#include <windows.h>
int APIENTRY WinMain(HINSTANCE h1, HINSTANCE h2, LPSTR l, int n)
{
MessageBox(NULL,"Bonjour!","Exemple",MB_OK);
return 0;
}

The Win32 program is now very reduced. Now it does not take more that 5 small lines of codes, of which only one is significant (Messagebox).

Run the programme

Compile and run the programme (Build/Build and Run). Choose the Release option (and not the Debug option), if you want a standalone program.

image4

The programme displays a simple message box. This is yet well a Windows program and not a console program.

image5


Valid XHTML 1.0 Transitional

© http://turrier.fr (2007)