secile / UsbCamera

C# source code for using usb camera and web camera in WinForms/WPF. With only single CSharp source code. No external library required.
MIT License
179 stars 55 forks source link

missing events #21

Closed hellottyp closed 1 year ago

hellottyp commented 1 year ago

// create instance.
camera = new UsbCamera(cameraIndex, format);

// show preview on control. (works light.)
camera.SetPreviewControl(this.panVideo.Handle, this.panVideo.ClientSize);

private void panVideo_MouseMove(object sender, MouseEventArgs e)
 {
       //it never fired over the camera region.but fired over other whitespace region.
       Console.WriteLine("mouse move");
}
secile commented 1 year ago

Hello, thank you for your information.

This is library's problem. I'll fix future release, but could you add 1 line (see below) and try again?

// about line 260.
builder.RenderStream(ref pinCategory, ref mediaType, vcap_source, null, null);
vw.put_Owner(controlHandle);
vw.put_MessageDrain(controlHandle);   <- ADD THIS LINE.
hellottyp commented 1 year ago
                panel1.MouseMove += (s, ev) =>
                {
                    Console.WriteLine("mouse move"); // work well
                };

                panel1.MouseLeave += (s, ev) =>
                {
                    Console.WriteLine("mouse leave"); //fired too
                };

                panel1.MouseClick += (s, ev) =>
                {
                    Console.WriteLine("mouse click"); //not work
                };
hellottyp commented 1 year ago

I have a none border window.I want to drag the window by the container of the camera.

secile commented 1 year ago

It seems that it is limitation of DirectShow. https://stackoverflow.com/questions/35488532/ivideowindow-messagedrain-not-working-in-vb

Please use MouseUp and MouseDown event instead.