获取全选(ctrl-a)以在CEdit控件上工作 [英] Getting select all(ctrl-a) to work on a CEdit control

查看:130
本文介绍了获取全选(ctrl-a)以在CEdit控件上工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在CEdit控件中实现全选(通过ctrl-a).我这样做是通过创建一个继承CEdit的类并为WM_KEYDOWN添加一个处理程序,如下所示:

I am trying to implement select all(via ctrl-a) in a CEdit control. I'm doing this by making a class which inherits CEdit and adding a handler for WM_KEYDOWN like this:

void CEditExtended::OnKeyDown( UINT nChar, UINT nRepCnt, UINT nFlags )
{   
  if((nChar == 0x41) && (GetKeyState(VK_CONTROL) & 0x8000) != 0))
    SetSel(0, -1);

  CEdit::OnKeyDown(nChar, nRepCnt, nFlags);
}

这可以在网上四处浏览,但是它永远不会同时注册ctrl和a,两者都不能注册.

Looking around on the web, this should work, but it never registers both ctrl and a at the same time, either one or the other.

推荐答案

尝试以下代码:

void CEditExtended::PreTranslateMessage(MSG* pMsg)
{
 if(pMsg->message == WM_KEYUP )
    {
        if ( (LOWORD(pMsg->wParam) & VK_CONTROL) == VK_CONTROL )
        {

         /// blah

        }
    }

    return CEdit::PreTranslateMessage(pMsg);
}

这篇关于获取全选(ctrl-a)以在CEdit控件上工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆