OWLNext    7.0
Borland's Object Windows Library for the modern age
Loading...
Searching...
No Matches
Constructing TFont

You can construct a TFont either directly, by specifying all the attributes of the font in the constructor, or indirectly, by specifying a TFont & or a pointer to a LOGFONT structure.

Directly constructing a pen creates a new object with the specified attributes. Here are the constructors for directly constructing a font:

TFont(const char far* facename=0,
int height=0, int width=0, int escapement=0,
uint8 italic=false, uint8 underline=false,
uint8 strikeout=false,
uint8 charSet=1,
TFont(int height, int width, int escapement=0,
int orientation=0,
uint8 italic=false, uint8 underline=false,
uint8 strikeout=false,
uint8 charSet=1,
const char far* facename=0);

The first constructor lets you conveniently plug in the most commonly used attributes for a font (such as name, height, width, and so on) and let the other attributes (which generally have the same value time after time) take their default values. The second constructor has the parameters in the same order as the CreateFont Windows API call so you can easily cut and paste from existing Windows code.

Indirectly creating a font also creates a new object, but it copies the attributes of the object passed to it into the new font object. Here are the constructors for indirectly creating a font:

TFont(const LOGFONT far* logFont);
TFont(const TFont&);

You can also create a new TFont object from an existing HFONT handle:

TFont(HFONT handle, TAutoDelete autoDelete = NoAutoDelete);

This constructor is used to obtain an ObjectWindows object as an alias to a regular Windows handle received in a message.

See Also