去掉光标选中变蓝的功能 有个文本框, 如果 选中的话, 然后 按backspace,就会整条语句都删除我想去掉这个功能只让, 一个一个的删除,而不是 整条语句变蓝,然后 一按 backspace,就会整条删除。如何实现???? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 对于这种特殊事件要求的控件,搂主可以查一个关键字 "窗口子类化"比如这篇文章就是讲如何子类化的http://www.vckbase.com/document/viewdoc/?id=1343重点是 SetWindowLong这个函数,lz 先看看吧 你好,在吗??子类化,我知道,我在写一个特殊的ecit所以要去掉这个功能或者说, 当用户 一旦用光标 选蓝的时候,我 该处理哪个消息??选蓝,会发送哪个消息,你提供的文章对我没有帮助我现在 查不到, 是哪一个消息??只要知道这个消息就好办了 是文本编辑框吧,那你处理按键消息呀,在按键消息的处理程序中这样处理:如果有选择的是多个字符那只删除最后一个就行了.比如选择的是:abc,那你选得到选择的字符,如何清掉abc,在用SetWindowText("ab")就可以了,不知道这样可不可以实现楼主的要求. BOOL CXXXDlg::PreTranslateMessage(MSG* pMsg) { // TODO: Add your specialized code here and/or call the base class CEdit* pEdit = (CEdit*)GetDlgItem(IDC_EDIT1); ASSERT(pEdit && pEdit->GetSafeHwnd()); if((pEdit->GetSafeHwnd() == pMsg->hwnd) && (WM_KEYDOWN == pMsg->message)) { if(VK_BACK == pMsg->wParam) { CString str; pEdit->GetWindowText(str); int start = -1; int end = -1; pEdit->GetSel(start, end); if(end > start) { str = str.Mid(start, end - start); str = str.Left(str.GetLength() - 1); pEdit->ReplaceSel(str); pEdit->SetSel(start, end - 1); return TRUE; } } } return CDialog::PreTranslateMessage(pMsg);} 从CEdit派生一个类。响应WM_CHAR消息。void CSpEdit::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags){ if (nChar == VK_BACK) { int nSelStart = 0, nSelEnd = 0; GetSel(nSelStart, nSelEnd); SetSel(nSelEnd, nSelEnd); } CEdit::OnChar(nChar, nRepCnt, nFlags);} BOOL CXXXDlg::PreTranslateMessage(MSG* pMsg) { // TODO: Add your specialized code here and/or call the base class CEdit* pEdit = (CEdit*)GetDlgItem(IDC_EDIT1); ASSERT(pEdit && pEdit->GetSafeHwnd()); if((pEdit->GetSafeHwnd() == pMsg->hwnd) && (WM_KEYDOWN == pMsg->message)) { pEdit->SetCurSel( -1, -1 ); return TRUE; } return CDialog::PreTranslateMessage(pMsg);} BOOL CXXXDlg::PreTranslateMessage(MSG* pMsg) { // TODO: Add your specialized code here and/or call the base class ASSERT(pEdit && pEdit->GetSafeHwnd()); if((GetDlgItem(IDC_EDIT1)->GetSafeHwnd() == pMsg->hwnd) && (WM_KEYDOWN == pMsg->message)) { if(VK_BACK == pMsg->wParam) { return true; } } return CDialog::PreTranslateMessage(pMsg);}这样就能去除掉CEdit控件中VK_BACK这个按键了... ????? 难道不是有个 hidesel 属性的么?.... 为什么都不用呢?. 难道是我记错了? 求帮忙 关于MFC工程 【SOS】一个winsocket TCP通信的简单问题。 在类成员定义里加个enum有什么意义? VC连接ORACLE问题,100分求救,在线等。 请问怎样才能使一个CFormView上的Edit与其他分割成的窗体之间产生联系?谢谢 程序中如何打开控制面板的电源管理页面? 关于内存回收(给500分,问题解决后分批给) 有那位大虾有pid控制算法? 大家来讨论一个算法 CRichEditCtrl 类似windows画图板的文字插入效果 帮我看下这个简单的源码 如果能做下视频教程那就更好了
搂主可以查一个关键字 "窗口子类化"
比如这篇文章就是讲如何子类化的
http://www.vckbase.com/document/viewdoc/?id=1343重点是 SetWindowLong这个函数,
lz 先看看吧
子类化,我知道,我在写一个特殊的ecit
所以要去掉这个功能或者说, 当用户 一旦用光标 选蓝的时候,我 该处理哪个消息??选蓝,会发送哪个消息,你提供的文章对我没有帮助我现在 查不到, 是哪一个消息??只要知道这个消息就好办了
如果有选择的是多个字符那只删除最后一个就行了.比如选择的是:abc,那你选得到选择的字符,如何清掉abc,在用SetWindowText("ab")就可以了,不知道这样可不可以实现楼主的要求.
{
// TODO: Add your specialized code here and/or call the base class
CEdit* pEdit = (CEdit*)GetDlgItem(IDC_EDIT1);
ASSERT(pEdit && pEdit->GetSafeHwnd()); if((pEdit->GetSafeHwnd() == pMsg->hwnd) && (WM_KEYDOWN == pMsg->message))
{
if(VK_BACK == pMsg->wParam)
{
CString str;
pEdit->GetWindowText(str);
int start = -1;
int end = -1;
pEdit->GetSel(start, end);
if(end > start)
{
str = str.Mid(start, end - start);
str = str.Left(str.GetLength() - 1);
pEdit->ReplaceSel(str);
pEdit->SetSel(start, end - 1);
return TRUE;
}
}
}
return CDialog::PreTranslateMessage(pMsg);
}
{
if (nChar == VK_BACK)
{
int nSelStart = 0, nSelEnd = 0;
GetSel(nSelStart, nSelEnd);
SetSel(nSelEnd, nSelEnd);
} CEdit::OnChar(nChar, nRepCnt, nFlags);
}
{
// TODO: Add your specialized code here and/or call the base class
CEdit* pEdit = (CEdit*)GetDlgItem(IDC_EDIT1);
ASSERT(pEdit && pEdit->GetSafeHwnd()); if((pEdit->GetSafeHwnd() == pMsg->hwnd) && (WM_KEYDOWN == pMsg->message))
{
pEdit->SetCurSel( -1, -1 );
return TRUE;
}
return CDialog::PreTranslateMessage(pMsg);
}
{
// TODO: Add your specialized code here and/or call the base class
ASSERT(pEdit && pEdit->GetSafeHwnd()); if((GetDlgItem(IDC_EDIT1)->GetSafeHwnd() == pMsg->hwnd) && (WM_KEYDOWN == pMsg->message))
{
if(VK_BACK == pMsg->wParam)
{
return true;
}
}
return CDialog::PreTranslateMessage(pMsg);
}
这样就能去除掉CEdit控件中VK_BACK这个按键了...