1. 动态创建CMyEdit控件的代码:
pEdit = new CMyEdit;
pEdit->Create(WS_CHILD|WS_VISIBLE|WS_TABSTOP|ES_MULTILINE
|WS_VSCROLL,
CRect(10,10,100,100), this, 1);
pEdit->ModifyStyleEx(0, WS_EX_CLIENTEDGE, SWP_DRAWFRAME); 2. CMyEdit中被继承的函数
void CMyEdit::OnLButtonDblClk(UINT nFlags, CPoint point)
{
int iStart, iEnd;
CString m_sSelectedText, m_sEditText;
GetSel(iStart, iEnd);
GetWindowText(m_sEditText); //get begin and end position of selected line (between two '\n')
int iLeft = m_sEditText.ReverseFind('\n');
int iRight = iLeft;
CString remainStr = m_sEditText.Left(iLeft);
while ( iLeft>iStart )
{
iRight = iLeft-1;
iLeft = remainStr.ReverseFind('\n');
remainStr = remainStr.Left(iLeft-1);
}
//set selected for current line
SetFocus();
SetSel(iLeft+1,iRight-iLeft-1); //这里无效,没有高亮显示整行。
//get text of selected line
m_sSelectedText = m_sEditText.Mid(iLeft+1,iRight-iLeft-1);//这里得到了整行的内容 CEdit::OnLButtonDblClk(nFlags, point);
}???
谢谢
pEdit = new CMyEdit;
pEdit->Create(WS_CHILD|WS_VISIBLE|WS_TABSTOP|ES_MULTILINE
|WS_VSCROLL,
CRect(10,10,100,100), this, 1);
pEdit->ModifyStyleEx(0, WS_EX_CLIENTEDGE, SWP_DRAWFRAME); 2. CMyEdit中被继承的函数
void CMyEdit::OnLButtonDblClk(UINT nFlags, CPoint point)
{
int iStart, iEnd;
CString m_sSelectedText, m_sEditText;
GetSel(iStart, iEnd);
GetWindowText(m_sEditText); //get begin and end position of selected line (between two '\n')
int iLeft = m_sEditText.ReverseFind('\n');
int iRight = iLeft;
CString remainStr = m_sEditText.Left(iLeft);
while ( iLeft>iStart )
{
iRight = iLeft-1;
iLeft = remainStr.ReverseFind('\n');
remainStr = remainStr.Left(iLeft-1);
}
//set selected for current line
SetFocus();
SetSel(iLeft+1,iRight-iLeft-1); //这里无效,没有高亮显示整行。
//get text of selected line
m_sSelectedText = m_sEditText.Mid(iLeft+1,iRight-iLeft-1);//这里得到了整行的内容 CEdit::OnLButtonDblClk(nFlags, point);
}???
谢谢
解决方案 »
- 数据库链接出错 unresolved external symbol
- 找了个傅里叶的代码,为什么结果与mathlab不一样?
- 怎么在MFC窗口的指定位置输出数字??
- 在ActiveX项目中的重载WindowPro函数里面居然截取不到自定义的消息
- dll版本验证的问题
- 弹出菜单响应自定义消息问题,谢谢
- 求购《COM本质论》
- 请教:开始学Vc,大家给点建议!!!
- 高分求购----“通过http暗藏通道来穿透防火墙的”原代码
- VC如何编程,上网 进行“文件传输”的功能(发送Email也行)。。。高手指点!
- 命名空间的问题
- ··连接点支不支持跨主机啊?DCOM可跨主机时,客户pConnectPoint->Advise到服务器总是失败。
代码是否有误,,
改成
void SetSel( int nStartChar, int nEndChar, BOOL bNoScroll = FALSE );
int iLeft = m_sEditText.ReverseFind('\n');
int iRight = iLeft;
CString remainStr = m_sEditText.Left(iLeft);
if(iLeft<iStart)
iRight = m_sEditText.GetLength(); // while ( iLeft>iStart )
{
iRight = iLeft-1;
iLeft = remainStr.ReverseFind('\n');
remainStr = remainStr.Left(iLeft-1);
}
//set selected for current line
SetFocus();
SetSel(iLeft+1,iRight); //这里无效,没有高亮显示整行。
CEdit::OnLButtonDblClk(nFlags, point);
把CEdit::OnLButtonDblClk(nFlags, point);//注释起来,另:
CEdit::SetSel
void SetSel( DWORD dwSelection, BOOL bNoScroll = FALSE );void SetSel( int nStartChar, int nEndChar, BOOL bNoScroll = FALSE );ParametersdwSelectionSpecifies the starting position in the low-order word and the ending position in the high-order word. If the low-order word is 0 and the high-order word is –1, all the text in the edit control is selected. If the low-order word is –1, any current selection is removed.低位字指定起始位置,高位字为结束位置。如果低位为0,高位为-1,则编辑控件中的全部文本被选中;如果低位字为-1,则任何当前选定内容被去掉选定状态。 bNoScrollIndicates whether the caret should be scrolled into view. If FALSE, the caret is scrolled into view. If TRUE, the caret is not scrolled into view.指示是否显示脱字符是滚动可见的。如果值为FALSE,则显示,TRUE不显示。 nStartCharSpecifies the starting position. If nStartChar is 0 and nEndChar is –1, all the text in the edit control is selected. If nStartChar is –1, any current selection is removed.指出当前选中部分的开始位置。如果nStartChar=0且nEndChar=-1,则编辑控件的文本被全选;如果nStartChar=-1,则任何当前选定内容被去掉选定状态。 nEndCharSpecifies the ending position.指出结束位置。 ResCall this function to select a range of characters in an edit control.调用此成员函数在一个编辑控件中选择一定范围的字符。