문자열 이어서 넣기


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);

}

+ Recent posts