Form Keypress events trapped twice ????

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • alma27
    New Member
    • Mar 2008
    • 3

    Form Keypress events trapped twice ????

    I discovered that when a Forn Keydown Event Or Form KeyPress event happens
    Each character is trapped twice on the same Event routine.
    I use VB6, and my form has KeyPreview property = TRUE.
    I was debugging a bug concerning use of card Reader, and while entering the
    code I found out it works this way.

    (When the card is passed correctly with focus on the right field, I get the txtField_keypre ss and KeyDown events, that are evoked only once each.)

    But I have a case in which the txtFields events are not evoked, just the Form Keys events.
    How can I avoid it from happening twice? Why does it happen?
  • debasisdas
    Recognized Expert Expert
    • Dec 2006
    • 8119

    #2
    From your post i am not sure what exactly you are trying to do.

    Comment

    • alma27
      New Member
      • Mar 2008
      • 3

      #3
      I am debugging a little problem on a project.
      There is a situation that only the form traps the key events (because the user does not put the cursor , where he should, so the control events don't trigger) and I must trap this situation and fix it.
      While debugging I found out every time a character is entered (by a card, through a card reader) the Form_KeyPress event is triggered twice, as well as the Form_KeyDown and Form_KeyUp.
      I don't understand why?

      I guess to test this it is enough to have a Form_keypress routine, and no textbox-keypress routine. So the Form routine will be triggered (if Keypreview=true ) Maybe it won't happen to you, but it does to me.
      I tried testing the EXE file as well, thinking maybe it is like a bug when running VB not through EXE.

      Comment

      • alma27
        New Member
        • Mar 2008
        • 3

        #4
        I created a small project and tested events from Form_keypress
        and either if I typed the characters or passed the magnetic card, each character evoked each event ONLY once.

        But When I run the large project I work on, every FORM Key event is called twice per each character .
        I don't even know where to look for the problem.
        Has anybody run into something like this ?????

        Comment

        Working...