Object-Oriented Programming for Windows 95 and NT

Chapter 10: Graphics Operations

Overview

Most Windows applications depend on the use of controls to perform the tasks that are required of the program. However, there are occasions when you want to write text or graphics directly to a window, without using controls. This chapter looks at the facilities provided by Windows for direct graphics operations.

Graphics Device Interface

The graphics operations are a set of Windows functions that make up the Windows Graphics Device Interface (GDI). This is a subset of the full Windows API, and the GDI functions will be found mixed in with the other API functions in the reference books.

The GDI functions are used for the following tasks:

  • Creating and deleting device contexts (described below)

  • Changing the coordinate system

  • Changing the graphics-drawing area

  • Creating, selecting, and changing pens and brushes

  • Drawing points, lines, and shapes

  • Changing colors and palettes

  • Creating and selecting fonts

  • Writing text to the window

Each of these groups of functions is described below.

Device Contexts

A device context (DC) represents the "logical" drawing area of a window and provides the link between the application and the device driver. A device context can apply to the screen, the printer, or any other output device. Borland use the term display context when referring to screen output.

When writing graphics directly to the screen with Visual C++, you must follow these three steps:

  1. Access a device context, using the GetDC Windows function. Windows allocates a device context for the window whose handle was specified...

UNLIMITED FREE
ACCESS
TO THE WORLD'S BEST IDEAS

SUBMIT
Already a GlobalSpec user? Log in.

This is embarrasing...

An error occurred while processing the form. Please try again in a few minutes.

Customize Your GlobalSpec Experience

Category: Window Operators
Finish!
Privacy Policy

This is embarrasing...

An error occurred while processing the form. Please try again in a few minutes.