http://www.vbforums.com/showthread.php?508872-on-screen-keyboard-using-VB6
Private Sub cmdKey_Click(Index As Integer)
Static boShift As Boolean
Dim strInput As String
Dim intASC As Integer
If Index = 1 Then
boShift = Not boShift
If boShift = True Then
cmdKey(1).Caption = "SHIFT (ON)"
Else
cmdKey(1).Caption = "SHIFT (OFF)"
End If
Else
If boShift = True Then
intASC = Index
Else
intASC = Index + (Asc("a") - Asc("A"))
End If
If Index = 32 Then intASC = Index
strInput = Chr(intASC)
Text1.Text = Text1.Text & strInput
End If
End Sub
Private Sub Form_Load()
Dim intI As Integer
cmdKey(0).Left = 240
cmdKey(0).Top = 360
cmdKey(0).Width = 495
cmdKey(0).Height = 375
Me.Width = (26 * (cmdKey(0).Width + 50)) + (2 * cmdKey(0).Left)
For intI = Asc("A") To Asc("Z")
Load cmdKey(intI)
cmdKey(intI).Caption = Chr(intI)
If intI = 65 Then
cmdKey(intI).Left = 240
cmdKey(intI).Top = 360
Else
cmdKey(intI).Left = cmdKey(intI - 1).Left + cmdKey(intI - 1).Width + 50
cmdKey(intI).Top = cmdKey(intI - 1).Top
End If
cmdKey(intI).Visible = True
Next intI
'
' Space Bar
'
Load cmdKey(32)
cmdKey(32).Caption = "Space"
cmdKey(32).Top = cmdKey(0).Top + cmdKey(0).Height + 50
cmdKey(32).Width = 6375
cmdKey(32).Visible = True
cmdKey(32).Left = (Me.Width / 2) - (cmdKey(32).Width / 2)
'
' Shift Key
'
Load cmdKey(1)
cmdKey(1).Caption = "SHIFT (OFF)"
cmdKey(1).Top = cmdKey(0).Top + cmdKey(0).Height + 50
cmdKey(1).Left = cmdKey(0).Left
cmdKey(1).Width = 1455
cmdKey(1).Visible = True
End Sub
No comments:
Post a Comment