|
Option Explicit
Private Declare Function SystemParametersInfo Lib "user32" _
Alias "SystemParametersInfoA" (ByVal uAction As Long, _
ByVal uParam As Long, lpvParam As Any, _
ByVal fuWinIni As Long) As Long
Private Declare Function SystemParametersInfoByVal Lib "user32" _
Alias "SystemParametersInfoA" (ByVal uAction As Long, _
ByVal uParam As Long, ByVal lpvParam As Any, _
ByVal fuWinIni As Long) As Long
Private Const SPI_GETKEYBOARDDELAY = 22
Private Const SPI_GETKEYBOARDSPEED = 10
Private Const SPI_SETKEYBOARDDELAY = 23
Private Const SPI_SETKEYBOARDSPEED = 11
Private Const KEY_LEFT = &H25
Private Const KEY_RIGHT = &H27
Private m_KeyboardSpeed As Long
Private m_KeyboardDelay As Long
Private m_boolChanged As Boolean
Private Sub Form_Load()
On Error Resume Next
Picture1.ScaleMode = vbPixels
Me.Show
hsbStep.Min = 1
hsbStep.Max = 10
hsbSpeed.Max = 31
hsbDelay.Max = 3
GetKeyboarddata
hsbSpeed.Value = m_KeyboardSpeed
lblSpeed.Caption = CStr(m_KeyboardSpeed)
hsbDelay.Value = m_KeyboardDelay
lblDelay.Caption = CStr(m_KeyboardDelay)
End Sub
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
Dim Increment As Long
Increment = hsbStep.Value
Select Case KeyCode
Case KEY_RIGHT
imgIcon.Left = imgIcon.Left + Increment
If (imgIcon.Left) > Picture1.ScaleWidth Then
imgIcon.Left = -imgIcon.Width
End If
Case KEY_LEFT
imgIcon.Left = imgIcon.Left - Increment
If imgIcon.Left < -imgIcon.Width Then
imgIcon.Left = Picture1.ScaleWidth
End If
Case Else
End Select
End Sub
Private Sub hsbStep_Change()
lblIncrement.Caption = CStr(hsbStep.Value)
Picture1.SetFocus
End Sub
Private Sub hsbSpeed_Change()
ScrollChange
End Sub
Private Sub hsbDelay_Change()
ScrollChange
End Sub
Private Sub ScrollChange()
SetKeyboardData hsbSpeed.Value, hsbDelay.Value
lblSpeed.Caption = CStr(hsbSpeed.Value)
lblDelay.Caption = CStr(hsbDelay.Value)
Picture1.SetFocus
End Sub
Private Sub GetKeyboarddata()
Dim rc As Long
rc = SystemParametersInfo( _
SPI_GETKEYBOARDSPEED, 0, m_KeyboardSpeed, 0&)
rc = SystemParametersInfo( _
SPI_GETKEYBOARDDELAY, 0, m_KeyboardDelay, 0&)
End Sub
Private Sub SetKeyboardData(KeySpeed, KeyDelay)
Dim rc As Long
rc = SystemParametersInfoByVal( _
SPI_SETKEYBOARDSPEED, KeySpeed, 0&, 1&)
rc = SystemParametersInfoByVal( _
SPI_SETKEYBOARDDELAY, KeyDelay, 0&, 1&)
End Sub
Private Sub cmdSetValues_Click()
If MsgBox("Die Tastatureinstellungen werden neu gesetzt." & _
vbCrLf & "Sind sie sicher ?", vbYesNo + vbQuestion, _
Form1.Caption) = vbYes Then
SetKeyboardData hsbSpeed.Value, hsbDelay.Value
m_boolChanged = True
End If
End Sub
Private Sub Form_QueryUnload(Cancel As Integer, _
UnloadMode As Integer)
If Not m_boolChanged Then
SetKeyboardData m_KeyboardSpeed, m_KeyboardDelay
End If
End Sub
|
|