网页功能: 加入收藏 设为首页 网站搜索  
如何实现应用程序中的”回车”成TAB
发表日期:2003-03-16作者:wangzn1979[] 出处:  

也就是说当按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的转换.

我来说两句】 【加入收藏】 【返加顶部】 【打印本页】 【关闭窗口
中搜索 如何实现应用程序中的”回车”成TAB
本类热点文章
  DBGrid 应用全书
  DBGrid 应用全书
  TWebBrowser编程简述
  用户界面设计的技巧与技术
  用户界面设计的技巧与技术
  初探Delphi 7 中的插件编程
  获取主板BIOS的信息
  网卡的远程网络唤醒
  Delphi 2006简介(Dexter)
  用Delphi开发数据库程序经验三则
  Delphi面向对象编程的20条规则
  Delphi面向对象编程的20条规则
最新分类信息我要发布 
最新招聘信息

关于我们 / 合作推广 / 给我留言 / 版权举报 / 意见建议 / 广告投放  
Copyright ©2003-2024 Lihuasoft.net webmaster(at)lihuasoft.net
网站编程QQ群   京ICP备05001064号 页面生成时间:0.00478