C++ Builder Tutorials

Crash Course C++Builder - part 1

Without lots of "real" programming, you can develop very efficient and fast Windows applications with C++ Builder. It is a RAD tool, Rapid Application Development, that reduces the complicated task of programming Windows applications to the handling of "objects" in a visual environment.

Designing a nice Windows GUI interface becomes a breeze. You don't have to "program" any standard Windows elements, just a few mouse clicks and there's your fully functional listbox, file dialog box, or even a full fledged database grid.

Debugging is limited to the program lines that you entered yourself, because all the ready-made modules that you use are tested and ready-to-go.

Preparations

  1. If you haven't done so already, create a new folder \CppProjects on your harddisk.
  2. If you haven't done so already, create directory Foot2Meter "under" \CppProjects.
  3. Download foot2metercb.zip (source code for the first finished project) from the Downloads section and unzip it to this directory.

Foot-to-Meter convertor: compilation

Our very first project is a Foot-to-Meter Convertor. The ready-to-go version is called Foot2Meter. You compile and test it as follows:

  1. Start C++ Builder and open foot2meter.cbproj: menu File / Open Project...
  2. Run the project: menu Run / Run (or press function key F9).
  3. Your project is compiled: the result is foot2meter.exe. Immediately after that, the program foot2meter.exe is launched. All this happens blazingly fast.

    foot2meter
  4. Enter a valid number in the first EDIT-box, for example: 5. Also enter a valid number in the second EDIT-box, for example: 3. Click on the button with the caption "Convert". On the right, you should see the corresponding length in meter.
  5. Click on the radiobutton "Meter to foot / inch". Note that the label for inches becomes invisible.

    foot2meter
  6. Enter an invalid value in the EDIT-box (like 20,5,7 or ABC) and try a conversion. C++ Builder responds with an error message and pauzes the execution of the application: when trying to convert the text "20,5,7" or "ABC" to a number, the Debugger noted the error condition. The Debugger shows design errors as well as runtime errors!
  7. Click the Continue button in order to close the error-dialogbox. Execution of the program is resumed and you see a second error message. This is the warning we programmed ourselves. Only this message will be shown when there is an invalid input when you run the program from Windows Explorer or from My Computer. Also close this dialogbox by clicking its OK button.
  8. Stop the program via its menu and Exit, via its sytem menu, or via its Close-button (top right of the window).
  9. Stop C++ Builder. If you get the question "Save changes to...?", say no. Because maybe you changed something in the source code and for the moment we don't want to save these changes.

Foot2Meter as a standalone program

  1. Start Windows Explorer and look in the folder where our first project is located. You will see several files:

    • foot2meter.exe is the executable file
    • foot2meter.obj is an intermediate file that was generated from the source files
    • some other files for housekeeping. In the next tutorials we'll discuss all those files in detail.
  2. Doubleclick on foot2meter.exe: the program starts.
  3. Try again to convert an illegal value. Now, you will only see the programmed error message.
  4. Stop the program.