Microsoft DirectX 8.1 (Visual Basic)

ScrawlB Sample

Description

The ScrawlB sample program illustrates using Microsoft® DirectInput® to create a simple drawing program. It shows how to use the mouse in exclusive mode, how to use event notification for mouse events, how to retrieve and interpret buffered data, and how to use callback functions to receive mouse movement events.

Path

Source: (SDK root)\Samples\Multimedia\VBSamples\DirectInput\Scrawl

Executable: (SDK root)\Samples\Multimedia\VBSamples\DirectInput\Bin\VB_Scrawlb.exe

User's Guide

Hold down the left button while dragging the mouse to draw. Click the right button to see a shortcut menu. Choosing Release Mouse (or pressing and releasing ALT) releases the system cursor so that you can move or resize the window or click on another application. Click on the client window again to resume drawing.

Programming Notes

The application subclasses the Display window to capture WM_ENTERMENULOOP messages. This is the best way to find out if the user has opened the system menu by pressing ALT+SPACEBAR, so that ScrawlB can release the mouse through a call to SetWindowLong. However, subclassing can lead to difficulties when debugging. Note that failure to comment out these lines while running the sample from within the Visual Basic environment will result in undefined behavior.

The frmCanvas module implements DirectXEvent8 in order to be able to process input events. The Microsoft® Visual Basic® MouseMove event is also used by this form for getting Microsoft Windows® mouse events when Microsoft DirectInput® does not have access to the mouse. When this event is triggered, the application knows that the cursor is back in the client window, so the mouse can be reacquired.