IStylusPlugin::InAirPackets 方法 (rtscom.h)

通知实现插件的对象触笔正在数字化器上方移动。

语法

HRESULT InAirPackets(
  [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 类 (发送通知的 RTS) 对象。

[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 参数将此数据向下发送到插件。

返回值

有关返回值的说明,请参阅 类和接口 - 墨迹分析

注解

当数据包在范围内,但正在数字化器上方移动且不接触数字化器时,由触笔创建时,将调用此方法。 可以使用 ppInOutPkt 参数返回修改后的数据包数组。 创建缓冲区并将 ppInOutPkts 指向该缓冲区。 该位置只能存在一个数据包。

注意 可以删除 IStylusPlugin::P ackets 方法和IStylusPlugin::InAirPackets 方法 使用的数据包。
 
触笔插件可能与单个 RTS 或多个 RTS 相关联。 在以下情况下,请使用 piRtsSrc 参数:
  • 当通知要求插件获取有关发出通知的特定数字化器的详细信息时。
  • 通过系统输入其他自定义通知时。
可以将数据包捆绑在一起,以便更高效地进行数据传输。 因此,插件不需要为每个数据包调用一次。 IStylusPlugin::InAirPackets 方法和IStylusPlugin::P ackets 方法 可以发送一个或多个数据包。

示例

以下 C++ 代码示例实现 一个 IStylusPlugin::P ackets 方法 方法,该方法修改 X,Y 数据以将数据包限制为矩形。 相同的代码可以应用于 IStylusPlugin::InAirPackets 方法的实现。

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