Jump to content

FindWordHook

From EDM2

This hook allows an application to control where the WinDrawText function breaks a character string that is too long for the drawing rectangle.

Syntax

FindWordHook(usCodepage, pszText, cb, ich, pichStart, pichEnd, pichNext);

Parameters

usCodepage (USHORT) - input
Codepage to use.
This parameter contains the codepage identifier of the string to be formatted.
pszText (PSZ) - input
Text to break.
This parameter contains a pointer to the actual string.
cb (ULONG) - input
Maximum text size.
This parameter contains a value specifying the number of bytes in the string.
ich (ULONG) - input
Break near here.
This parameter contains the index of the character in the string that intersects the right edge of the drawing rectangle.
pichStart (PULONG) - output
Where break began.
This parameter contains the index of the starting character of the intersecting word.
pichEnd (PULONG) - output
Where break ended.
This parameter contains the index of the ending character of the intersecting word.
pichNext (PULONG) - output
Where next word begins.
This parameter contains the index of the starting character of the next word in the string.
rc (BOOL) - returns
Success indicator.
TRUE: If the find-word hook function returns TRUE, WinDrawText will only draw the string up to, but not including, the specified word.
FALSE: If the find-word hook function returns FALSE, WinDrawText formats the string in the default manner.

Returns

rc (BOOL) - returns
Success indicator.
TRUE: If the find-word hook function returns TRUE, WinDrawText will only draw the string up to, but not including, the specified word.
FALSE: If the find-word hook function returns FALSE, WinDrawText formats the string in the default manner.

Remarks

The system calls this hook from within the WinDrawText function, if the DT_WORDBREAK flag is set. It lets the application have control of where the function WinDrawText should break for a string that is too long.

Example Code

#define INCL_WINHOOKS /* Or use INCL_WIN, INCL_PM, */
#include <os2.h>

USHORT  usCodepage; /* Codepage to use. */
PSZ     pszText;    /* Text to break. */
ULONG   cb;         /* Maximum text size. */
ULONG   ich;        /* Break near here. */
PULONG  pichStart;  /* Where break began. */
PULONG  pichEnd;    /* Where break ended. */
PULONG  pichNext;   /* Where next word begins. */
BOOL    rc;         /* Success indicator. */

rc = FindWordHook(usCodepage, pszText, cb,
       ich, pichStart, pichEnd, pichNext);