Solved

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

Posted on 1998-09-13
6
385 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
  • 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
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

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 50 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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

827 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