• 您的位置我爱Aspx >> VB.Net >> 使用VB在应用程序中注册热键
  • 使用VB在应用程序中注册热键

  • 作者:aspxer  来源:internet  日期:2007-5-20 13:58:46  关键字:
  • 使用VB在应用程序中注册热键

    Option Explicit

    Private Sub Form_Load()

    Dim ret As Long

    @#记录原来的window程序地址

    preWinProc = GetWindowLong(Me.hWnd, GWL_WNDPROC)

    @#用自定义程序代替原来的window程序

    ret = SetWindowLong(Me.hWnd, GWL_WNDPROC, AddressOf wndproc)

    idHotKey = 1 @#in the range &h0000 through &hBFFF

    Modifiers = MOD_ALT @#辅助键为Alt

    uVirtKey1 = vbKeyQ @#注册的热键为Alt+Q

    @#注册热键

    ret = RegisterHotKey(Me.hWnd, idHotKey, Modifiers, uVirtKey1)

    If ret = 0 Then

    MsgBox "注册热键失败,请使用其它热键!", vbCritical, "错误"

    End If

    End Sub

    Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)

    Dim ret As Long

    @#取消Message的截取,使之送往原来的window程序

    ret = SetWindowLong(Me.hWnd, GWL_WNDPROC, preWinProc)

    Call UnregisterHotKey(Me.hWnd, uVirtKey1)

    我对这篇文章有话说?
  • 广告位招租,广告代号:content_468_15
  • 上一篇:VB: 制作下雪的特技景象
    下一篇:VB打造超酷个性化菜单(一)
  • 相关文章