DdfSetTextAlign
This function defines whether left, center, or right text justification is to be used when text formatting is off.
Syntax
DdfSetTextAlign(hddf, fAlign)
Parameters
- hddf (HDDF) - input
- Handle to DDF returned by DdfInitialize.
- fAlign (ULONG) - input
- Justification flag. Only the following constants may be used:
- TA_LEFT - Left-justify text
- TA_RIGHT - Right-justify text
- TA_CENTER - Center text
- rc (BOOL) - returns
- Success indicator.
Returns
- rc (BOOL) - returns
- Success indicator.
- TRUE Successful completion
- FALSE Error occurred
Remarks
This function should be called before `DdfSetFormat` is called to turn off text formatting and should not be called again until formatting is turned back on. Note that leading and trailing spaces are not stripped from the text as a result of this alignment.
Possible errors include:
- HMERR_DDF_ALIGN_TYPE (0x3002) The alignment type is not valid.
Example Code
Declaration:
#define INCL_DDF #include <os2.h> HDDF hddf; /* Handle to DDF returned by DdfInitialize. */ ULONG fAlign; /* Justification flag. */ BOOL rc; /* Success indicator. */ rc = DdfSetTextAlign(hddf, fAlign);
After initializing a DDF buffer with DdfInitialize, this example uses `DdfSetTextAlign` to specify left-justified text in the DDF buffer when formatting is off. It then uses `DdfSetFormat` to turn off formatting for text in the DDF buffer (corresponding to the IPF `lines` tag).
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_GPIPRIMITIVES /* Drawing Primitives/Attributes*/ #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; } /* left justify text when formatting is OFF */ if (!DdfSetTextAlign(hDdf, TA_LEFT)) { return (MRESULT)FALSE; } /* turn formatting OFF */ if (!DdfSetFormat(hDdf, FALSE)) { return (MRESULT)FALSE; } if (!DdfText(hDdf, "Format OFF: This text should be Left Aligned!\n")) { return (MRESULT)FALSE; } return (MRESULT)hDdf; } return WinDefWindowProc(hwnd, ulMsg, mp1, mp2); }