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)】
查看全文
相关阅读:
体温填报APP--体温填报
体温填报APP--主界面设计
剑指Offer_#60_n个骰子的点数
剑指Offer_#56-II_ 数组中数字出现的次数II
剑指Offer_#56-I_数组中数字出现的次数
剑指Offer_#55
用Python从头开始构建神经网络
使用RetinaNet构建的人脸口罩探测器
如何利用PyTorch中的Moco-V2减少计算约束
TF2目标检测API
原文地址:https://www.cnblogs.com/xieyunc/p/2793625.html
最新文章
25 实战页式内存管理 中
每日总结
每日总结
每日总结
每日总结
每日总结
每日总结
每日总结
每日总结
每日总结
热门文章
每日总结
PyTorch指定GPU
构建之法阅读笔记(二)
体温填报APP--地图显示位置信息
体温填报APP--地图显示位置信息
体温填报APP--使用echarts显示数据
体温填报APP--个人14天体温表
体温填报APP--查看所有体温录入情况
体温填报APP--切换用户
体温填报APP--新增用户
Copyright © 2011-2022 走看看