给你个MSDN上的例子:// The pointer to my edit. extern CEdit* pmyEdit; // The string for replacing. extern LPCTSTR lpszmyString;int nBegin, nEnd;
// Replace the second line, if it exists, of the edit control // with the text lpszmyString. if ((nBegin=pmyEdit->LineIndex(1)) != -1) { nEnd = nBegin + pmyEdit->LineLength(nBegin); pmyEdit->SetSel(nBegin, nEnd); pmyEdit->ReplaceSel(lpszmyString }
extern CEdit* pmyEdit;
// The string for replacing.
extern LPCTSTR lpszmyString;int nBegin, nEnd;
// Replace the second line, if it exists, of the edit control
// with the text lpszmyString.
if ((nBegin=pmyEdit->LineIndex(1)) != -1)
{
nEnd = nBegin + pmyEdit->LineLength(nBegin);
pmyEdit->SetSel(nBegin, nEnd);
pmyEdit->ReplaceSel(lpszmyString
}
SendMessage(hWnd, EM_REPLACESEL, (WPARAM) bCanUndo, (LPARAM)lpszNewText);
//hWnd是你文本框的句柄,bCanUndo是是否可以撤销,lpszNewText是你要替换的字符这两个没有什么区别的,你试试
兄台,好像你连声明对象都不太清楚哦:是这样的:
CEdit* pmyEdit;还有,IE上的文本框不见得就是CEdit对象。