Results 1 to 6 of 6

Thread: Can't use DblClick while using Click event?

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Apr 1999
    Location
    Prague, Czech Republic
    Posts
    350

    Post

    Hi again.

    I have an Image located on my form. I'm using a Click event, but I want to use the DblClick too. When I run my program and click image, it runs well; when I try to double click, click code is generated too. It looks i don't catch the double click time.

    PS: When I delete Click ev., DblClick runs well.



    ------------------
    Thanks,
    John, 14 years old

  2. #2
    PowerPoster
    Join Date
    Jul 1999
    Posts
    5,923

    Post

    Unfortunately what you are experiencing is true for the rest of us. When you click, the click event gets fired, BUT when you DblClick, the click event also gets fired.

    This is simply because the computer cannot possibly know that you are about to click again with your DblClick, therefore the first click fires the click event, the second click fires the dblclick event.

    For this reason, you generally can't have radically different code in the click and dblclick events.

    A solution could be if the first click event is delayed somehow, waiting half a second or so to see if a second click occurs. I don't know how to do that with code though...

    Anyways, good luck

    Regards

    ------------------
    - Chris
    [email protected]
    If it ain't broke - don't fix it

  3. #3
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431

    Post

    You won't like this but here is what MSDN Help has to say about the Click event
    ==================
    If there is code in the Click event, the DblClick event will never trigger, because the Click event is the first event to trigger between the two. As a result, the mouse click is intercepted by the Click event, so the DblClick event doesn't occur.
    =================
    But try this: use your mouse-driver software to slow your double-click speed way down. If that fixes the problem, post another question and ask "How can I temporarily change the users DblClick speed?"

    ------------------
    Marty
    Why is it called lipstick if you can still move your lips?

  4. #4
    Hyperactive Member
    Join Date
    Jan 1999
    Location
    North East America
    Posts
    463

    Post

    Why don't you use right mouse button to do one of you commands or shift mouse click or somthing other than click and dlbclick

    ------------------
    TMacPherson
    Customer Suport Software Analyst
    [email protected]


  5. #5
    Guru Aaron Young's Avatar
    Join Date
    Jun 1999
    Location
    Red Wing, MN, USA
    Posts
    2,177

    Post

    You can use a Timer Control to get around the Problem by delaying the Click Response long enough to Check for a 2nd Click, ie.
    Code:
    Private Sub Picture1_Click()
        Timer1.Interval = 200
        Timer1.Enabled = True
    End Sub
    
    Private Sub Picture1_DblClick()
        Timer1.Enabled = False
        MsgBox "Double Click Code Goes Here"
    End Sub
    
    Private Sub Timer1_Timer()
        Timer1.Enabled = False
        MsgBox "Click Code Goes Here"
    End Sub

    ------------------
    Aaron Young
    Analyst Programmer
    [email protected]
    [email protected]


  6. #6
    Lively Member
    Join Date
    Dec 1999
    Location
    Karlsruhe, Germany
    Posts
    122

    Post

    Cool peace of code, Aaron!

    Roger

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width