Book Image

Microsoft Visual C++ Windows Applications by Example

By : Stefan Bjornander, Stefan Björnander
Book Image

Microsoft Visual C++ Windows Applications by Example

By: Stefan Bjornander, Stefan Björnander

Overview of this book

Table of Contents (15 chapters)
Microsoft Visual C++ Windows Applications by Example
Credits
About the Author
About the Reviewer
Preface
Index

The Font Class


The Win32 structure LOGFONT below represents a logical font in Windows.

typedef struct tagLOGFONT
{
  LONG lfHeight; 
  LONG lfWidth; 
  LONG lfEscapement; 
  LONG lfOrientation; 
  LONG lfWeight; 
  BYTE lfItalic; 
  BYTE lfUnderline; 
  BYTE lfStrikeOut; 
  BYTE lfCharSet; 
  BYTE lfOutPrecision; 
  BYTE lfClipPrecision; 
  BYTE lfQuality; 
  BYTE lfPitchAndFamily; 
  TCHAR lfFaceName[LF_FACESIZE]; 
}
LOGFONT, *PLOGFONT;

It might seem like a complicated task to set all the fields to their correct values. However, one benefit with the structure is that we really just have to set the lfFaceName and the lfHeight fields. If we set the rest of the fields to zero, they will be adjusted automatically. One convenient way to do is that to call the C standard function memset. In a similar manner, we can use memcmp to compare whether two fonts are equal. There is also a function memcpy to copy a memory block between two locations.

void *memset(void* pDestination, int iValue, size_t iSize...