Windows API Guide: CFHookProc Callback Function


Declare Function CreateFontIndirect Lib "gdi32.dll" Alias "CreateFontIndirectA" (lplf As LOGFONT) As Long

Platforms

  • Windows 95: Supported.
  • Windows 98: Supported.
  • Windows NT: Requires Windows NT 3.1 or later.
  • Windows 2000: Supported.
  • Windows CE: Requires Windows CE 1.0 or later.

Description & Usage

CreateFontIndirect creates a font object, which allows a font with given attributes to be used to draw text on a device. The font created by the function is the one which most closely matches the attributes of the logical font information passed via the structure. After your program is finished using the font, it must be deleted by using DeleteObject.

Return Value

If an error occured, the function returns 0 (Windows NT, 2000: use GetLastError to get the error code). If successful, the function returns a handle to the font just created.

Visual Basic-Specific Issues

None.

Parameters

lplf
Information describing the desired attributes to give to the newly created font.

Example

' This code is licensed according to the terms and conditions listed here. ' Use the font used by Windows to draw the title text of ' icons to write the alphabet on window Form1. Dim lf As LOGFONT  ' receives information about the font Windows uses Dim hFont As Long  ' handle to the font that is created Dim hOldFont As Long  ' handle to the font which Form1 previously had selected Dim retval As Long  ' return value ' Get the attributes of the logical font used by Windows to ' draw the title text of icons. retval = SystemParametersInfo(SPI_GETICONTITLELOGFONT, Len(lf), lf, 0) ' Create a font matching the logical font description. hFont = CreateFontIndirect(lf) ' Select that font for use in Form1, noting the previous font. hOldFont = SelectObject(Form1.hDC, hFont) ' Write the alphabet near the upper-left corner of Form1. retval = TextOut(Form1.hDC, 10, 10, "ABCDEFGHIJKLMNOPQRSTUVWXYZ", 26) ' Restore the previously selected font for use in Form1. retval = SelectObject(Form1.hDC, hOldFont) ' Delete the created font to free resources. retval = DeleteObject(hFont)

See Also

CreateFont

Category

Fonts & Text

Go back to the alphabetical Function listing.
Go back to the Reference section index.


Last Modified: October 11, 1999
This page is copyright © 1999 Paul Kuliniewicz. Copyright Information Revised October 29, 2000
Go back to the Windows API Guide home page.
E-mail: vbapi@vbapi.com Send Encrypted E-Mail
This page is at http://www.vbapi.com/ref/c/createfontindirect.html



Windows API Guide
Windows API Guide - Reference - Volume 1: Version 3.0 For the MS-DOS and PC-DOS Operating Systems
ISBN: B001V0KQIY
EAN: N/A
Year: 1998
Pages: 610

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