Summary


When you draw lines, rectangles, and other shapes, you can completely define the shape by giving its size and position. Text is different. Different fonts produce very different results, even for the same text. A single font sometimes even produces different results for a character, depending on the characters that surround it and the area in which it is drawn.

This chapter describes some of the methods you can use to position and measure text in Visual Basic. Layout rectangles and StringFormat objects let you easily draw text that is centered or aligned vertically and horizontally. The DrawString method automatically wraps text if necessary and can understand Tabs and Carriage Return/Line Feed characters contained in the text.

The StringFormat object’s flags let you determine how text is aligned, wrapped, and trimmed. The StringFormat object’s methods let you read and define tab stops.

The Graphics object’s MeasureString method lets you determine roughly how big a string will be when drawn on the object. Its MeasureCharacterRanges method lets you determine the placement of regions of text within a string.

With all of these methods at your disposal, you can position text almost exactly where you want it.

This chapter and Chapter 21 explain how to draw objects (such as lines, ellipses, and text) at a relatively high level. When you draw a line from one point to another, you don’t need to specify exactly how the pixels on the screen should be colored. You set values for higher-level properties such as the pen color and dash style, brush color and style, and so forth. Then Visual Basic figures out the details.

Chapter 23 explains how you can read and manipulate images on a pixel-by-pixel basis. It tells how to load and save image files in different formats (such as BMP, GIF, JPEG, and PNG) and how to get and set the colors of individual pixels.




Visual Basic 2005 with  .NET 3.0 Programmer's Reference
Visual Basic 2005 with .NET 3.0 Programmer's Reference
ISBN: 470137053
EAN: N/A
Year: 2007
Pages: 417

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net