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)】
查看全文
相关阅读:
基本语句
mysql多表查询方法(join)
MySQL JOIN 多表连接
MySQL SHOW INDEX语法的实际应用
1.索引作用
MySQL索引和优化查询
mysql复合索引、普通索引总结
mysql 索引相关
for循环的break和continue
保护程序猿滴眼睛---修改VS 2012 编辑器颜色
原文地址:https://www.cnblogs.com/xieyunc/p/2793625.html
最新文章
a4纸尺寸像素大小
IIS DirectoryEntry
C#添加IIS站点
http错误代码
foreach和for循环的区别
利用C#查看特定服务是否安装
NET中IL指令详解
一步一步教你读懂NET中IL
.NET计时器的使用-Stopwatch类
看完前任三,想起我的前任java女程序员,她曾教会我……
热门文章
细思极恐-你真的会写java吗
细思极恐-你真的会写java吗
细思极恐-你真的会写java吗
细思极恐-你真的会写java吗
为Java程序员金三银四精心挑选的五十道面试题与答案
一名十年Java程序员回忆阿里面试经历——揭开阿里面试的“遮羞布”
细思极恐-你真的会写java吗
圣诞节为大家推荐一些学习java书籍
java未来发展方向!新手入门了解
php中的__construct()作用
Copyright © 2011-2022 走看看