joySetCapture

Syntax

WORD joySetCapture(hWnd, wId, wPeriod, bChanged)

This function causes joystick messages to be sent to the specified window.

Parameters

HWND hWnd

Specifies a handle to the window to which messages are to be sent.

WORD wId

Identifies the joystick device to be captured. This value is either JOYSTICKID1 or JOYSTICKID2.

WORD wPeriod

Specifies the polling rate, in milliseconds.

BOOL bChanged

If this parameter is set to TRUE, then messages are sent only when the position changes by a value greater than the joystick movement threshold.

Return Value

Returns JOYERR_NOERROR if successful. Otherwise, returns one of the following error codes:

MMSYSERR_NODRIVER

The joystick driver is not present.

JOYERR_PARMS

The specified window handle hWnd or joystick device ID wId is invalid.

JOYERR_NOCANDO

Cannot capture joystick input because some required service (for example, a Windows timer) is unavailable.

JOYERR_UNPLUGGED

The specified joystick is not connected to the system.

Comments

This function fails if the specified joystick device is currently captured. You should call the joyReleaseCapture function when the joystick capture is no longer needed. If the window is destroyed, the joystick will be released automatically.

See Also

joyReleaseCapture, joySetThreshold, joyGetThreshold