Windows API Guide: EqualRgn Function


Declare Function GetCapture Lib "user32.dll" () As Long

Platforms

  • Windows 95: Supported.
  • Windows 98: Supported.
  • Windows NT: Requires Windows NT 3.1 or later.
  • Windows 2000: Supported.
  • Windows CE: Requires Windows CE 1.0 or later.

Description & Usage

GetCapture identifies which window currently has captured the mouse input, if any. However, this function only works if a window owned by the calling thread; if another program's window has captured the mouse, this function will not work.

Return Value

If a window owned by the calling thread has captured the mouse, the function returns a handle to that window. If no thread window has captured the mouse, the function returns 0.

Visual Basic-Specific Issues

None.

Parameters

None.

Constant Definitions

Example

If a window owned by the program has captured the mouse input, display its caption. If not, inform the user that no program window has captured the mouse. The capture is checked when the user clicks button Command1. To use this example, you must first place a command button named Command1 on a form window.

' This code is licensed according to the terms and conditions listed here. ' Declarations and such needed for the example: ' (Copy them to the (declarations) section of a module.) Public Declare Function GetCapture Lib "user32.dll" () As Long Public Declare Function GetWindowText Lib "user32.dll" Alias "GetWindowTextA" (ByVal hWnd _ As Long, ByVal lpString As String, ByVal nMaxCount As Long) As Long Public Declare Function GetWindowTextLength Lib "user32.dll" Alias "GetWindowTextLengthA" _ (ByVal hWnd As Long) As Long ' *** Place the following code inside a form window. *** Private Sub Command1_Click() Dim hWndCapture As Long  ' handle to the window that captured the mouse Dim wintext As String    ' receives the text of the capturing window Dim slength As Long      ' the length of that string ' First, see if a thread window has even captured the mouse. hWndCapture = GetCapture() If hwndCapture = 0 Then Debug.Print "This program has not captured the mouse." Else ' Get the capturing window's text and display it. slength = GetWindowTextLength(hWndCapture) + 1 wintext = Space(slength) slength = GetWindowText(hWndCapture, wintext, slength) wintext = Left(wintext, slength) Debug.Print "The window " & Chr(34) & wintext & Chr(34) & " has captured the mouse." End If End Sub

See Also

ReleaseCapture, SetCapture

Category

Mouse

Back to the Function list.
Back to the Reference section.


Last Modified: August 26, 2000
This page is copyright © 2000 Paul Kuliniewicz. Copyright Information Revised October 29, 2000
Go back to the Windows API Guide home page.
E-mail: vbapi@vbapi.com Send Encrypted E-Mail
This page is at http://www.vbapi.com/ref/g/getcapture.html



Windows API Guide
Windows API Guide - Reference - Volume 1: Version 3.0 For the MS-DOS and PC-DOS Operating Systems
ISBN: B001V0KQIY
EAN: N/A
Year: 1998
Pages: 610

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net