IMLangLineBreakConsole::BreakLineW method

Determines where to break the given string based on the specified maximum number of columns.

Syntax

HRESULT BreakLineW(
  [in]        LCID  locale,
  [in]  const WCHAR *pszSrc,
  [in]        long      cchSrc,
  [in]        long      cMaxColumns,
  [out]       long      *pcchLine,
  [out]       long      *pcchSkip
);

Parameters

  • locale [in]
    The locale identifier for the source string.

  • pszSrc [in]
    The source Unicode string.

  • cchSrc [in]
    The number of Unicode characters in the source string.

  • cMaxColumns [in]
    The maximum number of columns that can be output per line.

  • pcchLine [out]
    A pointer to an integer containing the number of Unicode characters that can fit in the given line before a line break is inserted.

  • pcchSkip [out]
    A pointer to an integer containing the number of characters in the source string to skip after the line break.

Return value

Returns one of the following values.

Return code Description
S_OK

Success.

E_FAIL

An error occurred.

E_OUTOFMEMORY

There is not enough memory to complete the operation.

Remarks

IMLangLineBreakConsole::BreakLineW is the Unicode version of IMLangLineBreakConsole::BreakLineA.

The cchSrc parameter always must be specified, even if pszSrc is a null-terminated string.

The number of columns is the same as the number of half-width characters. One full-width character is two columns wide.

The pcchSkip parameter gets the number of characters that do not have to be displayed at the start of the next line. For example, if the string "Hello world!" is broken after "Hello," pcchSkip is set to 1, indicating that the space between the words is not output to the next line.

Examples

The following example shows how to break pwszSrc into multiple lines based on locale and cMaxColumns.

//  pwszSrc is a string of cchMax characters or less.

size_t cchMax = 5000;
size_t cchLength;

WCHAR pszSrc[cchMax] = L("some source string");
HRESULT hr = StringCchLengthW(pwszSrc, cchMax, &cchLength);

if(SUCCEEDED(hr))
{
   size_t cchSrc = cchLength;
   size_t cchDone = 0;

   while (cchDone < cchSrc)
   {
       size_t cchLine;
       size_t cchSkip;

       pMLangLineBreak->BreakLineW(locale, pwszSrc + cchDone,
           cchSrc - cchDone, cMaxColumns, &cchLine, &cchSkip);

       // The characters between (pwszSrc + cchDone) and
       // (pwszSrc + cchDone + cchLine - 1) should be
       // output as one line.

       cchDone += cchLine + cchSkip;
   }
}
else
{
   //  TODO: Add error handling code here.
}

Requirements

Minimum supported client

Windows XP

Minimum supported server

Windows 2000 Server

Header

Mlang.h

IDL

Mlang.idl

DLL

Mlang.dll

See also

IMLangLineBreakConsole