Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Capturing left mouse button double-click on a Word document.

Posted on 1999-09-16
12
Medium Priority
?
455 Views
Last Modified: 2012-06-21
I'm trying to capture the ‘left mouse button double click’ on an MS-Word document.  I want to be able to tell when a user highlights a word and then double click it.

I'm trying to do this from a DLL in VB6.

So far, I've tried using GetMessage and the PeekMessage with a timer function on a form.
The GetMessage function created havoc on the normal mouse input.
I tried using PeekMessage, but that doesn't seem to be able to pickup the double-click at all.

Here’s the code I’ve tried so far:
Private WordWindow As Long

Private Sub Form_Load()
WordWindow = GetActiveWindow()
End Sub

Private Sub Timer1_Timer()
Dim FetchMsg As MSG
If PeekMessage(FetchMsg, WordWindow, WM_LBUTTONDBLCLK, WM_LBUTTONDBLCLK, PM_REMOVE) > 0 Then
    MsgBox "It works"
    End If
End Sub

I then tried the following code:

Private Sub Timer1_Timer()
Dim FetchMsg As MSG
If GetMessage(FetchMsg, WordWindow, WM_LBUTTONDBLCLK, WM_LBUTTONDBLCLK) > 0 Then
    If FetchMsg.message = WM_LBUTTONDBLCLK Then
        MsgBox "It works"
        Else
        TranslateMessage FetchMsg
        DispatchMessage FetchMsg
        End If
    End If
End Sub

Does any one know how to do this?  Am I missing an obvious solution?

Thanks in advance.
0
Comment
Question by:Axter
[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
  • 6
  • 3
  • 3
12 Comments
 
LVL 30

Author Comment

by:Axter
ID: 2053153
Edited text of question.
0
 
LVL 30

Author Comment

by:Axter
ID: 2053157
Edited text of question.
0
 
LVL 10

Expert Comment

by:viktornet
ID: 2053694
try this instead...

Dim FetchMsg As MSG
             if PeekMessage(FetchMsg, WordWindow, WM_LBUTTONDBLCLK,
             WM_LBUTTONDBLCLK, PM_REMOVE) <> 0 Then
                 MsgBox "It works"
                 End If

and set the interval of the timer to as little as possible...

you can also try a DO/WHILE loop instead of a timer...

..-=ViKtOr=-..
0
Technology Partners: 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!

 
LVL 30

Author Comment

by:Axter
ID: 2053996
viktornet,
I tried your suggestion, but it didn't work either.
I'm not sure why, but the peekmessage function doesn't seem to be picking up the double clicks at all.
0
 
LVL 10

Expert Comment

by:viktornet
ID: 2055673
did you try some other messages? Did they work?
0
 
LVL 30

Author Comment

by:Axter
ID: 2055827
I tried the right-click button, and it didn't work either.
0
 
LVL 10

Expert Comment

by:viktornet
ID: 2058748
well, then it's something with your code and not the app itself. Maybe the active app is not the front... maybe it's 0...

..-=ViKtOr=-..
0
 
LVL 10

Accepted Solution

by:
ThaSmartUno earned 300 total points
ID: 2089518
you can do this in a form/module ... i don't know how in a dll ...

Private Sub Form_Load()
Timer1.Interval = 150
Timer1.Enabled = True
End Sub

Private Sub Timer1_Timer()
           Static nOldKey As Integer

           Dim a As Integer
           For a = 1 To 255
               If GetAsyncKeyState(a) <> 0 Then
                       'MsgBox GetAsyncKeyState(a)
                       
                       If a = 1 Then
                            Text1.Text = Text1 & "Left mouse button"
                        ElseIf a = 2 Then
                            Text1.Text = Text1 & "Right  mouse button"
                        End If
               End If
               Next

End Sub

add that into a form with a Timer named Timer1 and a text box named Text1

And into a Module

Option Explicit
       
       Declare Function GetAsyncKeyState Lib "user32" (ByVal KEYey As Long) As Integer

0
 
LVL 30

Author Comment

by:Axter
ID: 2092828
ThaSmartUno,
I tried your code, but there's one problem with it.  I can't detect if the user is double clicking the left mouse button, or just holding it down.
I need to be able to detect when the user double click the mouse.

If you can think of a way to detect the double click I can give you the points.

Thanks
0
 
LVL 10

Expert Comment

by:ThaSmartUno
ID: 2092923
well you could check to see if it does the same click in a certain amount of time....
0
 
LVL 30

Author Comment

by:Axter
ID: 2200185
ThaSmartUno
I was not able to get this APP to work with any of the above suggestions, but since "ThaSmartUno" comment came the closes to working, I'm going to give the points to him/her.
0
 
LVL 10

Expert Comment

by:ThaSmartUno
ID: 2200992
well thanx, sorry I couldn't fully help you
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
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…
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…
Suggested Courses

670 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