Mfc
1. EditBox 글자 지우며 마지막에 쓰기
멤버 변수 이용 한 거 입니다.
editbox 최대값(별도 설정 없으면 30000)이 인데 , 글자 수가 29000 보다 크면, 앞 1000 개 지우는 거 입니다.
void CDlg_Main::wCsDisp( CString cS ){
int nLength;
// if( ((CButton*)GetDlgItem(IDC_L_CHK_Pause))->GetCheck() ) return; // 쓰기 중지 상태면 나간다.
nLength = m_Disp.GetWindowTextLength(); // Get the length of the text
if( (unsigned int)(nLength + 1000) > m_Disp.GetLimitText() ) { // 남은 글자 수가 1000 개 가 안되면, 1000개 지운다.
m_Disp.SetSel(1, 1000); // 처음 부터 1000 개 선택
m_Disp.Clear();
// nLength = m_Disp.GetWindowTextLength(); //
}
m_Disp.SetSel(-1, -1); // 커서 위치를 맨 뒤로 이동
m_Disp.ReplaceSel(cS); // replace the selection
m_Disp.SetFocus(); // 마지막 텍스트를 Focus
}
2. 줄 마지막으로 가기
void CDlg_Main::endDisp() { // 마지막 가기
int nLines;
static unsigned int oLines= 0;
nLines = m_Disp.GetLineCount(); // 현재 총 줄 수
if( nLines > oLines ) { // 이전 보다 크면
m_Disp.LineScroll( nLines - oLines , 0); // 새로 생긴 줄 만큼 아래로 스크롤
}
oLines = nLines;
}
'개발 > mfc' 카테고리의 다른 글
| mfc: CString 비교 - 작업중 (0) | 2024.01.18 |
|---|---|
| mfc, button 글자,바닦에 빛깔 입히기 색 변경 (0) | 2023.12.19 |
| [mfc] UDP,TCP server, client sample source (0) | 2023.11.27 |
| mfc UpdateData (0) | 2023.11.17 |
| MFC 메모리 릭 체크시 유용한 방법 2개 (0) | 2023.10.25 |