Click here to Skip to main content
15,884,629 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello,
I'm new developer and want to capture mouse cursor in Direct Show filter.
can you help with this ?
Posted

1 solution

Hi,
You can use DirectInput for capturing mouse.
C#
using Microsoft.DirectX.DirectInput;


C#
Device mouse;

void Initialize()
{

            mouse = new Device(SystemGuid.Mouse);
            mouse.SetCooperativeLevel(this,CooperativeLevelFlags.NonExclusive |CooperativeLevelFlags.Background );
            mouse.Acquire();
}

void RefreshMouse()
        {
//Call this method from some timer

            MouseState state = mouse.CurrentMouseState;
//Do something with it....
//Note: You get position of mouse from some reference and is of no use
//What is possible then? You can capture mouse button state and use native System.Windows.Forms.Cursor.Position to get the position of mouse
//To check Click on a panel use
if (state.GetMouseButtons()[0]!=0&& VideoPanel.Bounds.Contains(Cursor.Position))
                {
                    Media.FullScreen();
                }
}


Google it, Good luck ! :)
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900