导航:首页 > 五金知识 > vb中工具箱的快捷键是什么

vb中工具箱的快捷键是什么

发布时间:2022-05-28 12:17:43

1. vb按钮如何设置快捷键,

设置VB窗体中按扭快捷键的操作可以采用下面两种方法来实现:
1、在按扭的Capion 属性设置标题的时候,前面增加 "&K"字符就可以,K代表的是你准备使用的Alt+键盘字符,如“&O.退出”,程序运行的时候按下 Alt+O 即执行该按扭的操作了
2、你可以利用该按扭所在的Form 窗体优先权获得键盘操作功能来激发你要完成的按扭操作,此时首先要设置Form 的KeyPreview 属性值为 True,然后在 Form中KeyDown事件中判断你需要的组合键盘值来激发你的按扭事件.
Form_KeyDown事件中的各功能键值组合比较全面,如Shift,Alt 及Ctr等,一般都能满足快捷键的组合需求了.
Exp:
利用Ctrl+O组合键激发上面所说的按扭键,在Form_KeyDown事件中添加如下代码
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)

If Shift = 2 And KeyCode = 79 Then
btnQuit_Click()
End If

End Sub
btnQuit_Click()是退出程序按扭事件

2. VB中如何设置热键和快捷键

希望某一字符成为访问键,也可以在该字符前面加上一个 (&) 字符。

可以通过在 Caption 属性设置中使用 & 字符来为命令、菜单、和控件指定访问键。

要对菜单项赋值快捷键,请按照以下步骤执行:

1.打开“菜单编辑器”。

2.选取该菜单项。

3.在“快捷键”组合框中选取功能键或者键的组合。

要删除快捷键赋值,应选取列表顶部的"(none)"。

3. VB 如何设置快捷键

最简单的方法是按Ctrl+E打开菜单编辑器,然后设置个菜单项为退出什么的,设置其快捷键为Ctrl+D,勾选掉“可见”属性(如果是“不可见”属性请勾上)。然后运行就可以了。
还有的方法:(代码)
方法①:
Private
Sub
Form_KeyDown(KeyCode
As
Integer,
Shift
As
Integer)
Me.KeyPreview
=
True
If
KeyCode
=
vbKeyD
And
Shift
=
2
Then
End
End
Sub
方法②:
Private
Sub
Form_KeyUp(KeyCode
As
Integer,
Shift
As
Integer)
Me.KeyPreview
=
True
If
KeyCode
=
vbKeyD
And
Shift
=
2
Then
End
End
Sub
方法③:
Private
Sub
Form_KeyPress(KeyAscii
As
Integer)
If
KeyAscii
=
4
Then
End
End
Sub
方法①②③的灵敏度不一样,③里面的KeyAscii=4是Ctrl+D的Ascii值,是测试出来的。
至于Ascii值测试代码,只要将方法③的语句换为MsgBox
KeyAscii就行了

4. 不小心把vb右侧的属性窗口和工具箱窗口隐藏了。。怎么找出来。。怎么还原啊。,,,

[视图]这个菜单栏里找...或者按F4你会有惊喜

5. vb 快捷键

用 VB 实现全局热键模块
武汉 艾军
在软件报以前的文章中,虽然也介绍了如何用 VB 实现全局热键的方法,但是这些文章都只是针对初学者学习技巧而用,而在真正的程序编写中是不适应的,为了使我们编写的程序有继承性、维护性因此有必要制作一个实现全局热键的模块。
请大家看看下面调用全局热键的示例:
激活 3 个热键:(注:SetHotkey 是我自定义的函数)
SetHotkey 1, "Ctrl,112", "Add" 按 Ctrl+F1 激活指定程序
SetHotkey 2, 113, "Add" 按 F2 激活指定程序
SetHotkey 3, "Ctrl+Alt,113", "Add" 按 Ctrl+Alt+F2 激活指定程序
注释:注:关于激活热键后的操作,由自定义函数 SetHotkey 的 KeyId 传送的值来判断
注销 3 个热键:
SetHotkey 1, "", "Del" 退出程序是一定要用上的,不然会导至程序死掉
SetHotkey 2, "", "Del"
SetHotkey 3, "", "Del"
请大家新建一个模块(.bas)文件,自定义 SetHotkey函数及其他,这样在以后的任何程序中只要调用此模块就可以了。
注释:本模块是有关热键操作的
Option Explicit
Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long
Private Declare Function CallWindowProc Lib "user32" Alias "CallWindowProcA" (ByVal lpPrevWndFunc As Long, ByVal hwnd As Long, ByVal Msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Private Declare Function RegisterHotKey Lib "user32" (ByVal hwnd As Long, ByVal id As Long, ByVal fskey_Modifiers As Long, ByVal vk As Long) As Long
Private Declare Function UnregisterHotKey Lib "user32" (ByVal hwnd As Long, ByVal id As Long) As Long

Const WM_HOTKEY = &H312
Const MOD_ALT = &H1
Const MOD_CONTROL = &H2
Const MOD_SHIFT = &H4
Const GWL_WNDPROC = (-4) 注释:窗口函数的地址

Dim key_preWinProc As Long 注释:用来保存窗口信息
Dim key_Modifiers As Long, key_uVirtKey As Long, key_idHotKey As Long
Dim key_IsWinAddress As Boolean 注释:是否取得窗口信息的判断

Function keyWndproc(ByVal hwnd As Long, ByVal Msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long

If Msg = WM_HOTKEY Then
Select Case wParam 注释:wParam 值就是 key_idHotKey
Case 1 注释:激活 3 个热键后,3 个热键所对应的操作,大家在其他的程序中,只要修改此处就可以了
MsgBox "aa"
Case 2
MsgBox "bb"
Case 3
MsgBox "cc"
End Select
End If

注释:将消息传送给指定的窗口
keyWndproc = CallWindowProc(key_preWinProc, hwnd, Msg, wParam, lParam)

End Function

Function SetHotkey(ByVal KeyId As Long, ByVal KeyAss0 As String, ByVal Action As String)
Dim KeyAss1 As Long
Dim KeyAss2 As String
Dim i As Long

i = InStr(1, KeyAss0, ",")
If i = 0 Then
KeyAss1 = Val(KeyAss0)
KeyAss2 = ""
Else
KeyAss1 = Right(KeyAss0, Len(KeyAss0) - i)
KeyAss2 = Left(KeyAss0, i - 1)
End If

key_idHotKey = 0
key_Modifiers = 0
key_uVirtKey = 0

If key_IsWinAddress = False Then 注释:判断是否需要取得窗口信息,如果重复取得,再最后恢复窗口时,将会造成程序死掉
注释:记录原来的window程序地址
key_preWinProc = GetWindowLong(Form1.hwnd, GWL_WNDPROC)
注释:用自定义程序代替原来的window程序
SetWindowLong Form1.hwnd, GWL_WNDPROC, AddressOf keyWndproc
End If

key_idHotKey = KeyId
Select Case Action
Case "Add"
If KeyAss2 = "Ctrl" Then key_Modifiers = MOD_CONTROL
If KeyAss2 = "Alt" Then key_Modifiers = MOD_ALT
If KeyAss2 = "Shift" Then key_Modifiers = MOD_SHIFT
If KeyAss2 = "Ctrl+Alt" Then key_Modifiers = MOD_CONTROL + MOD_ALT
If KeyAss2 = "Ctrl+Shift" Then key_Modifiers = MOD_CONTROL + MOD_SHIFT
If KeyAss2 = "Ctrl+Alt+Shift" Then key_Modifiers = MOD_CONTROL + MOD_ALT + MOD_SHIFT
If KeyAss2 = "Shift+Alt" Then key_Modifiers = MOD_SHIFT + MOD_ALT
key_uVirtKey = Val(KeyAss1)
RegisterHotKey Form1.hwnd, key_idHotKey, key_Modifiers, key_uVirtKey 注释:向窗口注册系统热键
key_IsWinAddress = True 注释:不需要再取得窗口信息

Case "Del"
SetWindowLong Form1.hwnd, GWL_WNDPROC, key_preWinProc 注释:恢复窗口信息
UnregisterHotKey Form1.hwnd, key_uVirtKey 注释:取消系统热键
key_IsWinAddress = False 注释:可以再次取得窗口信息
End Select
End Function

6. vb中运行程序的快捷键是什么

vb中运行程序的快捷键是
F5

7. VB工具栏如何设置快捷键。急!

Private Sub Command1_Click()
MsgBox "您点击了command控件"
End Sub

Private Sub Form_KeyPress(KeyAscii As Integer)
If KeyAscii = 113 Then
Call Command1_Click
End If
End Sub

Private Sub Form_Load()
Form1.KeyPreview = True

End Sub
代码设置

8. vb中有那些快捷键

F4是属性窗口
F5是执行程序
F8是单步执行
F9设置断点
shift+F9可以监视表达式
alt+v+x可以快速显示出工具框
ctrl+F是查找窗口
Ctrl+g是立即窗口
ctrl+左右键头可以移动控件
shift+左右键头调整控件大小
ctrl+home jump to 首行
ctrl+end jump to 末尾
Shift+F2 到定义处
Ctrl+shift+F2 到上次编辑处
F7 切换到编辑窗口
Ctrl+W 编辑监视窗口

几个常用的:
ctrl+R 项目窗口
F4 属性窗口
ctrl+G 立即窗口
ctrl+E 菜单编辑器
F9 断点
Ctrl+I 查看定义,参数属性等

9. vb快捷键

把下面代码放到标注模块里,通过里面的函数注册系统级的热键
Option Explicit
'这部分代码 放在标准模块里 也就是一般说的BAS模块
'为应用程序增加热键功能。结合子类技术,用自己定义的窗口消息处理函数,响应热键操作
Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long
Declare Function CallWindowProc Lib "user32" Alias "CallWindowProcA" (ByVal lpPrevWndFunc As Long, ByVal hwnd As Long, ByVal Msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Declare Function RegisterHotKey Lib "user32" (ByVal hwnd As Long, ByVal id As Long, ByVal fsModifiers As Long, ByVal vk As Long) As Long
Declare Function UnregisterHotKey Lib "user32" (ByVal hwnd As Long, ByVal id As Long) As Long
Declare Function GlobalAddAtom Lib "kernel32" Alias "GlobalAddAtomA" (ByVal lpString As String) As Integer
Declare Function ShowWindow Lib "user32" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long
Declare Function SetForegroundWindow Lib "user32" (ByVal hwnd As Long) As Long
Declare Function GetTickCount Lib "kernel32" () As Long

Public Const WM_HOTKEY = &H312
Public Const MOD_ALT = &H1
Public Const MOD_CONTROL = &H2
Public Const MOD_SHIFT = &H4

Public Const GWL_WNDPROC = (-4)
Public Const SW_SHOW = 5

Public preWinProc As Long '保存窗口原来的消息处理函数地址
Public idHotKey As Long '保存热键的唯一性标识id
Public Modifiers As Long '保存辅助键组合信息 比如CTRL+A中的CTRL
Public uVirtKey As Long '保存虚拟键信息 比如CTRL+A中的A
Public strHotKey As String '热键的表达式

Public Function WindowProc(ByVal hwnd As Long, ByVal Msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
'自定义窗口消息处理函数,拦截窗口热键消息,执行自己定义的操作
If Msg = WM_HOTKEY Then '有热键消息
If wParam = idHotKey Then '核对唯一性标识
'ShowWindow hwnd, SW_SHOW '执行自定义操作(本例为显示本程序窗口)

SetWindowPos hwnd, HWND_TOP, 0, 0, 200, 200, SWP_SHOWWINDOW Or SWP_NOMOVE Or SWP_NOSIZE
If blnTrayIcon Then RemoveFromTray: blnTrayIcon = False
If frmMain.WindowState = 1 Then frmMain.WindowState = 0

SetForegroundWindow hwnd
End If
End If
'如果不是热键信息则调用原来的消息处理程序
WindowProc = CallWindowProc(preWinProc, hwnd, Msg, wParam, lParam)
End Function

Public Function SetMyHotKey(ByVal hwnd As Long) As String
'设置热键并保证唯一性,基本规则是CTRL+ALT+(A~Z)。
'注册热键;修改窗口消息函数为自定义函数
'返回热键组合的文字描述,用于显示给用户看
preWinProc = GetWindowLong(hwnd, GWL_WNDPROC) '获得原来的窗口消息函数地址
SetWindowLong hwnd, GWL_WNDPROC, AddressOf WindowProc '用自定义函数代替原来的窗口消息函数
Modifiers = MOD_CONTROL + MOD_ALT
idHotKey = GlobalAddAtom(Format(GetTickCount)) '获得可用的ID号
For uVirtKey = vbKeyA To vbKeyZ '从A-Z找到一个可用的热键组合
If RegisterHotKey(hwnd, idHotKey, Modifiers, uVirtKey) Then Exit For
Next
SetMyHotKey = "CTRL + ALT + " + Chr(uVirtKey)
End Function

Public Function DelMyHotKey(ByVal hwnd As Long) As Long
'注销热键
UnregisterHotKey hwnd, idHotKey '注销热键
SetWindowLong hwnd, GWL_WNDPROC, preWinProc '恢复窗口默认的消息函数
End Function

10. VB左边的工具栏被我关掉了怎么打开

1、首先打来开需要操作的VB应用程序,进自入到操作界面中。

阅读全文

与vb中工具箱的快捷键是什么相关的资料

热点内容
轴承3216h代表什么意思 浏览:586
宝马防爆胎总是爆胎 浏览:182
无锡雪桃导热设备公司怎么样 浏览:667
东莞飞达五金制品厂 浏览:515
不锈钢刨槽多少钱一米价格 浏览:996
东莞高德电动工具有限公司 浏览:181
南阳的五金市场 浏览:406
什么仪器可以代替蒸汽 浏览:311
vivo自带的膜是防爆膜 浏览:203
防爆场所电气施工控制措施 浏览:950
玻璃贴防爆膜的效果图 浏览:582
锡安达防爆电机怎么样 浏览:785
防爆电机的特点 浏览:73
防爆电气电线安装规范 浏览:333
上海竞佳机械有限公司怎么样 浏览:769
汽车仪表spn是什么意思 浏览:186
设备商品编号怎么编 浏览:827
南通恒兴机械有限公司怎么样 浏览:609
机械领袖键盘怎么开背光 浏览:578
中国移动用户端设备线怎么插 浏览:351