Skip to content

SETMOUSE


设置鼠标光标的位置和可见性

语法

declare function Setmouse ( byval x as long = -1, byval y as long = -1, byval visibility as long = -1, byval clip as long = -1 ) as long

用法

result = Setmouse([ x ] [, [ y ] [, [ visibility ] [, [ clip ]]]])

参数

(对于每个参数,-1 是一个特殊值,表示"不做更改"。)

x

可选 - 设置 x 坐标

y

可选 - 设置 y 坐标

visibility

可选 - 设置可见性:1 表示可见,0 表示隐藏

clip

可选 - 设置裁剪:1 表示鼠标被裁剪到图形窗口,0 表示不裁剪

返回值

成功时返回零(0),失败时返回非零值。

说明

Setmouse 将设置鼠标指针的(xy)坐标,并设置其可见性。鼠标位置通过 xy 参数设置。当 visibility 设置为 1 时鼠标可见,设置为 0 时不可见。Setmouse 仅适用于使用 Screen (Graphics) 语句启动的图形模式。

Setmouse 返回的错误代码可以在下一行使用 Err 检查。Setmouse 的函数版本直接将错误代码作为 32 位 Long 返回。

示例

start GeSHi

vb
Dim As Long x, y, buttons

' create a screen 640*480
ScreenRes 640, 480
Print "Click the mouse button to center the mouse"

Do
    ' get mouse x, y and button state (wait until mouse is onscreen)
    Do: Sleep 1: Loop While GetMouse( x, y , , buttons) <> 0

    If buttons And 1 Then
        ' on left mouse click, center mouse
        SetMouse 320, 240
    End If

    ' run loop until a key is pressed or the window is closed
Loop While Inkey = ""

end GeSHi

方言差异

  • -lang qb 方言中不可用,除非使用别名 __Setmouse 引用。

与QB的区别

  • FreeBASIC 新增

参见

  • Getmouse
  • Screen (Graphics)
  • Multikey
  • Getkey

返回 目录

基于 FreeBASIC 官方文档翻译 如有侵权请联系我们删除
FreeBASIC 是开源项目,与微软公司无隶属关系