共用方式為


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 Class 物件。

[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 類別