GESTURECONFIG 结构与CGestureConfig类

CGestureConfig类是对GESTURECONFIG结构体的封装,从CObject类派生而来,是为了简化操作过程,为了更方便的使用,详细内容参考后面的GESTURECONFIG说明,具体代码如下:

/// <summary>
/// CGestureConfig class allows to customize Windows gesture features such as zoom, pan or rotate. This class is used in CWnd::SetGestureConfig and CWnd::GetGestureConfig methods.</summary>
class CGestureConfig : public CObject
{
	friend class CWnd;

public:
	/// <summary>
	/// CGestureConfig constructor</summary>
	CGestureConfig();

	/// <summary>
	/// CGestureConfig destructor</summary>
	virtual ~CGestureConfig();

	/// <summary>
	/// Enable/disable gesture zoom</summary>
	/// <param name="bEnable">TRUE - enable the feature. FALSE - disable it</param>
	void EnableZoom(BOOL bEnable = TRUE);

	/// <summary>
	/// Enable/disable gesture rotate</summary>
	/// <param name="bEnable">TRUE - enable the feature. FALSE - disable it</param>
	void EnableRotate(BOOL bEnable = TRUE);

	/// <summary>
	/// Enable/disable gesture 2 finger tap</summary>
	/// <param name="bEnable">TRUE - enable the feature. FALSE - disable it</param>
	void EnableTwoFingerTap(BOOL bEnable = TRUE);

	/// <summary>
	/// Enable/disable gesture press and tap</summary>
	/// <param name="bEnable">TRUE - enable the feature. FALSE - disable it</param>
	void EnablePressAndTap(BOOL bEnable = TRUE);

	/// <summary>
	/// Enable/disable gesture pan</summary>
	/// <param name="bEnable">TRUE - enable the feature. FALSE - disable it</param>
	/// <param name="dwFlags">Gesture pan flags. Can be either GC_PAN (all pan gestures) or combination of the following flags: GC_PAN_WITH_SINGLE_FINGER_VERTICALLY, GC_PAN_WITH_SINGLE_FINGER_HORIZONTALLY, GC_PAN_WITH_GUTTER and GC_PAN_WITH_INTERTIA</param>
	void EnablePan(BOOL bEnable = TRUE, DWORD dwFlags = GC_PAN_WITH_GUTTER | GC_PAN_WITH_INERTIA);

	/// <summary>
	/// Determines whether the gesture zoom feature is enabled</summary>
	/// <returns> 
	/// TRUE if the feature is enabled; otherwise FALSE.</returns>
	BOOL IsZoomEnabled() const { return (Get(GID_ZOOM) & GC_ZOOM) == GC_ZOOM; }

	/// <summary>
	/// Determines whether the gesture rotate feature is enabled</summary>
	/// <returns> 
	/// TRUE if the feature is enabled; otherwise FALSE.</returns>
	BOOL IsRotateEnabled() const { return (Get(GID_ROTATE) & GC_ROTATE) == GC_ROTATE; }

	/// <summary>
	/// Determines whether the gesture 2 finger tap feature is enabled</summary>
	/// <returns> 
	/// TRUE if the feature is enabled; otherwise FALSE.</returns>
	BOOL IsTwoFingerTapEnabled() const { return (Get(GID_TWOFINGERTAP) & GC_TWOFINGERTAP) == GC_TWOFINGERTAP; }

#if defined(GID_PRESSANDTAP) && defined(GC_PRESSANDTAP)
	/// <summary>
	/// Determines whether the gesture "press and tap" feature is enabled</summary>
	/// <returns> 
	/// TRUE if the feature is enabled; otherwise FALSE.</returns>
	BOOL IsPressAndTapEnabled() const { return (Get(GID_PRESSANDTAP) & GC_PRESSANDTAP) == GC_PRESSANDTAP; }
#endif

	/// <summary>
	/// Determines whether the gesture pan feature is enabled</summary>
	/// <returns> 
	/// TRUE if the feature is enabled; otherwise FALSE.</returns>
	BOOL IsPanAllEnabled() const { return (Get(GID_PAN) & GC_PAN) == GC_PAN; }

	/// <summary>
	/// Determines whether the gesture pan vertical feature is enabled</summary>
	/// <returns> 
	/// TRUE if the feature is enabled; otherwise FALSE.</returns>
	BOOL IsPanVerticalEnabled() const { return (Get(GID_PAN) & GC_PAN_WITH_SINGLE_FINGER_VERTICALLY) == GC_PAN_WITH_SINGLE_FINGER_VERTICALLY; }

	/// <summary>
	/// Determines whether the gesture pan horizontal feature is enabled</summary>
	/// <returns> 
	/// TRUE if the feature is enabled; otherwise FALSE.</returns>
	BOOL IsPanHorizontalEnabled() const { return (Get(GID_PAN) & GC_PAN_WITH_SINGLE_FINGER_HORIZONTALLY) == GC_PAN_WITH_SINGLE_FINGER_HORIZONTALLY; }

	/// <summary>
	/// Determines whether the gesture pan with gutter feature is enabled</summary>
	/// <returns> 
	/// TRUE if the feature is enabled; otherwise FALSE.</returns>
	BOOL IsPanWithGutterEnabled() const { return (Get(GID_PAN) & GC_PAN_WITH_GUTTER) == GC_PAN_WITH_GUTTER; }

	/// <summary>
	/// Determines whether the gesture pan with inertia feature is enabled</summary>
	/// <returns> 
	/// TRUE if the feature is enabled; otherwise FALSE.</returns>
	BOOL IsPanWithInertiaEnabled() const { return (Get(GID_PAN) & GC_PAN_WITH_INERTIA) == GC_PAN_WITH_INERTIA; }

	/// <summary>
	/// Modify specific gesture touch paramaters</summary>
	/// <returns> 
	/// TRUE if succeeds; otherwise FALSE.</returns>
	/// <param name="dwID">Gesture feature ID. Can be one of the following: GID_ZOOM, GID_PAN, GID_ROTATE, GID_TWOFINGERTAP or GID_PRESSANDTAP</param>
	/// <param name="dwWant">Gesture features to enable. Can be 0 or GC_ALLGESTURES for all features except GID_PAN and GC_PAN or combination of the following flags: GC_PAN_WITH_SINGLE_FINGER_VERTICALLY, GC_PAN_WITH_SINGLE_FINGER_HORIZONTALLY, GC_PAN_WITH_GUTTER and GC_PAN_WITH_INTERTIA for gesture pan</param>
	BOOL Modify(DWORD dwID, DWORD dwWant = GC_ALLGESTURES, DWORD dwBlock = 0);

	/// <summary>
	/// Obtains a specific gesture touch paramaters</summary>
	/// <returns> 
	/// Gesture features. Can be 0 or GC_ALLGESTURES for all features except GID_PAN and GC_PAN or combination of the following flags: GC_PAN_WITH_SINGLE_FINGER_VERTICALLY, GC_PAN_WITH_SINGLE_FINGER_HORIZONTALLY, GC_PAN_WITH_GUTTER and GC_PAN_WITH_INTERTIA for gesture pan</returns>
	/// <param name="dwID">Gesture feature ID. Can be one of the following: GID_ZOOM, GID_PAN, GID_ROTATE, GID_TWOFINGERTAP or GID_PRESSANDTAP</param>
	/// <param name="bWant">TRUE - the method returns the enabled features; FALSE - disabled</param>
	DWORD Get(DWORD dwID, BOOL bWant = TRUE) const;

#ifdef _DEBUG
	virtual void Dump(CDumpContext& dc) const;
#endif

protected:
	PGESTURECONFIG m_pConfigs;
	int	m_nConfigs;
};

以下是对GESTURECONFIG的详细说明。

获取和设置用于启用笔势消息的配置以及此配置的类型。

语法

typedef struct _GESTURECONFIG {
  DWORD dwID;
  DWORD dwWant;
  DWORD dwBlock;
} GESTURECONFIG, *PGESTURECONFIG;

成员

dwID

将启用或禁用消息的配置类型的标识符。有关更多信息,请参见“备注”。

dwWant

要启用的消息。

dwBlock

要禁用的消息。

评论

无法禁用双指平移并保留单指平移。必须先为 GC_PAN 设置所需的位,然后才能为 GC_PAN_WITH_SINGLE_FINGER_HORIZONTALLY 或 GC_PAN_WITH_SINGLE_FINGER_VERTICALLY 设置它们。

如果已通过调用 SetGestureConfig 来禁用延时,则带 GF_END 标志的 GID_PAN 消息中将包含延时矢量。

当传递此结构时,dwID 成员将包含有关一组笔势的信息。这将确定其他标志的含义。如果为平移消息设置标志,则这些标志将与为旋转消息设置的标志不同。

下表指示 GESTURECONFIG 结构的 dwID 成员支持的笔势的各种标识符。请注意,若将 dwID 设置为 0,则指示设置全局笔势配置标志。

名称说明
GID_ZOOM3指示缩放笔势的配置设置。
GID_PAN4指示平移笔势。
GID_ROTATE5指示旋转笔势。
GID_TWOFINGERTAP6指示双指点击笔势。
GID_PRESSANDTAP7指示按住并点击笔势。

 

当 dwID 设置为 0 时使用以下标志。

名称说明
GC_ALLGESTURES0x00000001指示所有笔势。

 

当 dwID 设置为 GID_ZOOM 时使用以下标志。

名称说明
GC_ZOOM0x00000001指示缩放笔势。

 

当 dwID 设置为 GID_PAN 时使用以下标志。

名称说明
GC_PAN0x00000001指示所有平移笔势。
GC_PAN_WITH_SINGLE_FINGER_VERTICALLY0x00000002指示单指垂直平移。
GC_PAN_WITH_SINGLE_FINGER_HORIZONTALLY0x00000004指示单指水平平移。
GC_PAN_WITH_GUTTER0x00000008将垂直移动限制为向主方向进行,直至达到某个阈值以突破槽。
GC_PAN_WITH_INERTIA0x00000010指示带有延时的平移以便在平移笔势停止时平滑地慢慢停止。

 

注意   在 SetGestureConfig 中设置 GID_PAN 标志将影响用于平移的默认笔势处理程序。不应为相同的标志同时设置 dwWant 和 dwBlock;这将导致出现意外行为。有关平移和旧版平移支持的更多信息,请参见 Windows Touch 笔势;有关启用和阻止笔势的示例,请参见 SetGestureConfig

当 dwID 设置为 GID_ROTATE 时使用以下标志。

名称说明
GC_ROTATE0x00000001指示旋转笔势。

 

当 dwID 设置为 GID_TWOFINGERTAP 时使用以下标志。

名称说明
GC_TWOFINGERTAP0x00000001指示双指点击笔势。

 

当 dwID 设置为 GID_PRESSANDTAP 时使用以下标志。

名称说明
GC_PRESSANDTAP0x00000001指示按住并点击笔势。

 

示例

    GESTURECONFIG gc[3];    
    UINT uiGcs = 3;

    ZeroMemory(&gc, sizeof(gc));
    gc[0].dwID  = GID_ZOOM;
    gc[1].dwID  = GID_ROTATE;
    gc[2].dwID  = GID_PAN;
    BOOL bResult = GetGestureConfig(hWnd, 0, 0, &uiGcs, gc, sizeof(GESTURECONFIG));        
    if (!bResult){                
        DWORD err = GetLastError();                                       
    }    

要求

最低支持的客户端

Windows 7

最低支持的服务器

Windows Server 2008 R2

标头

Winuser.h (包括Windows.h)
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值