Platform SDK: DirectX

ScrawlB Sample

[C++]

This topic pertains only to application development in Visual Basic. See DirectInput C/C++ Samples.

[Visual Basic]

Description

The ScrawlB sample shows how to use the mouse in exclusive mode, how to use event notification for mouse events, and how to retrieve and interpret buffered data.

Path

Source: (SDK root)\Samples\Multimedia\VBSamples\Dinput\Src\Scrawlb

Executable: (SDK root)\Samples\Multimedia\VBSamples\Dinput\Bin\Scrawlb.exe

User's Guide

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

Note that if you use ALT+TAB to switch to another application, ScrawlB reclaims the mouse as soon as it passes over the client window.

Programming Notes

The application subclasses the main window in order to intercept 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. However, subclassing can lead to difficulties when debugging. See the comments in modMain.bas.

The frmCanvas module implements DirectXEvent in order to be able to process input events. The Visual Basic MouseMove event is also used by this form for getting Windows mouse events when 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.