- 热门文章:
- · 用Ehlib二次开发报表打印程序,实现财务凭证的打印(三)
- · 如何在Delphi应用程序中调用CHM文档
- · 在Delphi里调用API函数动态建立ODBC数据源。
- · 图像分割的一些简单实现
- · windwos 2000及NT 服务注册的具体实现
- · 在Delphi中动态生成QuickReport报表
- · Delphi与Lex、Yacc (一) 安装篇
- · 用程序删除已注册的COM+应用程序
- · Delphi5的水晶报表控件在Delphi6下的安装过程
- · TFontNameComboBox及TFontSizeComboBox的实现
- · VCL消息处理机制的内幕
- · 如何防止密码框的密码被人破译
如何实现应用程序中的”回车”成TAB?
如何实现应用程序中的”回车”成TAB?
也就是说当按Enter键的时候,产生的效果是按了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的转换.
- · Delphi编码标准——一般的源代码格式规则
- · Delphi编码标准——过程和函数
- · Delphi编码标准——文件命名
- · Delphi编码标准——窗体与数据模块命名
- · Delphi编码标准——包命名
- · Delphi编码标准——组件命名
- · 编写一个单独的Web Service for Delphi7(步骤)
- · 有关TDataSet的研究
- · Octane和Delphi Q&A – 由Anders Ohlsson撰写
- · 给Delphi社群的公开信
- · 在Delphi技巧实现权限管理
- · Delphi程序与Chm帮助关联的简单实现
- · 运行期间生成代码的动态执行
- · 使用静态数组应该注意的问题
- · Delphi面向对象编程的20条规则(By Marco Cantu)(前言)
- · Delphi面向对象编程的20条规则(By Marco Cantu)(rule 1-10)
- · 用程序设置COM+应用程序的属性。
- · Simple Programming Tip #1 by Charlie Calvert
- · 用API实现在MSN的信息提示
- · Delphi面向对象编程的20条规则(By Marco Cantu)(rule 11-15)
- · Delphi 完全时尚手册之 Visual Style 篇---使非标准 Win32 控件或自画控件也具有 Windows XP 的界面风格
- · 类和对象
- · Delphi面向对象编程的20条规则(By Marco Cantu)(rule 16-20)
- · 资源文件的创建与使用
- · DirectShow之接口实战篇(一)
- · DirectShow之接口实战篇(二)
- · DirectShow之接口实战篇(三)
- · 在Delphi中进行指纹仪的二次开发
- · Introduction to Indy (转载)
- · 通过原代码学习TComponent类的机制(1)
- · ModelMaker 新手起步(一)
- · Borland® JBuilder™ 7 与 IBM® WebSphere® 4.0 整合配置指南(1)
- · delphi一句话帮助
- · Delphi的组件读写机制(一)
- · Delphi的组件读写机制(二)
- · Delphi的组件读写机制(三)
- · 使用XMLDocment遍历CSDN论坛帖子回复
- · 使用ClientSocket控件实现CSDN论坛帖子的自动回复
