In this section you will learn how to write windows programs. Windows programming is not difficult. Windows programming can be done on Microsoft visual C++.
To do windows programming you should have a great knowledge of object oriented programming. Object oriented programming is major while using Microsoft visual C++. An AppWizard is an application that generates a basic window program automatically.
A windows programming has a different structure from a typical C++ program in DOS, and it is also more complicated than a DOS program. This is because in DOS programming we can enter data directly from the keyboard and can display it directly but in a windows program all inputs and outputs are accessed by way of windows functions.
There is no direct access to the hardware. Windows programming has a main advantage that it enables multitasking that is we can access one or more programs at a time and the windows itself determines which input is given to which program and signals the compiler accordingly. Windows also have a control on all communications with the user.
Another advantage of windows programming is that there is an interaction between the user and the windows application that a user can understand a range of different inputs given to different programs at the same time. A user can also use mouse to click anywhere and choose a wide number of menu options.
In short we can say that windows programming is user friendly. A well designed windows application is prepared to deal with any type of data.
The user actions done by a mouse are regarded as events which results a program to be executed. Therefore, we can say that how a program is going to be executed is decided by the actions performed by user in a sequence. The types of programs that are executed in this way are called as event-driven program.
It is quite clear that there is an interface between the user and the event driven programs. This interface is windows itself. When you do an action using keyboard or mouse, through windows application, it acts upon your program. The structure of a windows program is as follows:
In the above structure it is clear that the interface between the user and program is windows, the user performs actions that are called events, and windows process the events on program data and gives the desired words. The piece of code or is written to deal with a particular event.
For understanding windows programming, visual C++ is the best as it provides and has build in features that supports windows programming. Visual C++ includes two important tools that are; AppWizard and ClassWizard. These two provide a flexible programming; they reduce the incidence of errors, and also save time.
Besides other library files in C++ visual also provides other libraries, they are called Microsoft Foundation Classes and Templates library or (MFC & T).
This is made up of three parts of which MFC is a part. MFC is referred as an application framework as it provides a set of structured components. The Active Template Library (ATL) provides structures to write windows programs.
Open a new project in visual C++ using File menu as shown:
For creating a windows program AppWizard will be used. The method is as follows;
- Select New from File menu.
- Select projects tab in the pop menu.
- Select the project type as Windows Forms application.
Executing a windows program:
Before executing a program, we should compile and link the program modules. This is as same and simple as we did it in console application.
Compiling and linking will take some time, once a program has been built, the output window will indicate that there are no errors in program and the program will start executing. The window for this type of program is shown below:
The program solution can be built up by clicking on the debug option in the menu bar, a popup menu will appear you can select the option and program will be executed.