我有光標不可見,當用戶滾動按鈕時,它會突出顯示。問題是當用戶在按鈕之間時,他不知道他的光標在哪裏。鼠標位置+金額IntersectsWith按鈕
在鼠標離開事件中,我希望光標跳到最接近的按鈕(而不是一個,他只是左)
Private Sub btnNumbers_Mouseleave(sender As System.Object, e As System.EventArgs) Handles btnAlef.MouseLeave, btnBkspc.MouseLeave, btnBack.MouseLeave, btnClearAll.MouseLeave, btnDeleteWord.MouseLeave, btnEditMenu.MouseLeave, btnUndo.MouseLeave, btnSpeak.MouseLeave, btnGimel.MouseLeave, btnZayin.MouseLeave, btnYud.MouseLeave, btnVav.MouseLeave, btnTzadik.MouseLeave, btnTuf.MouseLeave, btnTes.MouseLeave, btnSpace.MouseLeave, btnShin.MouseLeave, btnSamech.MouseLeave, btnReish.MouseLeave, btnQuestion.MouseLeave, btnPred5.MouseLeave, btnPred4.MouseLeave, btnPred3.MouseLeave, btnPred2.MouseLeave, btnPred1.MouseLeave, btnPeriod.MouseLeave, btnPercent.MouseLeave, btnOpenParen.MouseLeave, btnNun.MouseLeave, btnMem.MouseLeave, btnLetterPrediction2.MouseLeave, btnLetterPrediction1.MouseLeave, btnLamed.MouseLeave, btnKuf.MouseLeave, btnHey.MouseLeave, btnFey.MouseLeave, btnExclamation.MouseLeave, btnEnter.MouseLeave, btnEnderTzadik.MouseLeave, btnEnderNun.MouseLeave, btnEnderMem.MouseLeave, btnEnderFey.MouseLeave, btnEnderChaf.MouseLeave, btnDollar.MouseLeave, btnDaled.MouseLeave, btnCloseParen.MouseLeave, btnChes.MouseLeave, btnChaf.MouseLeave, btnBkspc.MouseLeave, btnBeis.MouseLeave, btnAyin.MouseLeave, btnApostrophe.MouseLeave, btn9.MouseLeave, btn8.MouseLeave, btn7.MouseLeave, btn6.MouseLeave, btn5.MouseLeave, btn4.MouseLeave, btn3.MouseLeave, btn2.MouseLeave, btn1.MouseLeave, btn0.MouseLeave, btnSavedPhrases5.MouseLeave, btnSavedPhrases4.MouseLeave, btnSavedPhrases3.MouseLeave, btnSavedPhrases2.MouseLeave, btnSavedPhrases1.MouseLeave, btnSettings.MouseLeave, btnPhrases.MouseLeave, btnNumbers.MouseLeave, btnMinimize.MouseLeave, btnHebrew.MouseLeave, btnExit.MouseLeave, btnCopy.MouseLeave, btnRightWord.MouseLeave, btnRightChar.MouseLeave, btnLeftWord.MouseLeave, btnLeftChar.MouseLeave, btnHome.MouseLeave, btnEnd.MouseLeave, btnT8.MouseLeave, btnT7.MouseLeave, btnT6.MouseLeave, btnT5.MouseLeave, btnT4.MouseLeave, btnT3.MouseLeave, btnT2.MouseLeave, btnT1.MouseLeave
Dim btn As Button = DirectCast(sender, Button)
btn.FlatStyle = FlatStyle.Standard
Dim GetCursorPos = Cursor.Position
If FormSettings.chbxBorderHover.Checked = True Then
For Each c As Control In Me.Controls.OfType(Of Button)()
If GetCursorPos.IntersectsWith(c.Bounds) Then
Cursor.Position = c.Location
Exit For
End If
Next
End If
End Sub
這是我到目前爲止,但intercectsWith
不與繪圖工作點
有沒有什麼辦法讓我檢查最接近的按鈕是什麼?
改變你的邏輯來測試邊界(Rect)是否包含這個點:'如果c.Bounds.Contains(Cursor.Position)'你可能必須先將光標轉換成座標首先 – Plutonix
As你通過控件循環,你將不得不計算Cursor.Location和c.Bounds之間的距離並找到距離最近的那個。如果c.Bounds.Contains(Cursor.Position)那麼遊標已經在控件中,並且你沒有任何事情要做。 – dwilliss
@dwilliss我該怎麼做? – Dman