Inserting fake mouse event into the message queue?

J

Johnny J.

This is the situation: I'm developing an add-in for Visual Studio where I
need to trap doubleclick events in the active document.

I've got a local mouse hook installed and that works perfectly. I catch the
doubleclick event and check the VS activedocument properties.

BUT: If I've got more than one tab group (vertical or horizontal), this
scenario can arise: The active document is e.g. Form1.cs in one of the tab
groups. I then doubleclick Form2.cs which is in another tab group. The
doubleclick event will be caught by the mouse hook, but the VS
activedocument will not have changed yet. It will still be Form1.cs.

I don't really know what the best procedure would be to force the
activedocument change before the doubleclick event is triggered, but my idea
was that I might be able to send a mouseclick event to the same queue the
doubleclick event came from BEFORE checking the activedocument property. I
don't know if that would work and actually activate the right document, but
I can't think of any other solution... I don't know how to accomplish it,
though. Can anybody give me an idea...???

I MIGHT be able to check the window under the mousepointer when the
doubleclick is fired, but I think that might be more complicated than the
above approach.

Any idea is welcome,
Johnny J.
 
N

Nicolas Noakes

I don't really know what the best procedure would be to force the
activedocument change before the doubleclick event is triggered, but my
idea was that I might be able to send a mouseclick event to the same queue
the doubleclick event came from BEFORE checking the activedocument
property. I don't know if that would work and actually activate the right
document, but I can't think of any other solution... I don't know how to
accomplish it, though. Can anybody give me an idea...???

That's unlikely to work (I not a C# guru myself). In fact it's likely to
simply retrigger your hooked event again - effectively creating a perpetual
loop!

Regards,
Nicolas
 
J

Johnny J.

It shouldn't - I only trap doubleclick events, so a single click event
should pass right through...

/Johnny
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top