1

In my VB6 program, I have tons of hotkeys such as X, A, D... ETC . I also have a chat system in it, where everytime I use the characters X or A it will do the actions of those hotkeys. For example, if X was to close the application (not that it really does), when I am typing "fiXing" into my chat textbox, it will close the application. Can anyone tell me how to disable the hotkeys when typing EXCEPT the Enter Key?

thanks,

Kevin

4

2 に答える 2

1

チャットTextBoxGotFocusイベントで、ホットキーを無効にするフラグを設定します。TextBox次に、のLostFocusイベントでそれらを再度有効にします。

ホットキーをトラップする方法はわかりませんが、フラグを設定するコードは非常に単純です。

Private suppressHotkeys As Boolean

Private Sub txtChat_GotFocus()
  suppressHotkeys = True
End Sub

Private Sub txtChat_LostFocus()
  suppressHotkeys = False
End Sub

次に、ホットキーをトラップするコードで、フラグを確認します。

If (Not suppressHotkeys) Then
  //process hotkey
End If
于 2009-12-30T16:51:18.573 に答える
0

ホットキーにキーの組み合わせを使用することをお勧めします。Ctrl+XまたはAlt+と言う方が一般的Xです。KeyDown または KeyUp イベントのいずれかでそれらをテストします。

If KeyCode = vbKeyX And (Shift And vbCtrlMask = vbCtrlMask) Then
    ' Do something
End If
于 2009-12-30T18:04:42.940 に答える