SetCapture and ReleaseCapture Command

Purpose

Sets and releases exclusive mouse input which can be limited to a specific window.

Syntax

ReleaseCapture

SetCapture wh%

wh%:integer expression

Description

SetCapture redirects all mouse events - regardless of how many windows are currently open - to the window with the number wh% (0..31) or API handle. For a Form object use the hWnd property.

SetCapture can only be invoked for one single window at any one time. If the mouse input is to be redirected to another window, the command ReleaseCapture must first be called for the current (mouse) window and then SetCapture for the new window.

ReleaseCapture redirects the mouse input back to the corresponding window (the window with the mouse pointer).

Example

OpenW 1 : Win_1.Caption = Win_1.Name

OpenW 2 : Win_2.Caption = Win_2.Name

SetCapture 1// or Win_1.hWnd

Do

Sleep

If MouseK %& 1

Print MouseX, MouseY

EndIf

Until MouseK %& 2       'press right mouse button

ReleaseCapture

CloseW 2

CloseW 1

Causes all mouse-input to be sent only to window 1 until right mouse button is pressed

Remarks

SetCapture and ReleaseCapture correspond to Windows function SetCapture() and ReleaseCapture respectively.

See Also

-

{Created by Sjouke Hamstra; Last updated: 22/10/2014 by James Gaite}