IViewObjectEx  1.JNKX9

The IViewObjectEx interface is 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

 

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 offscreen 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 IViewEx interface supports hit detection for non-rectangular objects. Using the QueryHitPoint and QueryHitRect methods, the object can participate in the hit-test logic with the container.

Control Sizing

The IViewEx 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.

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 IViewObject25K_0FA 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.

Methods in Vtable Order

IUnknown1NEM0LU Methods

Description

QueryInterface2Y54585

Returns pointers to supported interfaces.

AddRef1SHW0SS

Increments reference count.

ReleaseDUW01A

Decrements reference count.

 

IViewObject1VLFPYP Methods

Description

Draw1SUNL2

Draws a representation of the object onto a device context.

GetColorSet238O_U

Returns the logical palette the object uses for drawing.

FreezeQVLUDN

Freezes the drawn representation of an object so it will not change until a subsequent Unfreeze.

UnfreezeIRZEGD

Unfreezes the drawn representation of an object.

SetAdvise168GX4M

Sets up a connection between the view object and an advise sink so that the advise sink can receive notifications of changes in the view object.

GetAdvise2UHK0DU

Returns the information on the most recent SetAdvise.

 

IViewObject25K_0FA Method

Description

GetExtent2119Z0D

Returns the size that the specified view object will be drawn on the specified target device.

 

IViewObjectEx Methods

Description

GetRect41MM.JG

Returns a rectangle describing a requested drawing aspect.

GetViewStatusUMJJ1T

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

QueryHitPoint3704C3U

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

QueryHitRectUS.3PX

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

GetNaturalExtent13KICDP

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

 

See Also

IViewObject2