Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

double click resulting in a click event

Posted on 1998-05-29
5
Medium Priority
?
152 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
[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
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 300 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

Independent Software Vendors: 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!

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…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
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…
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

618 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