iStylusPlugin::P ackets 方法 (rtscom.h)

通知实现插件的对象平板电脑笔正在数字化器上移动。

语法

HRESULT Packets(
  [in]      IRealTimeStylus  *piRtsSrc,
  [in]      const StylusInfo *pStylusInfo,
  [in]      ULONG            cPktCount,
  [in]      ULONG            cPktBuffLength,
  [in]      LONG             *pPackets,
  [in, out] ULONG            *pcInOutPkts,
  [in, out] LONG             **ppInOutPkts
);

参数

[in] piRtsSrc

发送通知的 RealTimeStylus 类 对象。

[in] pStylusInfo

StylusInfo 结构结构,包含与笔关联的 RTS 的相关信息。

[in] cPktCount

每个数据包的属性数。

[in] cPktBuffLength

pPackets 指向的缓冲区的长度(以字节为单位)。 每个数据包占用的内存 (cPktBuffLength / cPktCount) 。 有效值为 0 到 0x7FFF(含)。

[in] pPackets

指向数据包数据开头的指针。

[in, out] pcInOutPkts

ppInOutPkt 中的 LONG 数。

[in, out] ppInOutPkts

指向修改后的触笔数据包数组的指针。 插件可以使用此参数将修改后的数据包数据馈送给下游数据包。 NULL 以外的值指示 RTS 将使用 pPacket 参数将此数据发送到插件。

返回值

有关返回值的说明,请参阅 RealTimeStylus 类和接口

注解

当触控笔移动并触摸数字化器表面时发生。 使用此通知可约束指定矩形内的数据包数据。 可以删除 IStylusPlugin::P ackets 方法和IStylusPlugin::InAirPackets 方法 方法使用的数据包。

可以使用 ppInOutPkt 参数返回修改后的数据包数组。

可以将数据包捆绑在一起,以便提高数据传输效率,这样就不需要为每个数据包调用一次插件。 IStylusPlugin::InAirPackets 方法和IStylusPlugin::P ackets 方法 可以发送一个或多个数据包。

示例

以下 C++ 代码示例实现 IStylusPlugin::P ackets 方法 方法,该方法修改 X,Y 数据以将数据包限制为矩形。 此功能与 RealTimeStylus 插件示例中在 C# 中实现的功能相同。

STDMETHODIMP CPacketModifier::Packets( 
            /* [in] */ IRealTimeStylus *piRtsSrc,
            /* [in] */ const StylusInfo *pStylusInfo,
            /* [in] */ ULONG cPktCount,
            /* [in] */ ULONG cPktBuffLength,
            /* [size_is][in] */ LONG *pPackets,
            /* [out][in] */ ULONG *pcInOutPkts,
            /* [out][in] */ LONG **ppInOutPkts)
{
	BOOL fModified = FALSE;                             // Did we change the packet data?
	ULONG cPropertyCount = cPktBuffLength/cPktCount;    // # of properties in a packet
	ULONG iOtherProps = 0;                              // Properties other than X and Y

	// Allocate memory for modified packets
	LONG* pTempOutPkts = (LONG*)CoTaskMemAlloc(sizeof(ULONG)*cPktBuffLength);

	// For each packet in the packet data, check whether
	// its X,Y values fall outside of the specified rectangle.  
	// If so, replace them with the nearest point that still
	// falls within the rectangle.
	for (ULONG i = 0; i < cPktCount; i += cPropertyCount)
	{
		// Packet data always has X followed by Y 
		// followed by the rest
		LONG x = pPackets[i];
		LONG y = pPackets[i+1];

		// Constrain points to the input rectangle
		x = (x < m_filterRect.left ? m_filterRect.left : x);
		x = (x > m_filterRect.right ? m_filterRect.right : x);
		y = (y < m_filterRect.top ? m_filterRect.top : y);
		y = (y > m_filterRect.bottom ? m_filterRect.bottom : y);

		// If necessary, modify the X,Y packet data
		if ((x != pPackets[i]) || (y != pPackets[i+1]))
		{
			pTempOutPkts[i] = x;
			pTempOutPkts[i+1] = y;
			iOtherProps = i+2;
		
			// Copy the properties that we haven't modified
			while (iOtherProps < (i + cPropertyCount))
			{
				pTempOutPkts[iOtherProps] = pPackets[iOtherProps++];
			}

			fModified = TRUE;
		}
	}

	if (fModified)
	{
		// Set the [out] pointer to the 
		// memory we allocated and updated
		*ppInOutPkts = pTempOutPkts;
		*pcInOutPkts = cPktCount;
	}
	else
	{
		// Nothing modified, release the memory we allocated
		CoTaskMemFree(pTempOutPkts);
	}

	return S_OK;
}

要求

要求
最低受支持的客户端 Windows XP Tablet PC Edition [仅限桌面应用]
最低受支持的服务器 无受支持的版本
目标平台 Windows
标头 rtscom.h
DLL RTSCom.dll

另请参阅

IStylusAsyncPlugin

IStylusPlugin 接口

IStylusPlugin::StylusDown 方法

IStylusPlugin::StylusUp 方法

IStylusSyncPlugin

RealTimeStylus 类