Teach Yourself Borland C++ in 14 Days

Teach Yourself Borland C++ in 14 Days

At A Glance 1 WEEK 1 2 1 3 4 At a Glance 5 In Week 1 you will get a start on learning how to write Windows programs in C++. The C++ language is not an easy language to learn. It is, however, the standard programming language in many corporations and governments around the world. Learning C++ might not be the easiest task you could attempt to tackle, but it should be very rewarding, both intellectually, and, eventually, monetarily. 6 Your first four days will be spent learning about the basics of the C++ language. As you work through the first four chapters, you will write simple test programs, each of which will help you solidify a particular feature of the C++ language. I warn you, though, that these programs will probably not be the type of program that you purchased C++Builder to write. The test programs for the first four days will be console 7 applications. These programs work just like DOS programs. They won’t Untitled-16 1 1/19/99, 1:01 PM P2/V5/Swg2 TY C++ Builder in 14 Days 31051-1 Lenser 1.14.97 At a GlanceWK1 LP#3 2 Week 1 have any flash or glitter. You probably won’t be terribly impressed. These programs will, however, help to teach you the basics of C++, and that is what the first four days of this book are about. Starting on Day 5 you’ll begin to learn about some of the things that make the visual programming aspect of C++Builder the great tool that it is. We will talk about frameworks and what a framework means to you as a Windows programmer. On Day 5 you will build a simple test program using C++Builder’s visual programming tools. After that we will spend a couple days going over the C++Builder IDE so that you can become familiar with how the entire C++Builder IDE works together to make your programming tasks easier. This is where things start to get more interesting. You will get an opportunity to write some working Windows programs in the last part of this first week. So, with that in mind, let’s get to it. Untitled-16 2 1/19/99, 1:01 PM P2/V5/Swg2 TY C++ Builder in 14 Days 31051-1 Lenser 1.14.97 At a GlanceWK1 LP#3 Getting Your Feet Wet 3 Week 1 1 Day 1 Getting Your Feet Wet by Kent Reisdorph Congratulations—you’ve chosen one of today’s hottest new programming tools! Before you can jump into using all of what C++Builder has to offer, though, you’ll need to learn a little about C++ first. In this chapter you will find ■ A quick tour of C++Builder ■ Information about how to write a Win32 console-mode application ■ An introduction to the C++ language ■ Facts about C++ variables and data types ■ Information about functions in C++ (including the main() function) ■ A discussion of arrays Untitled-10 3 1/19/99, 12:48 PM P2/V5/swg2 TY C++ Builder in 14 Days 31051-1Lenser 1.15.97 CH01 LP#4 4 Day 1 What Is C++Builder? By now you know that C++Builder is Borland’s hot new rapid application development (RAD) product for writing C++ applications. With C++Builder you can write C++ Windows programs more quickly and more easily than was ever possible before. You can create Win32 console applications or Win32 GUI (graphical user interface) programs. When creating Win32 GUI applications with C++Builder, you have all the power of C++ wrapped up in a RAD environment. What this means is that you can create the user interface to a program (the user interface means the menus, dialog boxes, main window, and so on) using drag-and- drop techniques for true rapid application development. You can also drop OCX controls on forms to create specialized programs such as Web browsers in a matter of minutes. C++Builder gives you all of this, but you don’t sacrifice program execution speed because you still have the power that the C++ language offers you. I can hear you saying, “This is going to be so cool!” And guess what? You’re right! But before you go slobbering all over yourself with anticipation, I also need to point out that the C++ language is not an easy one to master. I don’t want you to think that you can buy a program like C++Builder and be a master Windows programmer overnight. It takes a great deal of work to be a good Windows programmer. C++Builder does a great job of hiding some of the low-level details that make up the guts of a Windows program, but it cannot write programs for you. In the end, you must still be a programmer, and that means you have to learn programming. That can be a long, uphill journey some days. The good news is that C++Builder can make your trek fairly painless and even fun. Yes, you can work and have fun doing it! So roll up your sleeves and get your hiking shoes on. C++Builder is cool, so have fun. A Quick Look at the C++Builder IDE This section contains a quick look at the C++Builder IDE. We’ll give the IDE a once-over here, and we’ll examine it in more detail on Day 6, “The C++Builder IDE Explored: Projects and Forms.” Because you are tackling Windows programming, I’ll assume you are advanced enough to have figured out how to start C++Builder. When you first start the program, you are presented with both a blank form and the IDE, as shown in Figure 1.1. The C++Builder IDE (which stands for integrated development environment) is divided into three parts. The top window might be considered the main window. It contains the speedbar on the left and the Component Palette on the right. The speedbar gives you one-click access to tasks like opening, saving, and compiling projects. The Component Palette contains a wide array of components that you can drop onto your forms. (Components are things like text labels, edit controls, list boxes, buttons, and the like.) For convenience, the components Untitled-10 4 1/19/99, 12:48 PM P2/V5/swg2 TY C++ Builder in 14 Days 31051-1 Lenser 1.15.97 CH01 LP#4 Getting Your Feet Wet 5 are divided into groups. Did you notice the tabs along the top of the Component Palette? Go ahead and click on the tabs to explore the different components available to you. To place a component on your form, you simply click the component’s button in the Component Palette and then click on your form where you want the component to appear. Don’t worry 1 about the fact that you don’t yet know how to use components. We’ll get to that in due time. When you are done exploring, click on the tab labeled Standard, because you’ll need it in a moment. Figure 1.1. The C++Builder IDE and the initial blank form. A component is a self-contained piece of binary software that performs some specific NEW TERM predefined task, such as a text label, an edit control, or a list box. Below the speedbar and Component Palette and glued to the left side of the screen is the Object Inspector. It is through the Object Inspector that you modify a component’s properties and events. You will use the Object Inspector constantly as you work with C++Builder. The Object Inspector has one or two tabs, depending on the component currently selected. It always has a Properties tab. A component’s properties control how the component operates. For example, changing the Color property of a component will change the background color of that component. The list of available properties varies from component to component, although components usually have several common elements (Width and Height properties, for instance). Untitled-10 5 1/19/99, 12:48 PM P2/V5/swg2 TY C++ Builder in 14 Days 31051-1Lenser 1.15.97 CH01 LP#4 6 Day 1 NEW TERM A property determines the operation of a component. Usually the Object Inspector has an Events tab in addition to the Properties tab. Events occur as the user interacts with a component. For example, when a component is clicked, an event fires and tells Windows that the component was clicked. You can write code that responds to those events, performing specific actions when an event occurs. As with properties, the events that you can respond to vary from component to component. An event is a method that is invoked in a component as a result of that component’s NEW TERM interaction with the user. To the right of the Object Inspector is the C++Builder workspace. The workspace initially displays the Form Editor. It should come as no surprise that the Form Editor allows you to create forms. In C++Builder a form represents a window in your program. The form might be the program’s main window, a dialog box, or any other type of window. You use the Form Editor to place, move, and size components as part of the form creation process. Hiding behind the Form Editor is the Code Editor. The Code Editor is where you type code when writing your programs. The Object Inspector, Form Editor, Code Editor, and Component Palette work interactively as you build applications.

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    536 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us