Using a Clipper with the System Cursor

DirectDraw applications often need to provide a way for users to navigate using the mouse. For full-screen exclusive mode applications that use page-flipping, the only option is to implement a mouse cursor manually with a sprite, moving the sprite based on data retrieved from the device or by responding to Windows mouse messages. However, any application that does not use page-flipping can still use the system's mouse cursor support.

When you use the system mouse cursor, you will sometimes fall victim to graphic artifacts that occur when you blit to parts of the primary surface. These artifacts appear as portions of the mouse cursor seemingly left behind by the system.

A DirectDrawClipper object can prevent these artifacts from appearing by preventing the mouse cursor image from being in the way during a blit operation. It is a relatively simple matter to implement, as well. To do so, create a DirectDrawClipper object by calling the IDirectDraw4::CreateClipper method. Then, assign your application's window handle to the clipper with the IDirectDrawClipper::SetHWnd method. Once a clipper is attached, any subsequent blits you perform on the primary surface with the IDirectDrawSurface5::Blt method will not exhibit the artifact.

Note that the IDirectDrawSurface5::BltFast method, and its counterparts in the IDirectDrawSurface, IDirectDrawSurface2, and IDirectDrawSurface3 interfaces, will not work on surfaces with attached clippers.

 Last updated on Thursday, April 08, 2004

© 1992-2003 Microsoft Corporation. All rights reserved.