Understanding Project Options

Project options are another of those things that are easy to ignore. For one thing, the defaults are usually good enough when you are just starting out. After all, who has time to worry about all those compiler linker options when you are just struggling to learn a new programming environment At some point, though, you will start to become more interested in what all those options do, and it's good to have some reference when the time comes. In this section we'll look at the Project Options...

The Project Manager Window

The Project Manager window shows you the current files in your project. To view the Project Manager, choose View Project Manager from the main menu. Figure 10.1 shows the Project Manager window for the Scratchpad program created on Day 6. The Project Manager window tells you at a glance the state of each file in the project. Files that are up-to-date are displayed in a regular font files that have been modified but have not yet been saved are shown in a bold font. This serves to remind you...

The Project Manager Speed Menu

The Project Manager has a speed menu to aid you in project management. Many of the items on the speed menu are also available via the speedbar. Figure 10.3 shows the Project Manager speed menu. Table 10.1 lists the speed menu items along with a description of what each item does. Table 10.1. The Project Manager speed menu items. Saves the project and all source files in the project. Saves the project to the Object Repository. Creates a blank source code unit and displays the new unit in the...

Stepping Through Your Code

Stepping through code is one of the most basic debugging operations, yet it still needs to be mentioned here. Sometimes we fail to see the forest for the trees. (Just like sometimes authors of programming books fail to include the obvious ) Reviewing the basics from time to time may reveal something you were not previously aware of. When you stop at a breakpoint, you can do many things to determine what is going on with your code. You can set up variables to watch in the Watch List, inspect...

Using Resource Files

Every Windows program uses resources. 1 Resources are the elements of a program that support the program but are not I executable code. A typical Windows program's resources include User-defined specialty resources (sound files and AVI files, for example) Resources are generally contained in a resource script file (a text file with an .rc extension), which is compiled by a resource compiler and then bound to the application's .exe file during the link phase. Resources are usually thought of as...

The Bit Btn Component

The BitBtn component is a perfect example of how a component can be extended to provide additional functionality. In this case the standard Button component is extended to allow a bitmap to be displayed on the face of the button. The BitBtn component has several properties over what the Button component provides. All these properties work together to manage the bitmap on the button and the layout between the bitmap and the button's text. They are explained in the following sections. The Glyph...

View Form

The View Form button displays the form associated with the currently selected unit. The form is displayed in the Form Designer. As with the View Unit button, the View Form button will be disabled if no form exists for the selected unit. The Project Manager provides shortcuts for viewing a unit's source file or form. To view a unit's source file, double-click on the unit's filename (in the File column). To view a form, double-click on the form name in the Form column. Double-clicking on units...

Function Overloading

C allows you to have functions that have the same name but take different parameters. Function overloading is when you have two or more functions with the same name but with different parameter lists. Functions that share a common name are called overloaded functions. On Day 11 showed you an example program which contained a function called multiply . Not surprisingly, this function multiplied two values together. The function took two integers, multiplied them, and returned the result. But...

Step Write Code for the File Open and File Save As Menu Items

Now let's write the code to implement the File Open and File Save As menu items. C Builder provides a slick way of writing menu handlers with a minimum amount of fuss. Keep in mind that we haven't created the MDI child form yet, but we know enough about it to write the code for the menu handlers. Here goes 1. On the main form, choose File Open from the menu. An event handler is created for that menu item, and the Code Editor is displayed. 2. Type code so that the event handler...

Dialog Boxes in CBuilder

In C Builder, a dialog box is simply another form. You create a dialog box just like you do a main window form or any other form. To prevent the dialog box from being sized, you can change the BorderStyle property to bsDialog or bsSingle. If you use bsDialog, your dialog box will have only the close box on the title bar, which is traditional for dialog boxes. Other than that, you don't have to do anything special to get a form to behave like a dialog box. All C Builder forms have tabbing...

Exercises

Add several components of your choosing to the form. Save the form to the Forms page of the Object Repository with the name BaseForm. 2. Start a new application. Choose File New to view the Object Repository. Switch to the Forms page. Click the Inherit radio button. Choose the BaseForm object you created in exercise 1 and add it to the application. Be sure you used the Inherit option. Save the project and close it. 3. Open the BaseForm object you created in exercise 1....

How CBuilder Manages Class Declarations

As you know, when you create a new form in the Form Designer, C Builder creates three files for you the form file, the source code unit, and the unit's header. When C Builder creates the class declaration in the header, it essentially creates two sections. The first section is the part of the class declaration that C Builder manages. The second section is the part that you manage. On Day 7 you created the Scratchpad program. If you did the exercises at the end of that chapter, you also created...

The for Loop

The for loop is probably the most commonly used type of loop. It takes three parameters the starting number, the test condition that determines when the loop stops, and the increment expression. I for initial cond_expr adjust 2 statements The for loop repeatedly executes the block of code indicated by statements as long as the conditional expression, cond_expr, is true nonzero . The state of the loop is initialized by the statement initial. After the execution of statements, the state is...

The List Box and Combo Box Components

The ListBox and ComboBox components are also widely used. The ListBox component represents a standard Windows list box, which simply presents a list of choices that the user can choose from. If the list box contains more items than can be shown at one time, scrollbars appear to allow access to the rest of the items in the list box. 1 Some list boxes are owner-drawn list boxes. In an owner-drawn list box, the jmUL programmer takes the responsibility for drawing the items in the list box. You can...

Common Events

As with properties and methods, there are some events that will be responded to most often. Components cover a wide variety of possible Windows controls, so each component will have individual needs. Events specific to forms are not covered here because I covered that information on Day 6. The most commonly used events are listed in Table 8.3. Table 8.3. Commonly handled component events. OnChange This event is triggered when a control changes in one way or another. Exact implementation depends...