EditWordBreakProc

The EditWordBreakProc function is an application-defined callback function used with the EM_SETWORDBREAKPROC message. A multiline edit control or a rich edit control calls an EditWordBreakProc function whenever the control must break a line of text.

The EDITWORDBREAKPROC type defines a pointer to this callback function. EditWordBreakProc is a placeholder for the application-defined function name.

int CALLBACK EditWordBreakProc(
  LPTSTR lpch,     // pointer to edit text
  int ichCurrent,  // index of starting point
  int cch,         // length in characters of edit text
  int code         // action to take
);
 

Parameters

lpch
Pointer to the text of the edit control.
ichCurrent
Specifies an index to a character position in the buffer of text that identifies the point at which the function should begin checking for a word break.
cch
Specifies the number of characters in the edit control text.
code
Specifies the action to be taken by the callback function. This parameter can be one of the following values:
Value Action
WB_CLASSIFY Retrieve the character class and word break flags of the character at the specified position. This value is for use with rich edit controls.
WB_ISDELIMITER Check whether the character at the specified position is a delimiter.
WB_LEFT Find the beginning of a word to the left of the specified position.
WB_LEFTBREAK Find the end-of-word delimiter to the left of the specified position. This value is for use with rich edit controls.
WB_MOVEWORDLEFT Find the beginning of a word to the left of the specified position. This value is used during CTRL+LEFT key processing. This value is for use with rich edit controls.
WB_MOVEWORDRIGHT Find the beginning of a word to the right of the specified position. This value is used during CTRL+RIGHT key processing. This value is for use with rich edit controls.
WB_RIGHT Find the beginning of a word to the right of the specified position. (This is useful in right-aligned edit controls.)
WB_RIGHTBREAK Find the end-of-word delimiter to the right of the specified position. (This is useful in right-aligned edit controls.) This value is for use with rich edit controls.

Return Values

If the code parameter specifies WB_ISDELIMITER, the return value is nonzero (TRUE) if the character at the specified position is a delimiter, or zero if it is not. If the code parameter specifies WB_CLASSIFY, the return value is the character class and word break flags of the character at the specified position. Otherwise, the return value is an index to the beginning of a word in the buffer of text.

Remarks

A carriage return followed by a linefeed must be treated as a single word by the callback function. Two carriage returns followed by a linefeed also must be treated as a single word.

An application must install the callback function by specifying the address of the callback function in an EM_SETWORDBREAKPROC message.

For rich edit controls, you can alternately use the EM_SETWORDBREAKPROCEX message to replace the default extended word break procedure with an EditWordBreakProcEx callback function. This function provides additional information about the text, such as the character set.

QuickInfo

  Windows NT: Requires version 3.1 or later.
  Windows: Requires Windows 95 or later.
  Windows CE: Unsupported.
  Header: Declared in winuser.h.
  Import Library: User-defined.
  Unicode: Defined as Unicode and ANSI prototypes.

See Also

Edit Controls Overview, Edit Control Functions, EM_FINDWORDBREAK, EM_SETWORDBREAKPROC, EM_SETWORDBREAKPROCEX, EditWordBreakProcEx, SendMessage