Solved

double click resulting in a click event

Posted on 1998-05-29
5
136 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
ID: 1462048
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
ID: 1462049
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
ID: 1462050
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
ID: 1462051
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
ID: 1462052
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

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…
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…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

930 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

12 Experts available now in Live!

Get 1:1 Help Now