PC Interfacing - Application Borland C++ Builder
Creating project for welcome application
Now we will try to create a program that displays Welcome message on the screen.
Right now you should have C++Builder running and you should be looking at a blank form.
By default, the form is named Form1. To the left of the form, the Object Inspector shows the properties for the form. Click on the title bar of the Object Inspector. The Caption property is highlighted. Type WELCOME ! to change the form’s caption.
Now click the Run button on the speedbar. (You could also press F9 or choose Run | Run from the main menu.) C++Builder begins to build the program. After a brief wait, the compiler status box disappears, the form is displayed, and the caption shows WELCOME!. In this case, the running program looks almost identical to the blank form. You may have noticed when the program was displayed because it is displayed in the exact location of the form in the Form Editor. You’ve just written your first C++ Windows program with C++Builder. It can be moved by dragging the title bar, it can be sized, it can be minimized, it can be maximized, and it can be closed by clicking the Close button.
If you still have the Hello World program running, close it by clicking the Close button in the upper-right corner of the window. The Form Editor is displayed again, and you are ready to modify the form (and, as a result, the program). To make the program more viable, we’re going to add text to the center of the window itself. To do this, we’ll add a text label to the form. First, click on the Standard tab of the Component Palette. The third component button on the palette has an A on it. Click the label button and then click anywhere on the form. A label component is placed on the form.
Click on the title bar of the Object Inspector or on the Caption property and type WELCOME !. Now the label on the form shows Hello World!. As long as we’re at it, let’s change the size of the label’s text as well. Double-click on the Font property. The property will expand to show the additional font attributes below it. Locate the Size property under Font and change the font size to 24 . As soon as you press the Enter key or click on the form, the label instantly changes to the new size. To move a component, simply click on it and drag it to the position you want it to occupy. Once you have the label where you want it, you’re ready to recompile and run the program. Click the Run button again. C++Builder compiles the program again and, after a moment , the program runs. Now you see WELCOME! displayed in the center of the form .
Title Bar
The main section of the title bar displays the C++ Builder 5 name of the application, and the name of the program that is running. A C++ Builder program is called a project. When Bcb starts, it creates a starting project immediately, and it names the starting project, Project1. If or when you add other projects, they take subsequent names such as Project2, Project3, etc. This main section of the title bar is also used to move, minimize, maximize the top section of the IDE, or to close Bcb. On the right section of the title bar, there are four system buttons with the following roles a) Minimize window b) Maximize window c) Restores window d) Close window
Menu Bar
Under the title bar, there is a range of words located on a gray bar; this is called the menu. To use a menu, you click one of the words and the menu expands. Click File. There are four main types of menus you will encounter. When clicked, the behavior of a menu that stands alone depends on the actions prior to clicking it. Under the File menu, examples include Save, Close All or Exit. For example, if you click Close All, Bcb will find whether the project had been saved already. If it were, the project would be closed; otherwise, you would be asked whether you want to save it.
A menu that is disabled is not accessible at the moment. This kind of menu depends on another action or the availability of something else. A menu with three dots means an action is required in order to apply its setting(s). Usually, this menu would call a dialog box where the user would have to make a decision. A menu with an arrow holds submenu. To use such a menu, position the mouse on it to display its submenu.
Notice that on the main menu (and any menu), there is one letter underlined on each word. Examples are F in File, E in Edit, etc. The underlined letter is called an access key. It allows you to access the same menu item using the keyboard. In order to use an access key, the menu should have focus first. The menu is given focus by pressing either the Alt or the F10 keys. To see an example, press Alt.
Notice that one of the items on the menu, namely File, has its border raised. This means the menu has focus.
Press p and notice that the Project menu is expanded.
When the menu has focus and you want to dismiss it, press Esc.
Notice that the Project menu has collapsed but the menu still has focus. Press f then press o. Notice that the Open dialog displays.
On most or all dialog boxes that have either an OK, Open, or Save buttons, when you press Enter, the OK, Open, or Save button is activated. On the other hand, most of those dialog boxes also have a Cancel button. You can dismiss those dialogs by clicking Cancel or pressing Esc.
On some menu items, there is a combination of keys we call a shortcut. This key or this combination allows you to perform the same action on that menu using the keyboard. If the shortcut is made of one key only, you can just press it. If the shortcut is made of two keys, press and hold the first one, while you are holding the first, press the second key once and release the first key. Some shortcuts are a combination of three keys. To apply an example, press and hold Ctrl, then press S, and release Ctrl. Notice that the Save As dialog box opens. To dismiss it, press Esc.
Toolbar
A toolbar is an object made of buttons. These buttons provide the same features you would get from the menu, only faster. Under the menu, the IDE is equipped with a lot of toolbars. For example, to create a new project, you could click File _ New… on the main menu, but a toolbar equipped with the New button allows you to proceed a little faster.
By default, Bcb displays or starts with 6 toolbars. Every toolbar has a name. One way you can find out the name of a toolbar is to click and hold the mouse on its gripper bar and drag it away from its position
Saving and closing solution
A program in Borland C++ Builder is called a project. As an application, it is saved in a few steps. To save a project, on the Standard toolbar, click the Save All button.
No comments:
Post a Comment