如何让delphi 手势老程序支持手势

Delphi&XE7学习笔记一(TabControl+ActionList+手势动作控制)
Delphi XE7几乎每个VCL控件都有Touch属性,在这里可以自定义手机或平板的手势操作。
但根据网上介绍和自我理解,在设置标准手势时,提示错误,不知自己是否哪里设置有问题
---------------------日更新解决办法---------------------------------------
在一次偶然的情况下,得知解决办法,时候查看资料放得要领,具体操作如下
按照网上资料显示一步一步操作本应该是不会出现这个问题,只因加入自己的片面理解,才产生了这类问题
1、在窗体中放入TActionList、TGestureManager、两个TButton、TTabControl控件
2、双击TActionList控件,新增Standard
Action,选取TNextTabAction和TPreviousTabAction,并指定TabConrol属性为TabControl1
3、将NextTabAction1和PreviousTabAction1指定给两个TButton控件的Action属性,此步骤意思是将上一页和下一页的Action事件指定给Button,这样不需要自己在Button事件下编写换页代码(TActionList控件使用方法及介绍请百度),这一步很重要,不指定到Button上,在手势操作的时候就会出现上图的错误,本人也是后来才想明白这个道理,我们刚刚添加的两个标准事件,只是引用,并未使用定义及使用,所以IDE并未创建相关对象,当我们指定到Button的时候,IDE才创建了事件对象,所以才可以在手势上直接调用,这只是我的理解,感觉应该是这么回事,不知道真正原理,不管怎样按照这么操作至少没有错误
4、选取TabControl1控件,找到Touch-GestureManager属性,双击选取GestureManager1
5、点击Gesture-Standard属性,这里Delphi给出34种标准手势,具体每种手势代表什么意思,不明白的请百度,这里我只用到Left和Right两种手势,分别将NextTabAction1和PreviousTabAction1给Left和Right赋值
至此就完成了手势+Action切换页面的设置,程序可以运行看效果。
已投稿到:
以上网友发言只代表其个人观点,不代表新浪网的观点或立场。随笔 - 2146&
文章 - 96&评论 - 11719&trackbacks - 253
除了通过 OnGesture 事件识别手势, 还可以直接个某个手势指定动作.
这需要用到: TActionList 或 TActionM 本例用了 TActionList.
1、给窗体添加并关联 TGestureManager, 还要添加 TActionL
2、给动作关联 Action:
3、给 Action 写代码.
unit Unit1;
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, GestureMgr, ActnL
TForm1 = class(TForm)
GestureManager1: TGestureM
ActionList1: TActionL
Action1: TA
Action2: TA
procedure Action1Execute(Sender: TObject);
procedure Action2Execute(Sender: TObject);
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Action1Execute(Sender: TObject);
ShowMessage('Left');
procedure TForm1.Action2Execute(Sender: TObject);
ShowMessage('Right');
object Form1: TForm1
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
GestureData = <
Control = Owner
Collection =
object ActionList1: TActionList
Left = 224
object Action1: TAction
Caption = 'Action1'
OnExecute = Action1Execute
object Action2: TAction
Caption = 'Action2'
OnExecute = Action2Execute
阅读(...) 评论()随笔 - 651&
文章 - 41&评论 - 6&trackbacks - 0
delphi手势,左右滑动,
控件的OnGesture事件写代码。
放一个TGestureManager控件,设置控件的touch属性为TGestureManager控件。
然后勾选控件的Touch&Gestures&Standard&里的手势类型,left,right,up,down等等,然后在OnGesture事件就可以捕捉到了。
官方的手势图
/RADStudio/Berlin/en/TStandardGesture_Enum
FieldDescription
The ID of the gesture that is emitted. ID is an integer value uniquely identifying the gesture.
The current point on the control's surface. Location contains the X and Y coordinates of the last known point.
options describing the state of the interactive gesture. Flags is only valid if the gesture is interactive.
The angle in radians (rad) in which either the finger or a gesturing device has moved relative to the screen coordinates.
Angle is only set for the rotation gesture (TInteractiveGesture = Rotate):
Angle is negative if rotation is clockwise.
Angle is positive if rotation is counter-clockwise.
The distance in pixels from the current point, given by Location, and the previous point.
Distance is only set for the zoom and two finger tap gestures (TInteractiveGesture = Zoom or TwoFingerTap). Distance is the distance between the two fingers or gesturing devices that are making the gesture.
InertiaVector
The inertia speed given by an X and Y pair. A positive X value means inertia toward the right of the screen, while a negative value means inertia to the left. A positive Y value means inertia toward the bottom of the screen, while a negative value means inertia to the top. InertiaVector is only valid if the event is interactive.
TapLocation
Specifies the coordinates of the "tap" and "press and tap" (igPressAndTap) gestures.
procedure TForm1.GridPanelLayout1Gesture(Sender: TO
const EventInfo: TGestureEventI var Handled: Boolean);
case EventInfo.GestureID of
sgiRight://向右滑动
case EventInfo.GestureID of
if TabControl1.ActiveTab && TabControl1.Tabs[TabControl1.TabCount - 1] then
TabControl1.ActiveTab := TabControl1.Tabs[TabControl1.TabIndex + 1];
Handled := T
if TabControl1.ActiveTab && TabControl1.Tabs[0] then
TabControl1.ActiveTab := TabControl1.Tabs[TabControl1.TabIndex - 1];
Handled := T
procedure TTabbedwithNavigationForm.FormKeyUp(Sender: TO var Key: W var KeyChar: C Shift: TShiftState);
if Key = vkHardwareBack then
if (TabControl1.ActiveTab = TabItem1) and (TabControl2.ActiveTab = TabItem6) then
TabControl2.P
touch与mouseup事件,先出发mouseUp事件,然后才触发ontouch事件。
阅读(...) 评论()}

我要回帖

更多关于 delphi 关闭程序 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信