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)】
查看全文
相关阅读:
Redis宣言
软件工程
分布式编程
编程泛型
tcp/ip高效编程总结
IP协议详解
gevent程序员指南
网站架构
这些话,是乔布斯给世间留下的真正伟大礼物
Flink/Spark 如何实现动态更新作业配置
原文地址:https://www.cnblogs.com/xieyunc/p/2793625.html
最新文章
Node.js——req、res对象
Node.js——请求头
Node.js——路径问题
Node.js——npm
Node.js——require加载规则
Node.js——优先从缓存加载
HTML5——动画延迟的另外一种方式
HTML5——loading
如何在C++中的Map或Set中修改Key值
RGB and YUV
热门文章
Unraveling the JPEG file
std::ref() 与 &
深度探索二维码及其应用
BCH code
C++ Timer
用IDM下载博客图片
请求一个域名ip的缓存用处
实现一个简单的代码字计数器(三)
软件工程
互联网应用的状态线程库
Copyright © 2011-2022 走看看