IDirectManipulationViewport2::AddBehavior method (directmanipulation.h)

Adds a behavior to the viewport and returns a cookie to the caller.

Syntax

HRESULT AddBehavior(
  [in]          IUnknown *behavior,
  [out, retval] DWORD    *cookie
);

Parameters

[in] behavior

A behavior created using the CreateBehavior method.

[out, retval] cookie

A cookie is returned so the caller can remove this behavior later. This allows the caller to release any reference on the behavior and let Direct Manipulation maintain an appropriate lifetime, similar to event handlers.

Return value

If the method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. Attaching a behavior that is already attached to this viewport or another viewport results in a failure.

Remarks

A behavior takes effect immediately after AddBehavior is called. This must be considered when adding a behavior during an active manipulation or inertia phase.

Requirements

Requirement Value
Minimum supported client Windows 8.1 [desktop apps only]
Minimum supported server Windows Server 2012 R2 [desktop apps only]
Target Platform Windows
Header directmanipulation.h

See also

IDirectManipulationViewport2