1.14.1 Creating and Displaying a Caret

Windows forms a caret by inverting the pixel color within the rectangle given by the caret's position and its width and height. Windows flashes the caret by alternately inverting the display, and then restoring it to its previous appearance. The caret blink time (in milliseconds) defines the elapsed time between inverting and restoring the display. A complete flash (on-off-on) takes twice the blink time.

The CreateCaret function creates the caret shape and assigns ownership of the caret to the given window. The caret can be solid or gray, or, for bitmap carets, any desired pattern. The caret can have any shape, but typical shapes are a line, a solid block, a gray block, and a pattern, as shown in Figure 1.1:

Windows displays a solid caret by inverting everything in the rectangle defined by the caret's width and height. For a gray caret, Windows inverts every other pixel. For a pattern, Windows inverts only the white bits of the bitmap that defines the pattern. The width and height of a caret are given in logical units, which means they are subject to the window's mapping mode.