新建一個Form1把Form1的KeyPreview改成True
創(chuàng)新互聯(lián)堅持“要么做到,要么別承諾”的工作理念,服務(wù)領(lǐng)域包括:做網(wǎng)站、成都網(wǎng)站制作、企業(yè)官網(wǎng)、英文網(wǎng)站、手機(jī)端網(wǎng)站、網(wǎng)站推廣等服務(wù),滿足客戶于互聯(lián)網(wǎng)時代的托克托網(wǎng)站設(shè)計、移動媒體設(shè)計的需求,幫助企業(yè)找到有效的互聯(lián)網(wǎng)解決方案。努力成為您成熟可靠的網(wǎng)絡(luò)建設(shè)合作伙伴!
拖入一個Button1到Form1上面
然后加入以下代碼
Private
Sub
Form1_KeyDown(sender
As
Object,
e
As
KeyEventArgs)
Handles
Me.KeyDown
If
e.KeyData
=
(Keys.Alt
Or
Keys.G)
Then
Button1.PerformClick()
'或者用Button1_Click(Nothing,
New
EventArgs)
'快捷鍵Alt+G觸發(fā)Button1_Click()事件。
End
If
End
Sub
Private
Sub
Button1_Click(sender
As
Object,
e
As
EventArgs)
Handles
Button1.Click
Button1.Size
=
New
Size(180,
23)
Button1.Text
=
"我被局部快捷鍵給召喚了~"
End
Sub
新建窗口,添加picture控件
利用line()方法畫線
line(開始x坐標(biāo),開始y坐標(biāo))-(結(jié)束x坐標(biāo),結(jié)束y坐標(biāo)),線的顏色,畫線的方式(默認(rèn)為線,B為矩形無填充,BF為填充的矩形)
For i = 1 To 16
Picture1.Line (0, Picture1.Height / 2)-(i * (Picture1.Width / 16), 0), RGB(255, 0, 0)
Picture1.Line (0, Picture1.Height / 2)-(i * (Picture1.Width / 16), Picture1.Height), RGB(255, 0, 0)
Picture1.Line (Picture1.Width, Picture1.Height / 2)-(i * (Picture1.Width / 16), 0), RGB(0, 255, 0)
Picture1.Line (Picture1.Width, Picture1.Height / 2)-(i * (Picture1.Width / 16), Picture1.Height), RGB(0, 255, 0)
Next i
如果要在窗口上畫也可以調(diào)用窗口的line方法即form.line()
選到TextBox1的keydown方法,然后val=keycode不行么?
焦點在哪個控件,哪個控件就會有keydown,沒有焦點也就不會有。
1. F12:轉(zhuǎn)到定義;Shift+F12:轉(zhuǎn)到引用
2. F5:啟動;Ctrl+F5:開始執(zhí)行(不調(diào)試);Shift+F5:停止調(diào)試
3. F7:查看代碼;Shift+F7:查看視圖設(shè)計器
4. Ctrl+Alt+L:解決方案資源管理器
5. Ctrl+Alt+J:對象瀏覽器
6. F4:顯示屬性窗口
7. Ctrl+Alt+X:工具箱
8. Ctrl+Alt+C類視圖
9. Alt+Enter:查看屬性
10.F10:逐過程調(diào)試
11.F11:逐語句調(diào)試
12.Ctrl+B:新斷點
13.Ctrl+Shift+F9:清除所有斷點
14.Ctrl+Shift+B生成解決方案
15.Shift+Alt+Enter:全屏
16.大綱顯示:Ctrl+M, Ctrl+M:切換大綱顯示展開;Ctrl+M, Ctrl+L:切換所有大綱顯示;Ctrl+M,Crtl+P停止大綱顯示;Ctrl+M, Ctrl+O:折疊到定義
17.智能感知:Ctrl+J:列出成員;Ctrl+Shift+空格:參數(shù)信息; Ctrl+K,Ctrl+I:快速信息;Alt+右箭頭鍵:完成單詞
見下面的代碼
Public?Class?Form1
Public?Declare?Auto?Function?RegisterHotKey?Lib?"user32.dll"?Alias?"RegisterHotKey"?(ByVal?hwnd?As?IntPtr,?ByVal?id?As?Integer,?ByVal?fsModifiers?As?Integer,?ByVal?vk?As?Integer)?As?Boolean
Public?Declare?Auto?Function?UnRegisterHotKey?Lib?"user32.dll"?Alias?"UnregisterHotKey"?(ByVal?hwnd?As?IntPtr,?ByVal?id?As?Integer)?As?Boolean
Private?Sub?Form1_Load(ByVal?sender?As?System.Object,?ByVal?e?As?System.EventArgs)?Handles?MyBase.Load
'注冊全局熱鍵?
RegisterHotKey(Handle,?0,?0,?Keys.F4)
'第3個參數(shù)意義:?0=nothing?1?-alt?2-ctrl?3-ctrl+alt?4-shift?5-alt+shift?6-ctrl+shift?7-ctrl+shift+alt
End?Sub
Private?Sub?Form1_Closed(ByVal?sender?As?Object,?ByVal?e?As?System.EventArgs)?Handles?MyBase.Closed
UnRegisterHotKey(Handle,?0)
End?Sub
Protected?Overrides?Sub?WndProc(ByRef?m?As?Message)
If?m.Msg?=?786?Then
Me.Activate()
End?If
MyBase.WndProc(m)
End?Sub
End?Class