Delphi 2010 新增功能之: 手势编程[3] - 直接给某个手势指定动作
2009-10-21 11:20
239 查看
除了通过 OnGesture 事件识别手势, 还可以直接个某个手势指定动作.
这需要用到: TActionList 或 TActionManager; 本例用了 TActionList.
操作步骤:
1、给窗体添加并关联 TGestureManager, 还要添加 TActionList;
2、给动作关联 Action:
![](http://images.cnblogs.com/cnblogs_com/del/214030/o_09102102.png)
3、给 Action 写代码.
代码文件:
窗体文件:
这需要用到: TActionList 或 TActionManager; 本例用了 TActionList.
操作步骤:
1、给窗体添加并关联 TGestureManager, 还要添加 TActionList;
2、给动作关联 Action:
![](http://images.cnblogs.com/cnblogs_com/del/214030/o_09102102.png)
3、给 Action 写代码.
代码文件:
unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, GestureMgr, ActnList; type TForm1 = class(TForm) GestureManager1: TGestureManager; ActionList1: TActionList; Action1: TAction; Action2: TAction; procedure Action1Execute(Sender: TObject); procedure Action2Execute(Sender: TObject); end; var Form1: TForm1; implementation {$R *.dfm} procedure TForm1.Action1Execute(Sender: TObject); begin ShowMessage('Left'); end; procedure TForm1.Action2Execute(Sender: TObject); begin ShowMessage('Right'); end; end.
窗体文件:
object Form1: TForm1 Left = 0 Top = 0 Caption = 'Form1' ClientHeight = 206 ClientWidth = 339 Color = clBtnFace Font.Charset = DEFAULT_CHARSET Font.Color = clWindowText Font.Height = -11 Font.Name = 'Tahoma' Font.Style = [] OldCreateOrder = False Touch.GestureManager = GestureManager1 PixelsPerInch = 96 TextHeight = 13 object GestureManager1: TGestureManager Left = 128 Top = 88 GestureData = < item Control = Owner Collection = < item Action = Action1 GestureID = sgiLeft end item Action = Action2 GestureID = sgiRight end> end> end object ActionList1: TActionList Left = 224 Top = 136 object Action1: TAction Caption = 'Action1' OnExecute = Action1Execute end object Action2: TAction Caption = 'Action2' OnExecute = Action2Execute end end end
相关文章推荐
- Delphi 2010 新增功能之: 手势编程[5] - 关于自定义手势
- Delphi 2010 新增功能之: 手势编程[1] - 初识 TGestureManager
- Delphi 2010 新增功能之: 手势编程[2] - 通过 OnGesture 识别手势
- Delphi 2010 新增功能之: 手势编程[4] - 关于 OnGesture 事件过程的参数
- Delphi 2010 新增功能之: Rtti 单元(1)
- Delphi 2010 新增功能之: IOUtils 单元(6): TPath(结构体) 的方法与属性
- Delphi 2010 新增功能之: IOUtils 单元
- Delphi 2010 新增功能之: Rtti 单元(5): 获取方法的更多信息
- Delphi 2010 新增功能之: Rtti 单元(5): 获取方法的更多信息
- Delphi 2010 新增功能之: IOUtils 单元(5): TDirectory 的其他功能
- Delphi 2010 新增功能之: TWICImage 类[2] - 图像的旋转变换
- Delphi 2010 新增功能之: TWICImage 类[4] - 图像的修剪
- Delphi 2010 新增功能之: IOUtils 单元(7): TFile 结构的功能
- Delphi 2010 新增功能之: IOUtils 单元(6): TPath(结构体) 的方法与属性
- Delphi 2010 新增功能之: IOUtils 单元(7): TFile 结构的功能
- Delphi 2010 新增功能之: IOUtils 单元(6): TPath(结构体) 的方法与属性
- Delphi 2010 新增功能之: Rtti 单元(3): TRttiOrdinalType
- Delphi 2010 新增功能之: IOUtils 单元(3): TDirectory.GetFiles 支持通配符
- Delphi 2010 新增功能之: IOUtils 单元(2): TDirectory.TFilterPredicate
- Delphi 2010 新增功能之: IOUtils 单元(7): TFile 结构的功能