I found a small bug in some sample code. It does not stop the example from working but does stop it being extended. The fix is shown below:
Public Sub UnregisterKey( _
ByVal sName As String _
)
Dim lIndex As Long
Dim i As Long
lIndex = AtomIndex(sName)
If (lIndex > 0) Then
' Unregister the key:
UnregisterHotKey m_hWnd, m_tAtoms(lIndex).lID
' Unregister the atom:
GlobalDeleteAtom m_tAtoms(lIndex).lID
' Remove from internal array:
If (m_iAtomCount > 1) Then
For i = lIndex To m_iAtomCount - 1
'
' OLD CODE LSet m_tAtoms(lIndex ) = m_tAtoms(lIndex + 1)
' Should read as below.
'
LSet m_tAtoms(i) = m_tAtoms(i + 1)
Next i
m_iAtomCount = m_iAtomCount - 1
ReDim Preserve m_tAtoms(1 To m_iAtomCount) As tHotKeyInfo
Else
m_iAtomCount = 0
Erase m_tAtoms
End If
End If
End Sub
|