标签:
如果把窗体的KeyPreview属性设为True,那么窗体将比其内的控件优先获得键盘事件的激活权。比如窗体Form1和其内的文本框Text1都准备响应KeyPress事件,那么以下代码将首先激活窗体的KeyPress事件:
Private Sub Form_Load()
Me.KeyPreview = True
End Sub
Private Sub Form_KeyPress(KeyAscii As Integer)
MsgBox "这是窗体的KeyPress事件"
End Sub
Private Sub Text1_KeyPress(KeyAscii As Integer)
MsgBox "这是文本框的KeyPress事件"
End Sub
窗体的keypreview属性的作用是什么?(设置快捷键和钩子)
标签:
原文地址:http://www.cnblogs.com/qqhfeng/p/5463365.html