HTMLFormElementEvents2::oncopy Event

Fires on the source element when the user copies the object or selection, adding it to the system clipboard.

Syntax

VARIANT_BOOL oncopy(
    IHTMLEventObj *pEvtObj
);

Parameters

Return Value

If the event bubbles and is cancellable, return VARIANT_TRUE to prevent the event from bubbling to other event handlers in the document tree. Return VARIANT_FALSE to allow bubbling.

Event DISPID

DISPID_HTMLELEMENTEVENTS2_ONCOPY

The DISPID for this event is defined in mshtmdid.h. Use this value to identify the event handler when implementing IDispatch::Invoke.

Event Information

Bubbles Yes
Cancels Yes
To invoke
  • Right-click to display the shortcut menu and select Copy.
  • Or press CTRL+C.
Default action Duplicates the selection.

Event Object Properties

The IHTMLEventObj interface contains additional information about the current event. When the oncopy event is fired, you can use the IHTMLWindow2::event property to retrieve an IHTMLEventObj interface. To obtain an alternate interface pointer such as IHTMLEventObj2 or IHTMLEventObj3, call QueryInterface on the object.

Available Properties

IHTMLEventObj::altKey Gets a value that indicates the state of the ALT key.
IHTMLEventObj2::altKey Gets a value that indicates the state of the ALT key.
IHTMLEventObj3::altLeft Gets a value that indicates the state of the left ALT key.
IHTMLEventObj::cancelBubble Sets or retrieves whether the current event should bubble up the hierarchy of event handlers.
IHTMLEventObj::clientX Gets the x-coordinate of the mouse pointer, or user's finger, position relative to the client area of the window, excluding window decorations and scroll bars.
IHTMLEventObj2::clientX Gets or sets the x-coordinate of the mouse pointer, or user's finger, position relative to the client area of the window, excluding window decorations and scroll bars.
IHTMLEventObj::clientY Gets the y-coordinate of the mouse pointer, or user's finger, position relative to the client area of the window, excluding window decorations and scroll bars.
IHTMLEventObj2::clientY Gets or sets the y-coordinate of the mouse pointer, or user's finger, position relative to the client area of the window, excluding window decorations and scroll bars.
IHTMLEventObj::ctrlKey Gets the state of the CTRL key.
IHTMLEventObj2::ctrlKey Gets or sets the state of the CTRL key.
IHTMLEventObj3::ctrlLeft Sets or retrieves the state of the left CTRL key.
IHTMLEventObj2::dataTransfer Retrieves the IHTMLDataTransfer interface pointer of the event object.
IHTMLEventObj::offsetX Gets the x-coordinate of a pointer's position relative to the object firing the event.
IHTMLEventObj2::offsetX Gets or sets the x-coordinate of a pointer's position relative to the object firing the event.
IHTMLEventObj::offsetY Gets the y-coordinate of a pointer's position relative to the object firing the event.
IHTMLEventObj2::offsetY Gets or sets the y-coordinate of a pointer's position relative to the object firing the event.
IHTMLEventObj::returnValue Sets or retrieves the return value from the event.
IHTMLEventObj::screenX Gets the x-coordinate of the mouse pointer's position relative to the user's screen.
IHTMLEventObj2::screenX Gets or sets the x-coordinate of the mouse pointer's position relative to the user's screen.
IHTMLEventObj::screenY Gets the y-coordinate of the mouse pointer's position relative to the user's screen.
IHTMLEventObj2::screenY Gets or sets the y-coordinate of the mouse pointer's position relative to the user's screen.
IHTMLEventObj::shiftKey Gets the state of the SHIFT key.
IHTMLEventObj2::shiftKey Gets the state of the SHIFT key.
IHTMLEventObj3::shiftLeft Retrieves the state of the left SHIFT key.
IHTMLEventObj::srcElement Gets the object that fired the event.
IHTMLEventObj2::srcElement Gets or sets the object that fired the event.
IHTMLEventObj::type Gets the event name from the event object.
IHTMLEventObj2::type Gets or sets the event name from the event object.
IHTMLEventObj::x Gets the x-coordinate (in pixels) of the mouse pointer, or user's finger, offset from the closest relatively positioned parent element of the element that fired the event.
IHTMLEventObj2::x Gets or sets the x-coordinate (in pixels) of the mouse pointer, or user's finger, offset from the closest relatively positioned parent element of the element that fired the event.
IHTMLEventObj::y Gets the y-coordinate (in pixels) of the mouse pointer, or user's finger, offset from the closest relatively positioned parent element of the element that fired the event.
IHTMLEventObj2::y Gets or sets the y-coordinate (in pixels) of the mouse pointer, or user's finger, offset from the closest relatively positioned parent element of the element that fired the event.

Refer to the specific event object for additional event properties.

Remarks

Use the IHTMLDataTransfer::setData method to specify a data format for the selection.

See Also

About DHTML Data Transfer, HTMLFormElementEvents2::onbeforecopy, HTMLFormElementEvents2::onbeforecut, HTMLFormElementEvents2::onbeforepaste, HTMLFormElementEvents2::oncut, HTMLFormElementEvents2::onpaste, IHTMLDataTransfer::setData