joySetCapture

The joySetCature function captures a joystick by causing its messages to be sent to the specified window.

MMRESULT joySetCapture(
  HWND hwnd,    
  UINT uJoyID,  
  UINT uPeriod, 
  BOOL fChanged 
);
 

Parameters

hwnd
Handle of the window to receive the joystick messages.
uJoyID
Identifier of the joystick (JOYSTICKID1 or JOYSTICKID2) to be captured.
uPeriod
Polling frequency, in milliseconds.
fChanged
Change position flag. Specify TRUE for this parameter to send messages only when the position changes by a value greater than the joystick movement threshold. Otherwise, messages are sent at the polling frequency specified in uPeriod.

Return Values

Returns JOYERR_NOERROR if successful or one of the following error values:

Value Description
MMSYSERR_NODRIVER The joystick driver is not present.
JOYERR_NOCANDO Cannot capture joystick input because a required service (such as a Windows timer) is unavailable.
JOYERR_UNPLUGGED The specified joystick is not connected to the system.

Remarks

This function fails if the specified joystick is currently captured. Call the joyReleaseCapture function to release the captured joystick, or destroy the window to release the joystick automatically.

QuickInfo

  Windows NT: Requires version 3.1 or later.
  Windows: Requires Windows 95 or later.
  Windows CE: Unsupported.
  Header: Declared in mmsystem.h.
  Import Library: Use winmm.lib.

See Also

Joysticks Overview, Multimedia Joystick Functions, joyReleaseCapture