当前位置:编程学习 > VC++ >>

VC编辑框追加字符串并自动滚屏功能

CEdit *pEt = (CEdit *)GetDlgItem(IDC_EDIT_RECV); 
//方式1
int nLen = GetWindowTextLength(pEt->m_hWnd);
pEt->SetSel(nLen, nLen);
pEt->ReplaceSel("要添加的文字");

//方式2
::SendMessage(GetDlgItem(hwnd,IDC_EDIT_RECV),EM_SETSEL,-1,0);
::SendMessage(GetDlgItem(hwnd,IDC_EDIT_RECV),EM_REPLACESEL,false,(long)buffer);

//方式3
CString str="append ";
int  nLength=pEt->SendMessage(WM_GETTEXTLENGTH);  
pEt->SetSel(nLength,nLength);  
pEt->ReplaceSel(str); 

//自动滚屏
pEt->LineScroll(pEt->GetLineCount());

 

补充:软件开发 , Vc ,
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,