Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 1998-09-13
6
Medium Priority
?
394 Views
Last Modified: 2011-10-03
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.
0
Comment
Question by:Richard2000
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 8

Expert Comment

by:MikeP090797
ID: 1434622
Set .KeyPreview of the form to True, and process the form_keydown event
0
 

Author Comment

by:Richard2000
ID: 1434623
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.
0
 
LVL 8

Expert Comment

by:MikeP090797
ID: 1434624
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
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:Richard2000
ID: 1434625
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 :-)
0
 
LVL 8

Expert Comment

by:MikeP090797
ID: 1434626
Since my suggestions weren't too helpfull, better delete the questions, and get the points back
0
 
LVL 1

Accepted Solution

by:
jonder earned 150 total points
ID: 1434627
You can reject this if you want to but the answer is very simple!
I had the same problem you are having about 9 months ago.
The way I fixed the problem was to make a Global Integer & set it to ZERO, then when your user presses F2

the KeyDown_Event would start off:

GlobalInteger = GlobalInteger + 1
If GlobalInteger > 1 Then
    ...'Your Code
    ...
    GlobalInteger = 0  
End If
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

721 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question