In Visual Basic, the Form is the container for all the controls that make up the user interface. When a Visual Basic application is executing, each window it displays on the Desktop is a Form. In previous chapters, we used Forms as containers on which we placed the elements of the user interface: Now, we’ll look at Forms and at a few related topics, such as menus (Forms are the only objects that can have menus attached) and drag-and-drop operations. The Form is the top-level object in a Visual Basic application, and every application starts with the Form. Forms have a built-in functionality that is always available without any programming effort on your part. You can move a Form around, resize it, and even cover it with other Forms. You do so with the mouse, with the keyboard, or through the Control menu. Forms have many trivial properties that won’t be discussed here. Instead, let’s jump directly to the properties that are unique to Forms and then look at how to manipulate Forms from within an application’s code.
‘TheAppearance of Form
The main characteristic of a Form is the title bar on which the form’s caption is displayed (see Figure 4.1). On l.e left end of the title bar is the Control Menu icon. Clicking this icon opens the Control menu. On the right side of the title bar are three buttons; Minimize, Maximize, and Close. Clicking these buttons performs the associated function. When a Form is maximized.zhe Maximize button is replaced by the Normal butt ,clicked, ~j,eNormal button vvill restore the Form to its size and position before it was miaximized.
IMG
The Control menu contains the following commands:
• Restore Restores a maximized Form to the size it was before it was maximized; available only if the Form has been maximized
• Move Lets the user move the Form around with the mouse
• Size Lets the user resize the control with the mouse
• Minimize Minimizes the Form
• Maximizes Maximizes the Form
• Close Closes the current Form
You can customize the appearance of Form with the following Form properties:
• MinButta, MaxButton These two properties are True by default. Set them to False to hide the corresponding buttons on the ~tle bar.
• ControlMenu· This property is also True by default. Set it to False to hide the icon and disable the Control menu. Although the Control menu is rarely used, Wmdows applications don’t disable it. , .When the ControlMenu property is False, the three buttons on the title bar .are also disabled. If you set the Caption property to an empty string, the title bar disappears altogether. .
• Border Style The BorderStyle property determines the style of the Form’s border and the appearance of the Form. The BorderStyle property can take one of the values
IMG