IMLangLineBreakConsole::BreakLineA method
Determines where to break the given string based on the specified maximum number of columns.
Syntax
HRESULT BreakLineA(
[in] LCID locale,
[in] UINT uCodePage,
[in] const __wchar_t *pszSrc,
[in] long cchSrc,
[in] long cMaxColumns,
[out] long *pcchLine,
[out] long *pcchSkip
);
Parameters
locale [in]
The locale identifier for the source string.uCodePage [in]
The code page of the source string.pszSrc [in]
The source string.cchSrc [in]
The number of bytes in the source string.cMaxColumns [in]
The maximum number of columns that can be output per line.pcchLine [out]
A pointer to the number of bytes that can fit in the given line before a line break is inserted.pcchSkip [out]
A pointer to the number of bytes 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 code fragment breaks the string pszSrc into multiple lines based on locale, uCodePage, and cMaxColumns.
// pszSrc is a string of cchMax characters or less.
size_t cchMax = 5000;
size_t cchLength;
CHAR pszSrc[cchMax] = "some string";
HRESULT hr = StringCchLengthA(pszSrc, cchMax, &cchLength);
if(SUCCEEDED(hr))
{
size_t cchSrc = cchLength;
size_t cchDone = 0;
while (cchDone < cchSrc)
{
size_t cchLine;
size_t cchSkip;
pMLangLineBreak->BreakLineA(locale, ucodepage,
pszSrc + cchDone, cchSrc - cchDone, cMaxColumns,
&cchLine, &cchSkip);
// The characters between (pszSrc + cchDone) and
// (pszSrc + 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 |