游標(biāo)是什么?????你集中注意力?或獲得過大,多行嗎?
創(chuàng)新互聯(lián)自2013年起,先為霞浦等服務(wù)建站,霞浦等地企業(yè),進(jìn)行企業(yè)商務(wù)咨詢服務(wù)。為霞浦企業(yè)網(wǎng)站制作PC+手機(jī)+微官網(wǎng)三網(wǎng)同步一站式服務(wù)解決您的所有建站問題。
不明白你的意思......你可以嘗試,例如_啟動窗口創(chuàng)建了一個子程序的編輯框,加上得到焦點()方法或編輯框設(shè)置為true,在多條線路。
總之,我不明白光標(biāo)平均....
Dim?mc?As?System.Windows.Forms.Cursor
mc?=?Cursors.Arrow
mc當(dāng)前獲取就是箭頭鼠標(biāo)
比如你要更換在你某個窗體上的光標(biāo)。
那么在這個窗體內(nèi)用這樣的代碼
Me.Cursor = System.Windows.Forms.Cursors.Cross
如果你要更換當(dāng)前系統(tǒng)顯示的光標(biāo)
System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.Cross
其中Cross代表十字光標(biāo),你也可以更改成其他的,直接查看Cursors中的各成員就可以找到了。
幾乎找不到真正VB.NET的api,都是自己將VB的api改成VB.NET的api,我的理解是聲明中對應(yīng)輸入是H的地方保留Long,其他的Long改成Integer,既然VB.NET連MSDN都找不到較全的api說明,不保證api的用法在VB.NET其他版本中適用。
給你個好玩的例子,包括鼠標(biāo)的隱藏(Ctrl_↓)、顯示(Ctrl_↑),移動、點擊
在Form1上放上2個TextBox,其中TextBox1.Multiline = True,并且面積大些,2個Button,運(yùn)行后在TextBox1中點擊一下會記錄位置,移開鼠標(biāo),點擊移動或點擊Button,可模擬在TextBox1中的點擊
Public Class Form1
Public My_MousePosition As Point
'模擬鼠標(biāo)移動、點擊
Declare Sub mouse_event Lib "user32" (ByVal dwFlags As Long, ByVal dx As Integer, ByVal dy As Integer, ByVal cButtons As Long, ByVal dwExtraInfo As Long)
'定義光標(biāo)的位置
Declare Function SetCursorPos Lib "user32" Alias "SetCursorPos" (ByVal x As Integer, ByVal y As Integer) As Integer
'鼠標(biāo)的隱藏
Declare Function ShowCursor Lib "user32" Alias "ShowCursor" (ByVal bShow As Integer) As Integer
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
TextBox1.Multiline = True
Button1.Text = "點擊"
Button2.Text = "移動"
Me.KeyPreview = True
End Sub
Private Sub Form1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown
If e.Control And e.KeyCode = Keys.Down Then ShowCursor(0)
If e.Control And e.KeyCode = Keys.Up Then ShowCursor(1)
End Sub
Private Sub Form1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseMove
TextBox2.Text = MousePosition.X " " MousePosition.Y
End Sub
Private Sub TextBox1_MouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles TextBox1.MouseClick
My_MousePosition = MousePosition
TextBox1.Text = My_MousePosition.X " " My_MousePosition.Y vbCrLf
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
SetCursorPos(My_MousePosition.X, My_MousePosition.Y)
mouse_event(H2, 0, 0, 0, 0)
mouse_event(H4, 0, 0, 0, 0)
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
SetCursorPos(My_MousePosition.X, My_MousePosition.Y)
End Sub
End Class
其中
mouse_event Lib "user32" (ByVal dwFlags As Long
的dwFlags的代碼是
Const MOUSEEVENTF_LEFTDOWN = H2
Const MOUSEEVENTF_LEFTUP = H4
Const MOUSEEVENTF_MIDDLEDOWN = H20
Const MOUSEEVENTF_MIDDLEUP = H40
Const MOUSEEVENTF_MOVE = H1
Const MOUSEEVENTF_ABSOLUTE = H8000
Const MOUSEEVENTF_RIGHTDOWN = H8
Const MOUSEEVENTF_RIGHTUP = H10
網(wǎng)頁名稱:vb.net自己設(shè)置光標(biāo) vb設(shè)置光標(biāo)位置
標(biāo)題鏈接:http://muchs.cn/article40/dojhiho.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站建設(shè)、虛擬主機(jī)、建站公司、商城網(wǎng)站、服務(wù)器托管、云服務(wù)器
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)