DdfSetFont
Appearance
This function specifies a text font in the DDF buffer.
Syntax
DdfSetFont(hddf, pszFaceName, ulWidth, ulHeight)
Parameters
- hddf (HDDF) - input
- Handle to DDF returned by DdfInitialize.
- pszFaceName (PCSZ) - input
- Pointer to font name. This parameter can be specified in two ways:
- An ASCIIZ string specifying the font name.
- NULL or "default" to specify the default font.
- ulWidth (ULONG) - input
- Font width in points. A point is approximately 1/72 of an inch.
- ulHeight (ULONG) - input
- Font height in points.
- rc (BOOL) - returns
- Success indicator.
Returns
- rc (BOOL) - returns
- Success indicator.
- TRUE Successful completion
- FALSE Error occurred
Remarks
No specific remarks were provided for this function.
Possible errors include:
- HMERR_DDF_MEMORY (0x3001) Not enough memory is available.
Example Code
Declaration:
#define INCL_DDF #include <os2.h> HDDF hddf; /* Handle to DDF returned by DdfInitialize. */ PCSZ pszFaceName; /* Pointer to font name. */ ULONG ulWidth; /* Font width in points. */ ULONG ulHeight; /* Font height in points. */ BOOL rc; /* Success indicator. */ rc = DdfSetFont(hddf, pszFaceName, ulWidth, ulHeight);
After initializing a DDF buffer with DdfInitialize, this example uses `DdfPara` to start a new paragraph, `DdfSetFont` and `DdfSetFontStyle` to display text in a large, bold Courier font, `DdfSetColor` to change the text color, and `DdfText` to place text in the buffer.
For a more detailed example and discussion of initializing DDF, see the DdfInitialize sample.
#define INCL_WINWINDOWMGR /* General window management */ #define INCL_WINMESSAGEMGR /* Message management */ #define INCL_DDF /* Dynamic Data Facility */ #include <os2.h> #include <pmhelp.h> MRESULT WindowProc(HWND hwnd, ULONG ulMsg, MPARAM mp1, MPARAM mp2) { HWND hwndParent; HWND hwndInstance; /* help instance window */ HDDF hDdf; /* DDF handle */ switch (ulMsg) { case HM_QUERY_DDF_DATA: /* get the help instance */ hwndParent = WinQueryWindow(hwnd, QW_PARENT); hwndParent = WinQueryWindow(hwndParent, QW_PARENT); hwndInstance = (HWND)WinSendMsg(hwndParent, HM_QUERY, MPFROMSHORT(HMQW_INSTANCE), NULL); /* Allocate 1K Buffer (default) */ hDdf = DdfInitialize( hwndInstance, /* Handle of help instance */ 0L, /* Default buffer size */ 0L /* Default increment */ ); if (hDdf == NULLHANDLE) /* Check return code */ { return (MRESULT)FALSE; } /* create paragraph in DDF buffer */ if (!DdfPara(hDdf)) { return (MRESULT)FALSE; } /* Change to large (100 x 100 dimensions) Courier font */ if (!DdfSetFont(hDdf, "Courier", 100L, 100L)) { return (MRESULT)FALSE; } /* make the font BOLDFACE */ if (!DdfSetFontStyle(hDdf, FM_SEL_BOLD)) { return (MRESULT)FALSE; } /* make the text display as BLUE on a PALE GRAY background */ if (!DdfSetColor(hDdf, CLR_PALEGRAY, CLR_BLUE)) { return (MRESULT)FALSE; } /* Write data into the buffer */ if (!DdfText(hDdf, "Sample Text")) { return (MRESULT)FALSE; } return (MRESULT)hDdf; } return WinDefWindowProc(hwnd, ulMsg, mp1, mp2); }