BCGSuite for MFC
BOOL CBCGPEditCtrl::IsInBlock ( int  nPos,
TCHAR  chOpen,
TCHAR  chClose,
int &  nBlockStart,
int &  nBlockEnd 
)

Determines whether the specifies offset is located between two characters.

Returns
Nonzero if nPos is between two characters chOpen and chClose; otherwise FALSE. You must not use nBlockStart and nBlockEnd if the function returns FALSE.

You can use this function for advanced block coloring in conjunction with overridden OnGetCharColor(). For example, if you want to implement HTML syntax highlighting, you can override OnGetCharColor() and every time call

IsInBlock(nCurrPos, "<", ">", nBlockStart, nBlockFinish).

Note. When implementing this algorithm you should be aware of performance issues, because IsInBlock implements simple text scanning in both directions from the specified offset. It may be non-efficient for large blocks.

Parameters
nPosPosition to check.
chOpenOpening block character.
chCloseClosing block character.
nBlockStart[out] When the function returns contains the zero-based offset of chOpen from the beginning of the text.
nBlockEnd[out] When the function returns contains the zero-based offset of chClose from the beginning of the text.