Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Use interface to programmatically create strokes from packet data.
Inheritance
The IStrokeBuilder interface inherits from the IUnknown interface. IStrokeBuilder also has these types of members:
Methods
The IStrokeBuilder interface has these methods.
IStrokeBuilder::AppendPackets Adds a packet to the end of the digitizer input packet list. |
IStrokeBuilder::BeginStroke Begins a stroke on an ink object by using packet data from a RealTimeStylus Class object. |
IStrokeBuilder::CreateStroke Creates strokes on an ink object by using packet data that came from a RealTimeStylus Class object. |
IStrokeBuilder::EndStroke Ends a stroke and returns the stroke object. |
IStrokeBuilder::get_Ink Gets or sets the ink object that is associated with the IStrokeBuilder object. |
Remarks
This interface is implemented by the StrokeBuilder Class.
The StrokeBuilder Class provides an alternative method of creating a stroke for applications that manage the data. It has methods that can be called from StylusDown, Packets, and StylusUp notifications.
The following two models are supported.
- Converting custom stroke information to a stroke in an atomic fashion by using the IStrokeBuilder::CreateStroke Method method.
- Building the stroke by using the IStrokeBuilder::BeginStroke Method, IStrokeBuilder::AppendPackets Method, and IStrokeBuilder::EndStroke Method methods, which mirror the StylusDown, Packets, and StylusUp notifications.
Examples
The following C++ example shows a partial implementation of an IStylusPlugin Interface class. The plug-in uses a StrokeBuilder object to create a new ink stroke.
// CStrokeBuilderPlugin
// Helper functions
HRESULT CStrokeBuilderPlugin::GetInk(IInkDisp** pInk)
{
return m_pStrokeBuilder->get_Ink(pInk);
}
// IStylusAsyncPlugin Interface implementation
STDMETHODIMP CStrokeBuilderPlugin::RealTimeStylusEnabled(
/* [in] */ IRealTimeStylus *piRtsSrc,
/* [in] */ ULONG cTcidCount,
/* [size_is][in] */ const TABLET_CONTEXT_ID *pTcids)
{
// Create an IStrokeBuilder object
return CoCreateInstance(CLSID_StrokeBuilder, NULL, CLSCTX_INPROC, IID_IStrokeBuilder, (VOID **)&m_pStrokeBuilder);
}
STDMETHODIMP CStrokeBuilderPlugin::DataInterest(
/* [retval][out] */ RealTimeStylusDataInterest *pDataInterest)
{
// Set up the messages we want to receive
*pDataInterest = (RealTimeStylusDataInterest)(RTSDI_StylusDown | RTSDI_Packets |
RTSDI_StylusUp | RTSDI_Error);
return S_OK;
}
STDMETHODIMP CStrokeBuilderPlugin::StylusDown(
/* [in] */ IRealTimeStylus *piRtsSrc,
/* [in] */ const StylusInfo *pStylusInfo,
/* [in] */ ULONG cPropCountPerPkt,
/* [size_is][in] */ LONG *pPacket,
/* [out][in] */ LONG **ppInOutPkt)
{
FLOAT fInkToDeviceScaleX;
FLOAT fInkToDeviceScaleY;
ULONG cPacketProperties;
PACKET_PROPERTY* pPacketProperties;
// Get the info we need to call BeginStroke
HRESULT hr = piRtsSrc->GetPacketDescriptionData(pStylusInfo->tcid, &fInkToDeviceScaleX, &fInkToDeviceScaleY,
&cPacketProperties, &pPacketProperties);
if (SUCCEEDED(hr))
{
// Start creating the stroke
hr = m_pStrokeBuilder->BeginStroke(pStylusInfo->tcid, pStylusInfo->cid, pPacket, cPropCountPerPkt,
pPacketProperties, fInkToDeviceScaleX, fInkToDeviceScaleY, &m_piStroke);
}
return hr;
}
STDMETHODIMP CStrokeBuilderPlugin::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)
{
// Add packet to the stroke
return m_pStrokeBuilder->AppendPackets(pStylusInfo->tcid, pStylusInfo->cid, cPktBuffLength, pPackets);
}
STDMETHODIMP CStrokeBuilderPlugin::StylusUp(
/* [in] */ IRealTimeStylus *piRtsSrc,
/* [in] */ const StylusInfo *pStylusInfo,
/* [in] */ ULONG cPropCountPerPkt,
/* [size_is][in] */ LONG *pPacket,
/* [out][in] */ LONG **ppInOutPkt)
{
// Finish the stroke. This adds the stroke to the StrokeBuilder's Ink object.
return m_pStrokeBuilder->EndStroke(pStylusInfo->tcid, pStylusInfo->cid, &m_piStroke, NULL);
}
STDMETHODIMP CStrokeBuilderPlugin::Error(
/* [in] */ IRealTimeStylus *piRtsSrc,
/* [in] */ IStylusPlugin *piPlugin,
/* [in] */ RealTimeStylusDataInterest dataInterest,
/* [in] */ HRESULT hrErrorCode,
/* [out][in] */ LONG_PTR *lptrKey)
{
CString strError;
strError.Format(L"An error occurred. Error code: %d", hrErrorCode);
TRACE(strError);
return S_OK;
}
// The remaining interface methods are not used
Requirements
Requirement | Value |
---|---|
Minimum supported client | Windows XP Tablet PC Edition [desktop apps only] |
Minimum supported server | None supported |
Target Platform | Windows |
Header | rtscom.h |