在vb6中利用api对光标进行编程:
option explicitprivate type pointapi x as long y as longend typeprivate declare function getcursorpos lib "user32" (lppoint as pointapi) as longprivate declare function showcursor lib "user32" (byval bshow as long) as longpublic function getxcursorpos() as long dim pt as pointapi getcursorpos pt getxcursorpos = pt.xend functionpublic function getycursorpos() as long dim pt as pointapi getcursorpos pt getycursorpos = pt.yend function '得到光标在屏幕中的位置private sub form_mousemove(button as integer, shift as integer, x as single, y as single) label1.caption = "x screen position = " & getxcursorpos label2.caption = "y screen position = " & getycursorposend sub'隐藏光标private sub command1_click() showcursor falseend sub'显示光标private sub command2_click() showcursor trueend sub
在vb.net中利用cursor 类很简单地对光标进行编程:(可以获取和设置光标的位置,设置光标的形状,显示和隐藏光标)
'隐藏光标 private sub button1_click(byval sender as system.object, byval e as system.eventargs) handles button1.click cursor.hide() end sub '得到光标在屏幕中的位置 private sub form2_mousemove(byval sender as object, byval e as system.windows.forms.mouseeventargs) handles mybase.mousemove me.label1.text = "x screen position = " & cursor.position.x me.label2.text = "y screen position = " & cursor.position.y end sub '显示光标 private sub button2_click(byval sender as system.object, byval e as system.eventargs) handles button2.click cursor.show() end sub
很简单的东西,更多的实例,可以参考api手册和framework的文档。
国内最大的酷站演示中心!
新闻热点
疑难解答
图片精选