Platform SDK: DirectX

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 by DirectInput® or by responding to Windows mouse messages. However, any application that doesn't 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.

[C++]

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's a relatively simple matter to implement, as well. To do so, create a DirectDrawClipper object by calling the IDirectDraw7::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 IDirectDrawSurface7::Blt method will not exhibit the artifact.

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

[Visual Basic]

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's a relatively simple matter to implement, as well. To do so, create a DirectDrawClipper object by calling the DirectDraw7.CreateClipper method. Then, assign your application's window handle to the clipper with the DirectDrawClipper.SetHWnd method. Once a clipper is attached, any subsequent blits you perform on the primary surface with the DirectDrawSurface7.Blt method will not exhibit the artifact.