当前位置: 网学 > 编程文档 > VB > 正文

“一键功能”的设计、实现与应用

来源:Http://myeducs.cn 联系QQ:点击这里给我发消息 作者: 用户投稿 来源: 网络 发布时间: 12/10/16
下载{$ArticleTitle}原创论文样式
If
End Sub

Private Sub cmbChooseKey_KeyUp(Index As Integer, KeyCode As Integer, Shift As Integer)
unLockcombobox
End Sub

''把键面字符转变成相应的键盘扫描码
Private Function strKeyToLong(strKey As String) As Integer
Dim i As Long
Select Case strKey
Case "F2"
i = vbKeyF2
Case "F3"
i = vbKeyF3
Case "F4"
i = vbKeyF4
Case "F5"
i = vbKeyF5
Case "F6"
i = vbKeyF6
Case "F7"
i = vbKeyF7
Case "F8"
i = vbKeyF8
Case "F9"
i = vbKeyF9
Case "F10"
i = vbKeyF10
Case "F11"
i = vbKeyF11
End Select
strKeyToLong = i
End Function

Private Sub cmbChooseKey_Click(Index As Integer)
''禁止重复定义快捷键
RedefineFuncKey cmbChooseKey(Index).Text, Index
End Sub

Private Sub cmdAdd_Click()
Dim strFileName As String
If cmbChooseKey(5).Text = "无" Or cmbChooseKey(5).Text = "" Then
MsgBox "请先为应用程序定义一个快捷键", vbInformation, "提示"
Else
cmnAdd.DialogTitle = "添加"
cmnAdd.Filter = "可执行文件(*.exe)|*.exe" ''在添加对话框中只显示EXE文件
cmnAdd.ShowOpen ''打开添加对话框
strFileName = cmnAdd.FileName
''把定义的快捷键和应用程序添加到列表框中
If strFileName <> "" Then
List1.AddItem cmbChooseKey(5).Text + " " + cmnAdd.FileName
End If
cmbChooseKey(5).Text = "无"
End If
End Sub

Private Sub cmdApply_Click()
Dim strKeyJoin As String, strKeyFile As String
strKeyJoin = ""
strKeyFile = ""
''把特定功能区定义的快捷键以逗号为分隔符写入FunctionKey.txt文件
For i = 0 To 4
If i < 4 Then
strKeyJoin = strKeyJoin & Trim(cmbChooseKey(i).Text) & ","
Else
strKeyJoin = strKeyJoin & Trim(cmbChooseKey(i).Text)
End If
Next
Open App.Path + "\FunctionKey.txt" For Output As #1
Print #1, strKeyJoin
Close #1
''如果在列表框中有应用程序名和快捷键且检测CustomKey.txt,则删除该文件;
If List1.ListCount = 0 And Dir(App.Path + "\CustomKey.txt") <> "" Then
Kill App.Path + "\CustomKey.txt"
''把定义的快捷键及应用程序以逗号为分隔符写入CustomKey.txt文件
ElseIf List1.ListCount <> 0 Then
For i = 0 To List1.ListCount - 1
If i < List1.ListCount - 1 Then
rKeyFile = strKeyFile + List1.List(i) + ","
Else
strKeyFile = strKeyFile + List1.List(i)
End If
Next
Open App.Path + "\CustomKey.txt" For Output As #1
Print #1, strKeyFile
Close #1
End If
List1.Clear
''重新从FunctionKey.txt和CustomKey.txt文件中取得定义的快捷键及相应的应用程序名供程序使用
Form_Load
End Sub

Private Sub cmdCancel_Click()
Unload Me
End Sub

''删除列表框中选中的快捷键和应用程序名
Private Sub cmdDel_Click()
List1.RemoveItem List1.ListIndex
End Sub

Private Sub cmdOk_Click()
cmdApply_Click ''调用"应用"按钮下的代码
Me.Visible = False
End Sub

Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
''按快捷键A调用"应用"按钮下的代码
If KeyCode = vbKeyA Then
cmdApply_Click
End If
End Sub

Private Sub Form_Load()
Dim strLine As String
''把F2~F11和"无"分别添加到组合框控件数组的下拉列表框和文本框中
For i = 0 To 5
cmbChooseKey(i).Text =

网学推荐

免费论文

原创论文

浏览:
设为首页 | 加入收藏 | 论文首页 | 论文专题 | 设计下载 | 网学软件 | 论文模板 | 论文资源 | 程序设计 | 关于网学 | 站内搜索 | 网学留言 | 友情链接 | 资料中心
版权所有 QQ:3710167 邮箱:3710167@qq.com 网学网 [Myeducs.cn] 您电脑的分辨率是 像素
Copyright 2008-2015 myeducs.Cn www.myeducs.Cn All Rights Reserved
湘ICP备09003080号