What does HRESULT 0x00040101 (DRAGDROP_S_CANCEL) mean?

 
Previous Next
DRAGDROP_S_DROP DRAGDROP_S_USEDEFAULTCURSORS

DRAGDROP_S_CANCEL

OLE drag-and-drop canceled without a drop

DRAGDROP_S_CANCEL is HRESULT 262401 (0x00040101) from winerror.h. AllStat describes DRAGDROP_S_CANCEL as “Drag-drop operation canceled.” The high-order severity bit is clear, so this is a success result, but it carries more information than plain S_OK.

The modal OLE drag loop ended normally because the drag operation was canceled rather than delivered to a target.

State boundary that must be proved

The central question for DRAGDROP_S_CANCEL is whether no target-side transfer was committed and the source object remains in its pre-drag state. For DRAGDROP_S_CANCEL, the HRESULT alone confirms neither unrelated work nor the quality of optional outputs.

A reliable interpretation of DRAGDROP_S_CANCEL names the exact method contract, the object generation, and the outputs that remain valid. For DRAGDROP_S_CANCEL, this prevents a success-with-information result from being promoted to full success or demoted to a generic error.

Where this result is encountered

  • DRAGDROP_S_CANCEL can appear in escape-key cancellation; record the producing interface and method rather than inferring behavior from the symbolic name alone.
  • DRAGDROP_S_CANCEL can appear in mouse-button state that tells IDropSource to cancel; record the producing interface and method rather than inferring behavior from the symbolic name alone.
  • DRAGDROP_S_CANCEL can appear in source or target logic that intentionally stops an in-progress drag; record the producing interface and method rather than inferring behavior from the symbolic name alone.

For DRAGDROP_S_CANCEL, the same numeric success value can be mishandled when a wrapper exposes only a Boolean. For DRAGDROP_S_CANCEL, keep the original HRESULT until the code-specific outputs and state transition have been evaluated.

Evidence and telemetry to preserve

  • For DRAGDROP_S_CANCEL, preserve the QueryContinueDrag inputs and return history.
  • For DRAGDROP_S_CANCEL, preserve keyboard and mouse-button state.
  • For DRAGDROP_S_CANCEL, preserve last target entered and proposed effect.
  • For DRAGDROP_S_CANCEL, preserve whether any target preview or temporary object was created.
  • For DRAGDROP_S_CANCEL, preserve source data ownership after the loop exits.

Also record dragdrop_s_cancel_operation, dragdrop_s_cancel_object, dragdrop_s_cancel_state_before, dragdrop_s_cancel_state_after, UTC time, process and thread identifiers, and a correlation ID. For DRAGDROP_S_CANCEL, keep secrets out of logs while retaining GUIDs, CLSIDs, media subtypes, property IDs, row identities, and hashes needed to distinguish objects.

Diagnostic sequence

  • For DRAGDROP_S_CANCEL, capture the raw HRESULT 0x00040101 immediately after the returning method and record whether the caller used SUCCEEDED, FAILED, equality testing, or exception translation.
  • Identify the exact owner of DRAGDROP_S_CANCEL: interface, method, object instance, provider or filter version, thread or apartment, and operation phase.
  • Validate the decisive contract boundary for DRAGDROP_S_CANCEL: no target-side transfer was committed and the source object remains in its pre-drag state.
  • For DRAGDROP_S_CANCEL, inspect every output parameter, count, status array, returned interface, or side effect that the method documentation associates with this success-with-information result.
  • Compare the observed state before and after DRAGDROP_S_CANCEL; do not assume that a success severity bit means every optional sub-operation completed.
  • For DRAGDROP_S_CANCEL, reproduce the smallest request with the same object state and then change only the condition identified by the evidence before repeating the operation.

Correct handling, retry, and recovery

Remove temporary drag UI and leave source data intact. Cancellation is an expected user outcome and normally should not trigger retries, error dialogs, or failure telemetry.

Retry DRAGDROP_S_CANCEL only when the recorded state can change the documented outcome. For DRAGDROP_S_CANCEL, repeating the same call is inappropriate for a stable end marker, cancellation, unsupported format, adjusted property, or partial result whose completed side effects have not been reconciled.

Practical validation scenario

A user presses Escape while dragging an attachment. The application receives DRAGDROP_S_CANCEL, removes the drag image, keeps the attachment in place, and records an informational cancellation event only.

The negative test should preserve the condition that produces DRAGDROP_S_CANCEL; the recovery test should alter only that condition and verify the final state as well as the HRESULT.

Difference from nearby HRESULT values

DRAGDROP_S_DROP means a target accepted the transfer. E_ABORT can represent a failure-style abort in other COM contracts and should not be substituted without checking the API.

For DRAGDROP_S_CANCEL, this distinction determines whether the caller should consume partial outputs, stop iteration, wait, reconfigure, notify the user, or perform no error recovery at all.

Developer and administrator guidance

Tests for DRAGDROP_S_CANCEL should verify both the encoded condition and the resulting outputs. A test for DRAGDROP_S_CANCEL that checks only SUCCEEDED cannot detect stale counts, partial streams, adjusted properties, missing callbacks, or other code-specific effects.

A support report for DRAGDROP_S_CANCEL should include decimal 262401, hexadecimal 0x00040101, the AllStat meaning, the owning API, and the first detailed status or output that explains why the method did not return ordinary S_OK.

References


Looking for a different code? Search another status or error code.