原文链接: 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. Mybatis源码分析之Mapper执行SQL过程(三)

    上两篇已经讲解了SqlSessionFactory的创建和SqlSession创建过程.今天我们来分析myabtis的sql是如何一步一步走到Excutor. 还是之前的demo    public  ...

  2. Zoning and LUN Masking

    In a SAN ( Storage Area Network ), if all the hosts are allowed to access all the drives in the SAN, ...

  3. C# 通过SendMessage获取浏览器地址栏的地址

    1:通过SPY++获得地址栏的层次结构,然后一层一层获得 2:代码 using System; using System.Collections.Generic; using System.Linq; ...

  4. 从#!/bin/bash中想到的...

    罪过罪过,开发了N年的SHELL,竟然第一次思考#!/bin/bash是啥意思?真是怀疑以前的的代码是咋开发出来的- 如果要解释#!/bin/bash是啥意思?为啥每个SHELL脚本第一行都写它哪?首 ...

  5. poj - 1191 - 棋盘切割(dp)

    题意:将一个8*8的棋盘(每一个单元正方形有个分值)沿直线(竖或横)割掉一块,留下一块,对留下的这块继续这样操作,总共进行n - 1次,得到n块(1 < n < 15)矩形,每一个矩形的分 ...

  6. Spark的运行模式(1)--Local和Standalone

    Spark一共有5种运行模式:Local,Standalone,Yarn-Cluster,Yarn-Client和Mesos. 1. Local Local模式即单机模式,如果在命令语句中不加任何配置 ...

  7. ps 如何制作动态打字图?

      1.情景展示 有几句话,想以打字的形式出现,而不是干巴巴的几个字,如何实现这个有趣的效果呢? 2.解决方案 第一步:录制屏幕:将想展示的文字逐字打出来-->保存: 第二步:将录制的视频使用p ...

  8. 【转】IP地址、子网掩码、网络号、主机号、网络地址、主机地址以及ip段

    背景知识 IP地址 IP地址被用来当做Internet上的电脑的身份编号.大家日常见到的情况是每台联网的PC上都需要有IP地址,才能正常通信.我们可以把“个人电脑”比作“一台电话”,那么“IP地址”就 ...

  9. P2093 零件分组【贪心算法练习题】

    题目链接: http://codevs.cn/problem/4888/ https://www.luogu.org/problem/show?pid=2093 题目描述 某工厂生产一批棍状零件,每个 ...

  10. Liability

    Liability li·a·bil·i·ty  ˌlīəˈbilədē/   noun A person or thing whose presence or behavior is likely ...