110,552
社区成员
发帖
与我相关
我的任务
分享
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using AForge.Video;
using AForge.Video.DirectShow;
using System.Runtime.InteropServices;
namespace Demo_jq
{
public partial class VideoForm : DevExpress.XtraEditors.XtraForm
{
FilterInfoCollection videoDevices;
//处理窗体的移动
[DllImport("User32.dll")]
public static extern bool ReleaseCapture();
[DllImport("User32.dll")]
public static extern bool SendMessage(IntPtr hwnd, int wMsg, int wParam, int lParam);
//API中用到的常量
const int WM_SYSCOMMAND = 0x0112;
const int SC_MOVE = 0xf010;
const int HTCAPTION = 0x0002;
public VideoForm()
{
InitializeComponent();
}
private void VideoForm_Load(object sender, EventArgs e)
{
videoDevices = new FilterInfoCollection(FilterCategory.VideoInputDevice);
VideoCaptureDevice videoSource1 = new VideoCaptureDevice(videoDevices[0].MonikerString);
videoSource1.DesiredFrameRate = 100;
videoSourcePlayer1.VideoSource = videoSource1;
videoSourcePlayer1.Start();
}
private void VideoForm_FormClosing(object sender, FormClosingEventArgs e)
{
videoSourcePlayer1.SignalToStop();
videoSourcePlayer1.WaitForStop();
this.Dispose();
}
private void videoSourcePlayer1_MouseDown(object sender, MouseEventArgs e)
{
ReleaseCapture();
SendMessage(this.Handle, WM_SYSCOMMAND, SC_MOVE + HTCAPTION, 0);
}
private void VideoForm_MouseDown(object sender, MouseEventArgs e)
{
ReleaseCapture();
SendMessage(this.Handle, WM_SYSCOMMAND, SC_MOVE + HTCAPTION, 0);
}
}
}