Click here to Skip to main content
15,903,201 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
Im using VB6 to create an app, I want to prevent and destroy WM_KEYDOWN message in TextBox control, when I press key 'a' in this TextBox then I want to destroy this key ('a'), in my opinion I prevent WM_KEYDOWN with wParam=keycode of 'a', then I destroy it, but Im not sucessful. Please help me solve this problem. Thanks. (I want to use a Hook).
Posted

1 solution

Try like this:

Code assumes that the text box is named textBox1

VB
Private Sub textBox1_KeyPress(KeyAscii As Integer)
    If (KeyAscii >> ASC("a") AND KeyAscii <> ASC("A") Then
        Exit Sub
    Else
        KeyAscii = 0
    End If
End Sub


This procedure needs to be hooked up to the keypress event.

Best Regards,

-MRB
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900