zoukankan
html css js c++ java
古老话题:如何实现应用程序中的”回车”成TAB?
如何实现应用程序中的”回车”成TAB?
其实方法有很多种,但哪一种才是最简洁、最灵活的呢?
下面的方法就是博主最常使用的方法:
一、在你的数据模块中,添加如下代码:
interface 。。。。。。 type TMessageHandler = class //使得回车消息转换成Tab消息 class procedure AppMessage(var Msg:TMsg;var Handled:Boolean); end; implementation class procedure TMessageHandler.AppMessage(var Msg: TMsg; var Handled: Boolean); begin if Msg.message=WM_KEYDOWN then if (Msg.wParam=VK_RETURN ) and ( (Screen.ActiveForm.ActiveControl is TEdit) or (Screen.ActiveForm.ActiveControl is TComboBox) or (Screen.ActiveForm.ActiveControl is TCheckBox) or (Screen.ActiveForm.ActiveControl is TRadioButton) //可以添加需要的控件 ) then begin Msg.wParam:=VK_TAB; end else if (Msg.wParam=VK_RETURN) and ( (Screen.ActiveForm.ActiveControl is TDBGrid) ) then begin with Screen.ActiveForm.ActiveControl do begin if Selectedindex<(FieldCount-1) then Selectedindex:=Selectedindex+1{ 移动到下一字段} else Selectedindex:=0; end; end; end;
二、为了使得整个应用程序都能够实现主要的功能,在主窗体的OnCreate事件中添加如下代码:
procedure TfmMain.FormCreate(Sender: TObject); begin Application.OnMessage:=TMessageHandler.AppMessage; end;
到此为止,你的应用程序已经实现了这个Enter->Tab的转换.
谢祥选【小宇飞刀(xieyunc)】
查看全文
相关阅读:
JAVA错误:Unable to find config file. Creating new servlet engine config file: /WEBINF/serverconfig.wsdd
java axis发布web service(二) 发布web service
JAVA错误:AXIS Web Service Problem: No compiler found in your classpath! (you may need to add ‘tools.jar’)
JAVA错误:java.lang.UnsupportedClassVersionError: Bad version number in .class file
JavaScript中的div和filter错误
拉格朗日乘数法
Timeout Detection & Recovery (TDR)
游戏程序员关心的Autodesk Maya 2013相关操作
Eclipse开发Android程序如何在手机上运行
我的第一篇随笔
原文地址:https://www.cnblogs.com/xieyunc/p/2793625.html
最新文章
Post提交数据到接口或网址 获取返回数据
Jquery Uploadify多文件上传带进度条 且传递自己的参数示例
JS复制网页内容,JS获取FCK编辑器的值
MSSQL数据导入导出基本方法
C#创建数据库 附加数据库等操作
微软官方提供Northwind(电子商务)数据库设计
sqlplus中不能上下键选择前一条命令解决方法
Oracle reset初始化参数
ORA01012 not logged on
rman连接AUXILIARY报错ORA12528
热门文章
SCOPE 中 SPFILE、MEMORY、BOTH 的小小区别
Oracle的监听常用命令
配置监听样本
11gR2 Restart Database SRVCTL启动DB报ORA01031: insufficient privileges
Xshell连接Linux下Oracle无法回退的解决办法
[RAC Clusterware] ora01506错误(转)
JAVA错误:could not find class javax.activation.DataHandler from file activation.jar
JAVA错误:java.sql.SQLException: [Microsoft][ODBC Microsoft Access 驱动程序] 磁盘或网络错误。
java axis发布web service(三) 调用web service
解决Eclipse中ISO88591 字符集的方法
Copyright © 2011-2022 走看看