The IViewObjectEx interface is an extension derived from IViewObject2 to provide support for:
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:
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.
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.
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.
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.
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.
IUnknown Methods | Description |
---|---|
QueryInterface | Returns pointers to supported interfaces. |
AddRef | Increments reference count. |
Release | Decrements reference count. |
IViewObject Methods | Description |
---|---|
Draw | Draws a representation of the object onto a device context. |
GetColorSet | Returns the logical palette the object uses for drawing. |
Freeze | Freezes the drawn representation of an object so it will not change until a subsequent Unfreeze. |
Unfreeze | Unfreezes the drawn representation of an object. |
SetAdvise | 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. |
GetAdvise | Returns the information on the most recent SetAdvise. |
IViewObject2 Method | Description |
---|---|
GetExtent | Returns the size that the specified view object will be drawn on the specified target device. |
IViewObjectEx Methods | Description |
---|---|
GetRect | Returns a rectangle describing a requested drawing aspect. |
GetViewStatus | Returns 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. |
GetNaturalExtent | Provides sizing hints from the container for the object to use as the user resizes it. |
Windows NT: Use version 4.0 or later. New for OC96.
Windows: Use Windows 95 or later. New for OC96.
Windows CE: Unsupported.
Header: Declared in ocidl.h.