Solved

double click resulting in a click event

Posted on 1998-05-29
5
135 Views
Last Modified: 2010-05-03
I have a form with a listbox containing a list of contacts. Double clicking on a contact brings onother form with contact detail. The problem is that when the Contact details form has a button at the same mouse position it gets activated (Click event). This is a VB documented bug. Does anybody knows a stable way to prevent it?
0
Comment
Question by:tp
5 Comments
 

Expert Comment

by:nguy
Comment Utility
tp
Well, if you have the SP3 and you're still having this problem you may have to call a MousUp from within the ListBox_DblCllick event procedure just to circumvent the Click Event.
0
 
LVL 3

Expert Comment

by:MorFF
Comment Utility
nguy, I have tried this but without success.
You can easily simulate the situation with puting a big SSCommand1 button on Form2. On Form1_DblClick just show Form2.
It's suppose to be SSCommand button problem.
0
 

Author Comment

by:tp
Comment Utility
You might want to try MorFF's suggestion by moving the position of the command button on the second form or disable the click event of command button and have it react only to double clicks.
0
 

Expert Comment

by:nguy
Comment Utility
This is a problem that has plagued mankind since...

Well, to get to the meat of the matter, here is a solution that has worked for me.
Place a timer control on your form.  Set the timer's interval property to 100, set enabled property to False.
Add a module level variable to the declarations section:
Private m_bDblClick As Boolean

In your Listbox Click event place the following code:
Private Sub List1_Click()
  m_bDblClick = False
  Timer1.Enabled = True
End Sub

In the double click event, place the following code:
Private Sub List1_DblClick()
  m_bDblClick = True
End Sub

In the timer event of the timer control, place the following code:
Private Sub Timer1_Timer()
  If m_bDblClick Then
    Debug.Print "DblClick"
    'Or whatever double click code should happen
  Else
    Debug.Print "Click"
    'Or whatever click code should happen
  End If
  Timer1.Enabled = False
End Sub

Coding for more than one list box is possible, but has it's drawbacks, but for a single list box, this works well.
0
 
LVL 6

Accepted Solution

by:
clifABB earned 150 total points
Comment Utility
tp

good solution from clifABB! (mine's a bit more straightforward tho!)
sorry nguy, have to disagree with you on the button doubleclick, makes it non standard windows functionality.

Cheers - MorFF
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

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…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
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…
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…

743 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now