Solved

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

Posted on 1998-09-13
6
384 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
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 

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

Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

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

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…
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
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…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

777 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