리치에디트 컨트롤 사용법
리치에디트 컨트롤 사용하기1) AfxInitRichEdit();App 클래스의 InitInstance 함수에서 AfxInitRichEdit 함수를 호출하여 Common Control Library를 초기화시킵니다.2) 워드랩 하기// WrapNone (워드랩 않하기)SetTargetDevice(NULL, 1);// WrapToWindow (워드랩 하기)SetTargetDevice(NULL, 0);3) 원하는 구문만 색상및 폰트변경하기CRichEditCtrl m_reChat;다음 함수는 m_reChat라는 이름의 리치 에디트 컨트롤에 strTextIn으로 지정한 메시지를 추가합니다. crNewColor로 지정한 색상과 sSize로 지정한 크기와 lpszFontName으로 지정한 글꼴로 만들어 추가합니다.
void Cxxx::AddText(CString &strTextIn, COLORREF &crNewColor, int sSize, LPCSTR lpszFontName){  //리치에디트 컨트롤의 끝에 문자열 추가하기  int iTotalTextLength = m_reChat.GetWindowTextLength();  m_reChat.SetSel(iTotalTextLength, iTotalTextLength);  m_reChat.ReplaceSel((LPCTSTR)strTextIn);  int iStartPos = iTotalTextLength;  //인자로 넘어온 색상값과 폰트크기로, CHARFORMAT 설정  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);}
'WindowsPrograming' 카테고리의 다른 글
| RichEditBox에서 글자색 관련 질문입니다.. (0) | 2007.03.11 | 
|---|---|
| MFC 프로그래밍에 대한 Q&A입니다 (0) | 2007.03.11 | 
| RichEditView에서 File Filter설정방법? (0) | 2007.03.11 | 


 
 




