原文链接: http://computer-programming-forum.com/81-vc/c92ab6e6d6ac92bc.htm

楼主

How to handle the return key on a ClistCtrl ? I've tried to intercept 
the LVN_KEYDOWN message but the Return key is not handled !!! I've also 
tried to intercept the NM_RETURN message but it doesn't work 
Thanks in advance. 
O.Ferrandiz

2楼

You need to override PreTranslateMessage to trap the WM_KEYDOWN(VK_RETURN) 
message like so:

BOOL 
CListCtrlEx::PreTranslateMessage(MSG* pMsg) 

  if (((GetStyle() & LVS_EDITLABELS) == 0) || (pMsg->message != WM_KEYDOWN) 
|| (pMsg->wParam != VK_RETURN)) 
    return CListCtrl::PreTranslateMessage(pMsg);

// Send the message on to the control 
  DispatchMessage(pMsg); 
  return TRUE;

}

Note that you don't need to call TranslateMessage() if you only need the 
WM_KEYDOWN message, as that function only causes a WM_CHAR(VK_RETURN) 
message to be sent to your handler.  Now you'll get the WM_NOTIFY(NM_RETURN) 
messages.

CListCtrl的LVN_KEYDOWN事件中怎么捕捉不到回车键?的更多相关文章

  1. 在Application_Error事件中获取当前的Action和Control

    ASP.NET MVC程序处理异常时,方法有很多,网上也有列举了6种,下面是使用全局处理在Global.asax文件的Application_Error事件中实现.既然是ASP.NET MVC,我需要 ...

  2. Direcshow中视频捕捉和参数设置报告

    Direcshow中视频捕捉和参数设置报告 1.      关于视频捕捉(About Video Capture in Dshow) 1视频捕捉Graph的构建 一个能够捕捉音频或者视频的graph图 ...

  3. Direcshow中视频捕捉和參数设置报告

    Direcshow中视频捕捉和參数设置报告 1.      关于视频捕捉(About Video Capture in Dshow) 1视频捕捉Graph的构建 一个能够捕捉音频或者视频的graph图 ...

  4. touch事件中的touches、targetTouches和changedTouches详解

    touches: 当前屏幕上所有触摸点的列表; targetTouches: 当前对象上所有触摸点的列表; changedTouches: 涉及当前(引发)事件的触摸点的列表 通过一个例子来区分一下触 ...

  5. 功能源代码(扇形进度)及Delegate运用在开放事件中、UINavigationController的封装

    1:扇形进度视图及运用 首先先创建扇形的视图,传入进度值 #import <UIKit/UIKit.h> @interface LHProgressView : UIView @prope ...

  6. DOM - 5.事件冒泡 + 6.事件中的this

    5.事件冒泡 如果元素A嵌套在元素B中,那么A被点击不仅A的onclick事件会被触发,B的onclick也会被触发.触发的顺序是"由内而外" .验证:在页面上添加一个table. ...

  7. flex loaderInfo为null在creationComplete事件中

    原文: http://yunzhongxia.iteye.com/blog/1152670   Flex4中application变为FlexGlobals.topLevelApplication,很 ...

  8. ASPxTreeList控件去根节点的新增修改操作(写在onCommandColumnButtonInitialize()事件中)

    treelist去掉根节点按钮效果图: //去掉父节点及子节点旁的新增.修改.删除操作(写在onCommandColumnButtonInitialize事件中) protected void Tre ...

  9. ListView与.FindControl()方法的简单练习 #2 -- ItemUpdting事件中抓取「修改后」的值

    原文出處  http://www.dotblogs.com.tw/mis2000lab/archive/2013/06/24/listview_itemupdating_findcontrol_201 ...

随机推荐

  1. SpringBoot报错 : Whitelabel Error Page

    添加了一个Controller类,本来想试下Spring MVC是否可以正常运行,结果报错,Controller类的内容: @RestController public class Test1Cont ...

  2. jQuery函数的等价原生函数代码示例

    选择器 jQuery的核心之一就是能非常方便的取到DOM元素.我们只需输入CSS选择字符串,便可以得到匹配的元素.但在大多数情况下,我们可以用简单的原生代码达到同样的效果. .代码如下: //---- ...

  3. APP测试体系

    网上找的图片,总结的很好:

  4. 使用Spring框架入门一:基于XML配置的IOC/DI的使用

    一.Spring框架 1.方法一:逐项导入基础依赖包: spring-core.spring-beans.spring-context.spring-expression 2.方法二:最简洁的导入,直 ...

  5. scala 基础语法

    文章内容全部来自:http://twitter.github.io/scala_school/zh_cn/index.html 表达式 scala> 1 + 1 res0: Int = 2 值 ...

  6. hadoop-处理小文件

    一个Hadoop程序的优化过程 – 根据文件实际大小实现CombineFileInputFormat http://www.rigongyizu.com/hadoop-job-optimize-com ...

  7. Sqoop拒绝连接错误

    使用Sqoop远程连接MySQL导入数据到HBase数据库: sqoop import --driver com.mysql.jdbc.Driver --connect "jdbc:mysq ...

  8. mysql 备份还原

    1.文件备份 2.dump mysqldump -h 192.168.102.73 -uroot -p123456 edc >/webapp/edcapp/edc.sql       mysql ...

  9. DWR组件——基于远程过程调用实现Ajax

    转载请注明原文地址:http://www.cnblogs.com/ygj0930/p/6686115.html  一:DWR的用途 DWR(Direct Web Remoting)是一个Web远程调用 ...

  10. 视频转换ffmpeg

    使用yum在centos下安装ffmpeg   ffmpeg -i IMG_1893.MOV -ab 56 -ar 22050 -b 500 -r 15 -s 640x480 test.mp4   说 ...