在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的文檔。
國內最大的酷站演示中心!
新聞熱點
疑難解答
圖片精選