C++ Program, Example Of Programming

C++ GUI Hello World Program Example

Traditionally the first program in most computer languages including C++ is called Hello World program. This first program as a rule consists of the simplest possible code. Therefore this program has another use. It is a simplest template to create any other more sophisticated program.

When programming under Windows in C++ we have actually 2 such programs. They are called:

Windows console C++ Hello World program

Windows GUI C++ Hello World program

The first one is pretty simple. It is actual traditional Hello World program. We will not discuss it here. It is too simple and it is not related with Windows interface. It is DOS style program.

GUI (up) and Console (down) Hello World program examples output

GUI (up) and Console (down) Hello World program examples output

The main feature of Windows operating system, something new which made it different from other operating systems was using windows as an interface, a way to counteract with every windows program. And not just Norton Commander style pseudo-graphical ASCII windows but real graphical windows, that is pictures we can interract with. It was from the very beginning and now almost all other operating system, all Linux operating systems also use similar interface, consisting of small windows. Formally this now familiar for everyone method of interacting with computer is called GUI, Graphic User Interface.

How console programs output and input data without GUI windows? They use standard Console window which existed in DOS operating system before Windows operating system was invented. DOS operating system is still part, some say the basis of MS Windows system.

In regard to interface we can divide most programs (except dll etc.) into 3 categories:

Console programs

GUI programs

Windowless programs (viruses are typically windowless)

Another idea to clearify this is that program is one thing, interface is another. Program can exist without interface, interface cannot exist without program.

C++ GUI Hello World program example – loading

C++ GUI Hello World program example

Therefore the true Windows Hello World program is C++ Hello World program using Windows GUI.

Here is one more specific peculiarity of Windows programming. All GUI code can be done in several ways. Originally 2 ways existed: by using Win32 API (Application Programming Interface) or using Win32 API with MFC (Microsoft Foundation Classes). The second method can only be done using MS Visual Studio compiler (not quite free compiler). Here we will not use MFC. Free MS Visual Studio Express Edition comes without MFC. We are going to use only Win32 API. There is couple more ways which we’ll not discuss here also.

So here is the roadmap of how to start learning programming in C++ under Windows using GUI:

  1. Install C++ compiler; let it be Dev-C++. Install programming editor, let it be Notepad++. Install MSDN library.
  2. Copy C++ Hello World program source code to new project in Dev-C++ and compile it.
  3. Start understanding the code, changing it and recompiling it to see the changes.
  4. Add more code to Hello World program to create more complex programs and compile them.

MSDN library is a Microsoft library, containing all those programming functions we need to understand how it works and to program under Windows. It’s terribly big, like a DVD movie, but much more interesting.

This way we learn simultaneously 2 main subjects:

  1. C++ syntax and semantics
  2. Windows GUI (all kinds of windows, buttons, pop-up windows, menus etc)

Leave a Reply

Your email address will not be published. Required fields are marked *