Wrox Home  
Search P2P Archive for: Go

  Return to Index  

pro_vb thread: Re: trapping for system HotKeys Continued


Message #1 by "Vishal Gandhi" <vishalgandhi@m...> on Sat, 12 May 2001 15:25:06 +0530
HotKeyControl form

Option Explicit
Public Event hotkeypressed()

Public Property Get AltKey() As Boolean
AltKey = tAltsel
End Property

Public Property Let AltKey(ByVal vNewValue As Boolean)
tAltsel = vNewValue
Call UpdateHotKey
End Property

Public Property Get CtrlKey() As Boolean
CtrlKey = tCtrlsel
End Property

Public Property Let CtrlKey(ByVal vNewValue As Boolean)
tCtrlsel = vNewValue
Call UpdateHotKey
End Property

Public Property Get ShiftKey() As Boolean
ShiftKey = tShiftsel
End Property

Public Property Let ShiftKey(ByVal vNewValue As Boolean)
tShiftsel = vNewValue
Call UpdateHotKey
End Property

Public Property Get WinKey() As Boolean
WinKey = tWinsel
End Property

Public Property Let WinKey(ByVal vNewValue As Boolean)
tWinsel = vNewValue
Call UpdateHotKey
End Property

Public Property Get Character() As KeyCodeConstants
Character = tCharacter
End Property

Public Property Let Character(ByVal vNewValue As KeyCodeConstants)
tCharacter = vNewValue
Call UpdateHotKey
End Property

Public Property Get HotKeyEnabled() As Boolean
HotKeyEnabled = tHotKeyEnabled
End Property

Public Property Let HotKeyEnabled(ByVal vNewValue As Boolean)
tHotKeyEnabled = vNewValue
Call UpdateHotKey
End Property

Public Property Get hwnd() As Long
hwnd = tHWnd
End Property

Public Property Let hwnd(ByVal vNewValue As Long)
tHWnd = vNewValue
Call UpdateHotKey
End Property

Public Sub SetupHotKey(lHWnd As Long, bCtrlKey As Boolean, bAltKey As
Boolean, bshiftkey As Boolean, bwinkey As Boolean, kCharacter As
KeyCodeConstants)
tHWnd = lHWnd
tCtrlsel = bCtrlKey
tAltsel = bAltKey
tShiftsel = bshiftkey
tWinsel = bwinkey
tCharacter = kCharacter
tHotKeyEnabled = True
Call UpdateHotKey
End Sub

Public Sub RemoveHotKey()
KillHotKey
tHotKeyEnabled = False
End Sub

Private Sub UserControl_Initialize()
Set objref = Me
End Sub

Private Sub UserControl_InitProperties()
tAltsel = False
tCtrlsel = False
tShiftsel = False
tWinsel = False
tHWnd = 0
tHotKeyEnabled = False
tCharacter = vbKeyA
End Sub

Private Sub UserControl_ReadProperties(PropBag As PropertyBag)
With PropBag
  tAltsel = .ReadProperty("AltKey", False)
  tCtrlsel = .ReadProperty("CtrlKey", False)
  tShiftsel = .ReadProperty("ShiftKey", False)
  tWinsel = .ReadProperty("WindowsKey", False)
  tHWnd = .ReadProperty("Window Handle", 0)
  tCharacter = .ReadProperty("Character", vbKeyA)
  tHotKeyEnabled = .ReadProperty("HotKeyEnabled", False)
End With
End Sub

Private Sub UserControl_WriteProperties(PropBag As PropertyBag)
With PropBag
  .WriteProperty "AltKey", tAltsel, False
  .WriteProperty "CtrlKey", tCtrlsel, False
  .WriteProperty "ShiftKey", tShiftsel, False
  .WriteProperty "WindowsKey", tWinsel, False
  .WriteProperty "Window Handle", tHWnd, 0
  .WriteProperty "Character", tCharacter, vbKeyA
  .WriteProperty "HotKeyEnabled", tHotKeyEnabled, False
End With
End Sub

Private Sub UserControl_Resize()
Width = Image1.Width
Height = Image1.Height
End Sub

Private Sub UserControl_Terminate()
KillHotKey
Set objref = Nothing
End Sub

Public Sub HKPressed()
RaiseEvent hotkeypressed
End Sub

Public Sub About()

MsgBox "Hotkey demo project." & vbNewLine & "For more demos, visit " & URL

End Sub

----- Original Message -----
From: "Dennis Pienaar" <dennis@c...>
To: "professional vb" <pro_vb@p...>
Sent: Friday, May 11, 2001 3:51 PM
Subject: [pro_vb] trapping for system HotKeys


> Hi Group
> I have received a request from a client to trap system-wide hotkeys
> throughout a win9x session. The service should monitor for certain key
> combos and react when applicable. My only problem with this is how to
> implement it. Does anyone know if there are any api calls available to
trap
> keys.
>
> Any ideas will be appreciated
>
> thanks in advance
>
>

  Return to Index