Introduction to Programming Using Visual Basic 2005, An (6th Edition)
1.2. Using Windows
Programs such as Visual Basic, which are designed for Microsoft Windows, are easy to useonce you learn a little jargon and a few basic techniques. This section explains the jargon, giving you enough understanding of Windows to get you started in Visual Basic. Although Windows may seem intimidating if you've never used it before, you need to learn only a few basic techniques, which are covered in this section. Mouse Pointers
When you use Windows, think of yourself as the conductor and Windows as the orchestra. The conductor in an orchestra points to various members and does something with his or her baton; then the orchestra members respond in certain ways. For a Windows user, the baton is called the pointing device; most often it is a mouse. As you move the mouse across your desk, a pointer moves along the screen in sync with your movements. Two basic types of mouse pointers you will see in Windows are an arrow and an hourglass. The arrow is the ordinary mouse pointer you use to point at various Windows objects before activating them. You will usually be told to "Move the pointer to ...." This really means "Move the mouse around your desk until the mouse pointer is at ...." The hourglass mouse pointer pops up whenever Windows is saying "Wait a minute; I'm thinking." This pointer still moves around when you move the mouse, but you can't tell Windows to do anything until it finishes what it's doing and the mouse pointer no longer resembles an hourglass. (Sometimes you can press the Esc key to tell Windows to stop what it is doing.) Note: The mouse pointer can take on many other shapes, depending on which application you are using and what task you are performing. For instance, when entering text in a word processor or Visual Basic, the mouse pointer appears as a thin, large, uppercase I (referred to as an I-beam). Mouse Actions
After you move the (arrow) pointer to a place where you want something to happen, you need to do something with the mouse. There are five basic things you can do with a mousepoint, hover, click, double-click, and drag. Pointing means moving your mouse across your desk until the mouse pointer is over the desired object on the screen. Hovering means lingering the mouse at a particular place and waiting for a message or menu to appear. Clicking (sometimes people say single-clicking) means pressing and releasing the left mouse button once. Whenever a sentence begins "Click on ...," you need to
An example of a sentence using this jargon might be "Click on the button marked Yes." You also will see sentences that begin "Click inside the ...." This means to move the mouse pointer until it is inside the boundaries of the object, and then click. Double-clicking means clicking the left mouse button twice in quick succession (that is, pressing it, releasing it, pressing it, and releasing it again quickly so that Windows doesn't think you single-clicked twice). Whenever a sentence begins "Double-click on ...", you need to
For example, you might be instructed to "Double-click on the little box at the far left side of your screen." Note: An important Windows convention is that clicking selects an object so you can give Windows or the document further directions about it, but double-clicking tells Windows to perform a default operation. For example, double-clicking on a folder will open that folder. Dragging usually moves a Windows object. If you see a sentence that begins "Drag the ...", you need to
Sometimes this whole activity is called drag and drop. Windows Start Button
Clicking on the Start button at the bottom left corner of the screen displays a menu that you can use to run programs, shut down Windows, and carry out several other tasks. The Start menu also can be accessed by pressing a special key labeled with the Windows logo (located next to the Alt key) or by pressing Ctrl + Esc. (In the notation "key1 + key2", the plus sign (+) instructs you to hold down key1 and then press key2. There are many useful key combinations of this type.) Windows and Its Little Windows
Windows gets its name from the way it organizes your screen into rectangular regions. When you run a program, the program runs inside a bordered rectangular box. Unfortunately Windows jargon calls all of these windows, so there's only a lowercase "w" to distinguish them from the operating system called Windows. When Windows' attention is focused on a specific window, the Title bar at the top of the window is blue and the window is said to be active. (Inactive windows have a gray Title bar.) The active window is the only one that can be affected by your actions. An example of a sentence you might see is "Make the window active." This means that if the Title bar of the window is gray, click inside the window. At this point, the active window will be responsive to your actions. Using Notepad
We will explore the Windows application Notepad to illustrate the Windows environment. Notepad is used extensively in this text to create text files for programs. Most of the concepts learned here carry over to Visual Basic and other Windows applications. To invoke Notepad from Windows, click the Start button, click on Run, type "Notepad" into the box labeled "Name:", and click the OK button. The window in Figure 1.1 will appear. As its name suggests, Notepad is an elementary word processor. You can type text into the Notepad window, edit the text, print the text on the printer, and save the text for later recall. Figure 1.1. The Notepad window.
The blinking vertical line is called the cursor. Each letter you type will appear at the cursor. The Notepad window is divided into four parts. The part containing the cursor is called the Work area. It is the largest and most important part of the window because documents are typed into this window. The Title bar at the top of the screen holds the name of the document currently being written. Until the document is given a name, the document is called "Untitled." The three buttons on the right side of the title bar can be used to maximize, minimize, or close the window. You can click on the Maximize button to make the Notepad window fill the entire screen, click on the Minimize button to change the Notepad window into a button on the taskbar, or click on the Close button to exit Notepad. As long as a window isn't maximized or minimized, you can usually move it around the screen by dragging its title bar. (Recall that this means to move the mouse pointer until it is in the title bar, hold down the left mouse button, move the mouse until the window is where you want it to be, and then release the mouse button.) Note 1: After you have maximized a window, the Maximize button changes to a pair of rectangles called the Restore button. Click on this button to return the window to its previous size. Note 2: If the Notepad window has been minimized, it can be restored to its previous size by clicking on the button that was created on the task bar when the application was opened. (The three tasks discussed in this paragraph also can be carried out with the System Menu button in the upper-left corner of the window.) You can change the Notepad window to suit your needs. To adjust the size, do the following:
If the Work area contains more information than can fit on the screen, you need a way to move through this information so you can see it all. For example, you will certainly be writing instructions in Visual Basic that are longer than one screen. You can use the mouse to scroll through your instructions with small steps or giant steps. A Vertical scroll bar lets you move from the top to the bottom of the window; a Horizontal scroll bar lets you move between the left and right margins of the window. Use this Scroll bar when the contents of the window are too wide to fit on the screen. Figure 1.1 shows both Vertical and Horizontal scroll bars. A scroll bar has two arrows at the end of a channel and sometimes contains a box called the Scroll box. The Scroll box is the key to moving rapidly; the arrows are the key to moving in smaller increments. Dragging the Scroll box enables you to quickly move long distances to an approximate location in your document. For example, if you drag the Scroll box to the middle of the channel, you'll scroll to approximately the middle of your document. The Menu bar just below the Title bar is used to call up menus, or lists of tasks. Several of these tasks are described in this section. Documents are created from the keyboard in much the same way they would be written with a typewriter. In computerese, writing a document is referred to as editing the document; therefore, Notepad is called a text editor. After Notepad has been invoked, the following routine will introduce you to using Notepad:
Comments
Practice Problems 1.2
(Solutions to practice problems always follow the exercises.) Assume that you are using Windows Notepad:
Exercises 1.2
In Exercises 10 through 24, give the key (or key combination) that performs the task in Windows Notepad.
Solutions to Practice Problems 1.2
|
Категории