문자열 이어서 넣기
void ChttpDlg::AppendString( const CString str )
{
int nOldLines = 0, nNewLines = 0, nScroll = 0;
long nInsertionPoint = 0;
CHARFORMAT cf;
// Save number of lines before insertion of new text
nOldLines = m_CRichEdit.GetLineCount();
// Initialize character format structure
cf.cbSize = sizeof(CHARFORMAT);
cf.dwMask = CFM_COLOR;
cf.dwEffects = 0; // To disable CFE_AUTOCOLOR
cf.crTextColor = RGB( 0, 0, 0 );
// Set insertion point to end of text
nInsertionPoint = m_CRichEdit.GetWindowTextLength();
m_CRichEdit.SetSel(nInsertionPoint, -1);
// Set the character format
m_CRichEdit.SetSelectionCharFormat(cf);
// Replace selection. Because we have nothing
// selected, this will simply insert
// the string at the current caret position.
m_CRichEdit.ReplaceSel(str);
// Get new line count
nNewLines = m_CRichEdit.GetLineCount();
// Scroll by the number of lines just inserted
nScroll = nNewLines - nOldLines;
m_CRichEdit.LineScroll(nScroll);
}
'NativeCode > mfc' 카테고리의 다른 글
Dialog 아무데나 누르고 창 이동 (0) | 2010.03.18 |
---|---|
Dialog 항상 위 (0) | 2010.03.18 |
리스트 컨트롤 Column 추가 아이템 추가 (1) | 2010.03.18 |
리스트 컨트롤 GridLine 추가하기 (1) | 2010.03.18 |
리스트 컨트롤 값 얻기 & 검색하기 (1) | 2010.03.18 |