Products >lcc-win32 > Tutorial > First Windows Program

Your first windows program

After you have successfully compiled and run your first console application, it's time to move to another level - GUI programming.

Back in history, computers were equipped with simple text-based input and output, which is sufficiently covered by standard C input/output library stdio.h (we used printf() function from the library in our Hello World application).

Today, majority of computer users use GUI (Graphical User Interface) to control applications they're working with. Through the use of windows, that contain controls like text boxes, buttons, drop-down lists etc., the user interaction is more intuitive and easy.

But it by far doesn't mean that every computer application must use GUI these days. Actually, we often see a bad habit of putting GUI to applications that would be better controlled from command-line. (Remote server management tools are such example). Moreover, it's often wise to split application into two parts - the executive command line part, and the user interface part.

We'll stick to our Hello World program, but this time, we'll use Windows GUI as a user interface. Our application will consist of a single dialog box with a message and closing button.

Do Click on Project menu, then Create ... option.

You'll be asked for the name of project.

Enter hello-win

As in the previous part of tutorial Wedit now needs to know, where your source code files will reside (Working directory) and where the object files and executable should be placed (Output directory).

Do

Do Use Browse buttono pick a directory of your choice. Pick different directory than the one you used for 'hello' application

Please note that Type of project is Windows executable now!

Do Click on Create

WEdit can create a basic application skeleton for you, so that you don't have to write it manually every time you start a new project. In our simple console application WEdit will create source file hello-win.c and put some useful code in it.

Do

Do Click on Yes

Next dialog allows to modify other projects properties. Because we want our application to just display an information window, we'll select dialog application

Do Select Dialog based radio button in Type of application group, then click OK

As the last part of the new project definition, you see Compiler/Linker/Debugger settings dialogs. You do not have to change anything for your 'Hello World' project.

Click on Next buttons and on the Finish button on the last page.

Now you see contents of file hello-win.c, which was generated by the application skeleton feature of Wedit.

Unlike the console Hello World application, where all information describing behavior and look of the program was contained in hello.c file, description of graphic elements of user interface is conveniently stored in different file, called the resource file.

If you take a look at the Application characteristics dialog box above, you see two files dealing with resources - resource file hello-win.rc, and resource header file hello-winres.h.

Now we open the resource file in Resource editor and edit it appropriately.

Do Select Resources/Open from menu.

Do Select hello-winres.h file and click Open

You can see window with the basic dialog skeleton ...

... and the Controls palette.

You can use the palette to drop controls to your dialog. Double-clicking any item pops up the properties dialog. Feel free to play with resource editor until your dialog skeleton looks somewhat like this:

Do Click on the close button of resource editor and click Yes in the Save dialog

Now you're almost finished. Just make the application from compile menu and execute it. Congratulations!