Export (0) Print
Expand All

IViewObjectEx interface

An extension derived from IViewObject2 to provide support for:

  • Enhanced, flicker-free drawing for non-rectangular objects and transparent objects
  • Hit testing for non-rectangular objects
  • Control sizing

When to implement

Implement this interface on objects that need to support efficient flicker-free drawing, non-rectangular hit testing, or control sizing. This interface is derived from the IViewObject2 interface which, in turn, is derived from IViewObject.

All IViewObjectEx methods described in this document that take or return a position assume that the location is expressed in HIMETRIC units relative to the origin of the object.

When to use

Containers call the methods of this interface to draw objects in an efficient, flicker free manner, test whether points or rectangles are within the object, or to resize controls.

Members

The IViewObjectEx interface inherits from IViewObject2. IViewObjectEx also has these types of members:

Methods

The IViewObjectEx interface has these methods.

MethodDescription
GetNaturalExtent

Provides sizing hints from the container for the object to use as the user resizes it.

GetRect

Retrieves a rectangle describing a requested drawing aspect.

GetViewStatus

Retrieves information about the opacity of the object, and what drawing aspects are supported.

QueryHitPoint

Indicates whether a point is within a given aspect of an object.

QueryHitRect

Indicates whether any point in a rectangle is within a given drawing aspect of an object.

 

Flicker Free Drawing

Containers can now choose between a variety of drawing algorithms, depending on their sophistication and the situation.

Flicker is created by redrawing the background before letting an object redraw its foreground as in the back to front drawing algorithm known as the Painter's Algorithm. There are essentially two ways to avoid flickering:

  • Draw into an offscreen bitmap and then copy the resulting image to the screen in one chunk. This technique might require significant additional resources to store the offscreen image, depending on the size of the region to drawn, the resolution, and the number of colors.
  • Draw front to back, instead of back to front, excluding each rectangular area from the clipping region as soon as its has been painted. One benefit of this technique is that each pixel is painted only once. Speed depends essentially on the performance of the clipping support.

Each technique has advantages and disadvantages, depending on the specific situation. There is no single algorithm that is most efficient in all situations. Depending on the situation and their sophistication, containers may choose to use one or another, or a mix of both. The IViewObjectEx interface provides methods to support both techniques or a mixture of the two. Simple containers can implement a simplistic back to front painting algorithm directly to the screen. The speed is likely to be high but so will flicker. If flicker is to be reduced to a minimum, painting to an off-screen device context is the solution of choice. If memory consumption is a problem, containers can use clipping to reduce the use of off screen bitmaps.

To draw as flicker-free as possible without using an offscreen bitmap, the container will have to paint in two passes. The first pass is done front to back. During that pass, each object draws regions of itself that are cheap enough to clip out efficiently and that it can entirely obscure. These regions are known as opaque. After each object is done, the container clips out the regions just painted to ensure that subsequent objects will not modify the bits on the screen.

During the second pass, which occurs back to front, each object draws its remaining parts - irregular, oblique or in general difficult to clip out, such as text on transparent background. Such parts are known as transparent. At this point, the container is responsible for clipping out any opaque, already painted regions in front of the object currently drawing. The less painting during this second pass, the less flicker on the screen.

Clipping during the second pass may be very inefficient, since the clipping region needs to be recreated for every object that has something to draw. This might be acceptable if not too many overlapping objects have irregular or transparent parts. An object can tell its container ahead of time whether it wants to be called during this second pass or not.

If the container provides an off screen bitmap to paint into, then it can skip the first pass and ask every object to render itself entirely during the second pass. In certain cases, the container may also decide than flicker is not a problem and use that same technique while painting directly on screen. For example, flicker might be acceptable when painting a form for the first time, but not when repainting.

Note  Although documented here two pass drawing is not currently utilized by any containers.

Hit Testing for Non-Rectangular Objects

The IViewObjectEx interface supports hit detection for non-rectangular objects. Using the IViewObjectEx::QueryHitPoint and IViewObjectEx::QueryHitRect methods, the object can participate in the hit-test logic with the container.

Control Sizing

The IViewObjectEx interface allows controls to provide sizing hints as the user resizes the control. The control can specify a minimum and maximum size and can specify the nearest good size to a size requested by the user.

Requirements

Minimum supported client

Windows 2000 Professional [desktop apps only]

Minimum supported server

Windows 2000 Server [desktop apps only]

Header

OCIdl.h

IDL

OCIdl.idl

IID

IID_IViewObjectEx is defined as 3AF24292-0C96-11CE-A0CF-00AA00600AB8

See also

IViewObject2

 

 

Community Additions

ADD
Show:
© 2014 Microsoft