리치 에디트 컨트롤에서 문자열을 한 줄씩 추가하는 방법 > MFC Tip

본문 바로가기
사이트 내 전체검색

MFC Tip

리치 에디트 컨트롤에서 문자열을 한 줄씩 추가하는 방법

페이지 정보

profile_image
작성자 이즈
댓글 0건 조회 1,384회 작성일 06-12-28 04:38

본문

리치 에디트 컨트롤을 이용해서 간단한 채팅 창을 만들고 있습니다. 그런데 글꼴과 색상을 바꿔가며 한 줄씩 추가하는 것이 잘 안됩니다.

다음 함수는 m_reChat라는 이름의 리치 에디트 컨트롤에 strTextIn으로 지정한 메시지를 추가합니다. crNewColor로 지정한 색상과 sSize로 지정한 크기와 lpszFontName으로 지정한 글꼴로 추가되는 메시지를 만들어 추가합니다.

void Cxxx::AddText(CString &strTextIn, COLORREF &crNewColor, int sSize, LPCSTR lpszFontName)
{
    // m_reChat은 채팅 컨트롤
int iTotalTextLength = m_reChat.GetWindowTextLength();
m_reChat.SetSel(iTotalTextLength, iTotalTextLength);
m_reChat.ReplaceSel((LPCTSTR)strTextIn);
int iStartPos = iTotalTextLength;

CHARFORMAT cf;
cf.cbSize = sizeof(CHARFORMAT);
cf.dwMask = CFM_COLOR | CFM_UNDERLINE | CFM_BOLD | CFM_FACE | CFM_SIZE;
cf.dwEffects = (unsigned long)~( CFE_AUTOCOLOR | CFE_UNDERLINE | CFE_BOLD);
cf.crTextColor = crNewColor;//RGB(0, 0, 0);
    cf.yHeight = sSize * 20;
    strcpy(cf.szFaceName, lpszFontName); 

int iEndPos = m_reChat.GetWindowTextLength();
m_reChat.SetSel(iStartPos, iEndPos);
m_reChat.SetSelectionCharFormat(cf);
m_reChat.HideSelection(TRUE, FALSE);
m_reChat.LineScroll(1);
}

댓글목록

등록된 댓글이 없습니다.

Total 172건 4 페이지

검색

회원로그인

회원가입

사이트 정보

컴퓨터 정보,윈도우즈,리눅스,포토샵,3ds
맥스,프로그래밍 강좌팁

접속자집계

오늘
307
어제
558
최대
5,287
전체
630,412
Copyright © www.qdata.co.kr All rights reserved.