Microsoft DirectX 8.1 (Visual Basic)

Step 2: Setting Up Notifications

Rather than polling for mouse input in Sub Main, the ScrawlB sample application relies on Microsoft® DirectInput® to notify it whenever a mouse event takes place. As part of initialization, the application gets an event handle and passes it to DirectInputDevice8.SetEventNotification.

Dim EventHandle As Long

EventHandle = objDX.CreateEvent(frmCanvas)
Call objDIDev.SetEventNotification(EventHandle)
 

DirectInput will now notify any object that implements the DirectXEvent8 class. In the case of ScrawlB, the implementing object is the frmCanvas form, whose declarations section contains the following line.

Implements DirectXEvent8
 

This line causes frmCanvas to inherit all the methods of the DirectXEvent8 class. The only method implemented by that class is DirectXEvent8.DXCallback, and the inheriting class must implement this method. DirectInput calls this method whenever an input event is signaled.

The implementation of DXCallback is covered under Step 4: Retrieving Buffered Data from the Mouse.

There are responsibilities involved in maintaining an exclusive access level. They are covered in Step 3: Managing Exclusive Access to the Mouse