Link to home
Start Free TrialLog in
Avatar of Richard2000
Richard2000

asked on

KeyDown event fires twice with SSTab - Any work-around?

There is a bug with the SSTab which causes the KeyDown event to fire twice.  I'm using VB 4 and the latest version of the SSTab control for VB 4.  This bug is causing havoc with my program!!  I have a form with a SSTab on it and when the user presses F2, I use the KeyDown event to show a modal dialog.  Because of this bug, the dialog is actually shown twice!

How do I get around this problem?  Note that the event only fires twice when the tabs at the top have the focus.  A way around this problem could be to block the second event; but I am worried about future compatibility.  For example, if a new version of the control is realeased which my end users have installed on their machine which doesn't contain the bug, the work-around could break my program.  

Thanks for your help.
Avatar of MikeP090797
MikeP090797

Set .KeyPreview of the form to True, and process the form_keydown event
Avatar of Richard2000

ASKER

MikeP,

Thanks for your answer.  Unfortunately, I *HAD* been using the KeyDown event of the *FORM* which is where the problem occurs.  It seems that whenever a SSTab is on a form, the KeyDown event of the form will fire twice when a tab on a SSTab has the focus.
You can use a global variable, set it to True before .Show 1, and to False after it. Before setting it to true, check if it is already true, and exit if it is. I dont see how this can cause compatibility problem
MikeP,

I had some problems getting this technique to work.  I have found a work-around myself - simply enter KeyCode = 0 at the end of the form_keydown event.  This ensures the event will only fire once.  Please lock the question and I will give you the points for making some suggestions :-)
Since my suggestions weren't too helpfull, better delete the questions, and get the points back
ASKER CERTIFIED SOLUTION
Avatar of jonder
jonder

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial