Delphi 2010 新增功能之: 手势编程[2] - 通过 OnGesture 识别手势
2009-10-21 11:02
267 查看
本例尝试在 OnGesture 事件中响应 sgLeft、sgRight 手势; 操作步骤:
1、加 TGestureManager 控件如窗体: GestureManager1;
2、设置窗体属性 Touch.GestureManager := GestureManager1;
3、添加窗体的 OnCreate 事件, 写: Touch.StandardGestures := [sgLeft, sgRight];
4、添加窗体的 OnGesture 事件, 写响应代码.
上面的步骤 3 的目的是指定准备要接受识别的动作, 这在设计时选定比较方便:
![](http://images.cnblogs.com/cnblogs_com/del/214030/o_09102101.png)
测试代码:
1、加 TGestureManager 控件如窗体: GestureManager1;
2、设置窗体属性 Touch.GestureManager := GestureManager1;
3、添加窗体的 OnCreate 事件, 写: Touch.StandardGestures := [sgLeft, sgRight];
4、添加窗体的 OnGesture 事件, 写响应代码.
上面的步骤 3 的目的是指定准备要接受识别的动作, 这在设计时选定比较方便:
![](http://images.cnblogs.com/cnblogs_com/del/214030/o_09102101.png)
测试代码:
unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, GestureMgr; type TForm1 = class(TForm) GestureManager1: TGestureManager; procedure FormCreate(Sender: TObject); procedure FormGesture(Sender: TObject; const EventInfo: TGestureEventInfo; var Handled: Boolean); end; var Form1: TForm1; implementation {$R *.dfm} procedure TForm1.FormCreate(Sender: TObject); begin Touch.StandardGestures := [sgLeft, sgRight]; end; procedure TForm1.FormGesture(Sender: TObject; const EventInfo: TGestureEventInfo; var Handled: Boolean); begin case EventInfo.GestureID of sgiLeft : ShowMessage('Left'); sgiRight : ShowMessage('Right'); end; end; end.
相关文章推荐
- Delphi 2010 新增功能之: 手势编程[4] - 关于 OnGesture 事件过程的参数
- Delphi 2010 新增功能之: 手势编程[5] - 关于自定义手势
- Delphi 2010 新增功能之: 手势编程[3] - 直接给某个手势指定动作
- Delphi 2010 新增功能之: 手势编程[1] - 初识 TGestureManager
- Delphi 2010 新增功能之: IOUtils 单元(6): TPath(结构体) 的方法与属性
- Delphi 2010 新增功能之: IOUtils 单元(6): TPath(结构体) 的方法与属性
- Delphi 2010 新增功能之: IOUtils 单元(2): TDirectory.TFilterPredicate
- Delphi 2010 新增功能之: IOUtils 单元(6): TPath(结构体) 的方法与属性
- Delphi 2010 新增功能之: IOUtils 单元(1): 初识 TDirectory.GetFiles
- Delphi 2010 新增功能之: TWICImage 类[1] - 方便的图像格式转换
- Delphi 2010 新增功能之: TWICImage 类[2] - 图像的旋转变换
- Delphi 2010 新增功能之: IOUtils 单元
- [转] Delphi 2010 新增功能之: IOUtils 单元: TDirectory.TFilterPredicate
- Delphi 2010 新增功能之: IOUtils 单元
- Delphi 2010 新增功能之: 软键盘、触摸键盘(TTouchKeyboard)
- Delphi 2010 新增功能之: Rtti 单元(3): TRttiOrdinalType
- Delphi 2010 新增功能之: IOUtils 单元(5): TDirectory 的其他功能
- Delphi 2010 新增功能之: TWICImage 类[1] - 方便的图像格式转换
- Delphi 2010 新增功能之: IOUtils 单元(4): TDirectory.GetDirectories
- Delphi 2010 新增功能之: Rtti 单元(5): 获取方法的更多信息