很久没用vb了,做了个小东西,用着还挺顺手的 :)
frmmain.frm
'---------------------------------------------------------------------------------------
' Author :阿汐
' Purpose :vb实现老板键的简单功能
'---------------------------------------------------------------------------------------
Sub Form_Load() Sub Form_Load()
Dim ret As Long
preWinProc = GetWindowLong(Me.hwnd, GWL_WNDPROC)
ret = SetWindowLong(Me.hwnd, GWL_WNDPROC, AddressOf Wndproc)
idHotKey = 1
'按住ctrl+q实现切换
Modifiers = MOD_CONTROL
uVirtKey = vbKeyQ
ret = RegisterHotKey(Me.hwnd, idHotKey, Modifiers, uVirtKey)
'最小花到托盘
TrayAddIcon frmmain, App.Path & "pbs.ico", "系统托盘"
End Sub
Sub Form_Unload() Sub Form_Unload(Cancel As Integer)
Dim ret As Long
ret = SetWindowLong(Me.hwnd, GWL_WNDPROC, preWinProc)
Call UnregisterHotKey(Me.hwnd, uVirtKey)
'退出时移出托盘图标
TrayRemoveIcon
End Sub
Sub Form_Resize() Sub Form_Resize()
'窗口最小化
If Me.WindowState = vbMinimized Then Me.Hide
End Sub
Sub Form_MouseMove() Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
'气泡单击时的鼠标事件
Dim Result As Long
Dim cEvent As Single
cEvent = X / Screen.TwipsPerPixelX
Select Case cEvent
Case MouseMove
TrayBalloon frmmain, "一键隐藏程序 v0.1 By 阿汐", NIIF_INFO
Case LeftUp
Case LeftDown
frmmain.WindowState = 0
frmmain.Show
Case LeftDbClick
Case MiddleUp
Case MiddleDown
Case MiddleDbClick
Case RightUp
Case RightDown
Case RightDbClick
Case BalloonClick
End Select
End Sub
Sub Label1_Click() Sub Label1_Click()
End Sub
Sub Label2_Click() Sub Label2_Click()
End Sub