IHTMLEventObj

IHTMLEventObj


This interface provides access to the event processes, such as the element in which the event occurred, the state of the keyboard keys, the location of the mouse, and the state of the mouse buttons.

The event object is only available during an event, that is, you can use it in event handlers but not in other code. You retrieve the event object by calling the IHTMLWindow2::get_event method.

Although all event properties are available to all event objects, some properties might not have meaningful values during some events. For example, the values retrieved by the get_fromElement and the get_toElement methods are meaningful only when processing the onmouseover and onmouseout events.

IHTMLEventObj Methods
get_srcElement   get_altKey   get_ctrlKey  
get_shiftKey   put_returnValue   get_returnValue  
put_cancelBubble   get_cancelBubble   get_fromElement  
get_toElement   put_keyCode   get_keyCode  
get_button   get_type   get_qualifier  
get_reason   get_x   get_y  
get_clientX   get_clientY   get_offsetX  
get_offsetY   get_screenX   get_screenY  
get_srcFilter  

IHTMLEventObj::get_srcElement

HRESULT get_srcElement(
    IHTMLElement **p
);

Retrieves an interface pointer for the object in which the event occurred.

p
Address of a pointer to the IHTMLElement interface of the object.

IHTMLEventObj::get_altKey

HRESULT get_altKey(
    VARIANT_BOOL *p
);

Retrieves the state of the ALT key.

p
Address of a Boolen variable that receives TRUE if the key is down, or FALSE otherwise.

IHTMLEventObj::get_ctrlKey

HRESULT get_ctrlKey(
    VARIANT_BOOL *p
);

Retrieves the state of the CTRL key.

p
Address of a Boolen variable that receives TRUE if the key is down, or FALSE otherwise.

IHTMLEventObj::get_shiftKey

HRESULT get_shiftKey(
    VARIANT_BOOL *p
);

Retrieves the state of the SHIFT key.

p
Address of a Boolean variable that receives TRUE if the key is down, or FALSE otherwise.

IHTMLEventObj::put_returnValue

HRESULT put_returnValue(
    VARIANT v
);

Sets the return value of the event.

v
VARIANT structure that contains the return value. It can be either TRUE of FALSE.

For event handler functions, the value of this property takes precedence over values returned by the function, such as through a return statement.

See also get_returnValue

IHTMLEventObj::get_returnValue

HRESULT get_returnValue(
    VARIANT *p
);

Retrieves the return value of the event or dialog.

p
Address of a VARIANT structure that receives the return value. It can be either TRUE or FALSE.

For event handler functions, the value of this property takes precedence over values returned by the function, such as through a return statement.

See also put_returnValue

IHTMLEventObj::put_cancelBubble

HRESULT put_cancelBubble(
    VARIANT_BOOL v
);

Sets whether the current event should bubble up the hierarchy of event handlers.

v
Boolean value that contains the cancel-bubble flag. TRUE cancels bubbling for this event, preventing the next event handler in the hierarchy from receiving the event. FALSE enables bubbling; this is the default value.

Using this property to cancel bubbling for an event does not affect subsequent events.

See also get_cancelBubble

IHTMLEventObj::get_cancelBubble

HRESULT get_cancelBubble(
    VARIANT_BOOL *p
);

Retrieves whether the current event should bubble up the hierarchy of event handlers.

p
Address of a Boolean variable that receives TRUE if bubbling has been canceled, or FALSE otherwise.

Using this property to cancel bubbling for an event does not affect subsequent events.

See also put_cancelBubble

IHTMLEventObj::get_fromElement

HRESULT get_fromElement(
    IHTMLElement **p
);

Retrieves the object being moved from for the onmouseover and onmouseout events.

p
Address of a pointer to the IHTMLElement interface of the object.

IHTMLEventObj::get_toElement

HRESULT get_toElement(
    IHTMLElement **p
);

Retrieves the object being moved to for the onmouseover and onmouseout events.

p
Address of a pointer to the IHTMLElement interface of the object.

IHTMLEventObj::put_keyCode

HRESULT put_keyCode(
    long v
);

Sets the Unicode key code associated with the key that caused the event.

v
Long integer value specifying any Unicode key code in the range 1 to 255. It is zero if no key caused the event.

If you set this property, the given key code replaces the existing value. Subsequent event handlers receive the new value rather than the original.

This property is intended to be used with the onkeydown, onkeyup, and onkeypress events.

See also get_keyCode

IHTMLEventObj::get_keyCode

HRESULT get_keyCode(
    long *p
);

Retrieves the Unicode key code associated with the key that caused the event.

p
Address of a long integer variable that receives the Unicode key code. It can be any key code in the range 1 to 255. It is zero if no key caused the event.

If you set this property, the given key code replaces the existing value. Subsequent event handlers receive the new value rather than the original.

This property is intended to be used with the onkeydown, onkeyup, and onkeypress events.

See also put_keyCode

IHTMLEventObj::get_button

HRESULT get_button(
    long *p
);

Retrieves which mouse button, if any, is pressed.

p
Address of a long integer variable that receives one of these values:
0 No button.
1 Left button is pressed.
2 Right button is pressed.
4 Middle button is pressed.

This property is intended to be used with the onmousedown, onmouseup, and onmousemove events. For other events, it typically is 0 regardless of the state of the mouse buttons.

IHTMLEventObj::get_type

HRESULT get_type(
    BSTR *p
);

Retrieves the event name as a string.

p
Address of a string variable that receives the event name.

Events are returned without the "on" prefix. For example, the "onclick" event is returned as "click".

IHTMLEventObj::get_qualifier

HRESULT get_qualifier(
    BSTR *p
);

Specifies the event qualifier.

p
Address of a string variable that receives the event qualifier. In Internet Explorer 4.0, it is always set to "".

IHTMLEventObj::get_reason

HRESULT get_reason(
    long *p
);

Retrieves the disposition of data transfer for a data source object.

p
Address of a long integer variable that receives an integer value specifying the reason for completion. Can be one of these values:
0 Data transmitted successfully.
1 Data transfer aborted.
2 Data transfer in error.

IHTMLEventObj::get_x

HRESULT get_x(
    long *p
);

Retrieves the position of the mouse hit relative to the object in the parent heirarchy that is positioned using the CSS positioning attribute. If no object in the heirarchy has been positioned, the BODY is the default.

p
Address of a long integer variable that receives the position of the mouse hit.

If the mouse is outside the window when the event is called, this property returns -1.

See also get_y

IHTMLEventObj::get_y

HRESULT get_y(
    long *p
);

Retrieves the position of the mouse hit relative to the object in the parent heirarchy that is positioned using the CSS positioning attribute. If no object in the heirarchy has been positioned, the BODY is the default.

p
Address of a long integer variable that receives the position of the mouse hit.

If the mouse is outside the window at the time the event fires, this property returns -1.

See also get_x

IHTMLEventObj::get_clientX

HRESULT get_clientX(
    long *p
);

Retrieves the horizontal position of the mouse hit relative to the top of the client area of the window. This does not include window decorations or scroll bars.

p
Address of a long integer variable that receives the position.

See also get_clientY

IHTMLEventObj::get_clientY

HRESULT get_clientY(
    long *p
);

Retrieves the vertical position of the mouse hit relative to side of the client area of the window. This does not include window decorations or scroll bars.

p
Address of a long integer variable that receives the position.

See also get_clientX

IHTMLEventObj::get_offsetX

HRESULT get_offsetX(
    long *p
);

Returns container-relative positions. These match the offsetLeft and offsetTop properties of the object. Use offsetParent to find the container object that defines this coordinate system.

p
Address of a long integer variable that receives the positions.

See also get_offsetY

IHTMLEventObj::get_offsetY

HRESULT get_offsetY(
    long *p
);

Returns container-relative positions. These match the offsetLeft and offsetTop properties of the object. Use offsetParent to find the container object that defines this coordinate system.

p
Address of a long integer variable that receives the positions.

See also get_offsetX

IHTMLEventObj::get_screenX

HRESULT get_screenX(
    long *p
);

Returns coordinates relative to the physical screen size.

p
Address of a long integer variable that receives the screen coordinates.

See also get_screenY

IHTMLEventObj::get_screenY

HRESULT get_screenY(
    long *p
);

Returns coordinates relative to the physical screen size.

p
Address of a long integer variable that receives the screen coordinates.

See also get_screenX

IHTMLEventObj::get_srcFilter

HRESULT get_srcFilter(
    BSTR *p
);

Specifies the filter object that caused the onfilterchange event.

p
Address of a string variable that receives the filter object.

© 1997 Microsoft Corporation. All rights reserved. Terms of Use.