Share via


Visual Basic Concepts

Using Graphical Controls

Visual Basic provides three controls designed to create graphical effects in an application:

  • The image control

  • The line control

  • The shape control

Advantages of Graphical Controls

The image, line, and shape controls are very useful for creating graphics at design time. One advantage of graphical controls is that they require fewer system resources than other Visual Basic controls, which improves the performance of your Visual Basic application.

Another advantage of graphical controls is that you can create graphics with less code than with graphics methods. For example, you can use either the Circle method or the shape control to place a circle on a form. The Circle method requires that you create the circle with code at run time, while you can simply draw the shape control on the form and set the appropriate properties at design time.

Limitations of Graphical Controls

While graphical controls are designed to maximize performance with minimal demands on the application, they accomplish this goal by limiting other features common to controls in Visual Basic. Graphical controls:

  • Cannot appear on top of other controls, unless they are inside a container that can appear on top of other controls (such as a picture box).

  • Cannot receive focus at run time.

  • Cannot serve as containers for other controls.

  • Do not have an hWnd property.

For More Information   For information about the graphics methods, see "Using the Graphics Methods" later in this chapter. For information about the graphical controls, see "Using the Image Control," "Using the Line Control," and "Using the Shape Control" in "Using Visual Basic's Standard Controls." For information about the effect of graphics on your application's performance, see especially "Cutting Back on Graphics" in "Designing for Performance and Compatibility."