当前上下文中不存在名称“video

f2831890 2011-07-18 02:09:45
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;

namespace _718单个摄像头
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void button1_Click(object sender, EventArgs e)
{
btnPlay.Enabled = false;
btnStop.Enabled = true;
btnPz.Enabled = true;
video = new cVideo(pictureBox1.Handle, pictureBox1.Width, pictureBox1.Height);
video.StartWebCam();
}
//在【关闭视频】按钮的Click事件中添加如下代码:
private void b_stop_Click(object sender, EventArgs e)
{
btnPlay.Enabled = true;
btnStop.Enabled = false;
btnPz.Enabled = false;
video.CloseWebcam();
}
//在【拍摄照片】按钮的Click事件下添加如下代码:
private void btnPz_Click(object sender, EventArgs e)
{
video.GrabImage(pictureBox1.Handle, "d:\\a.bmp");
}
}
}



...全文
54 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
TimZhuFaith 2011-07-18
  • 打赏
  • 举报
回复
cVideo video = null;
public Form1()
{
InitializeComponent();
}
ohkuy 2011-07-18
  • 打赏
  • 举报
回复


//在最外面定义,并且保证要先按button1,否则会说“未将对象引用到实例”
cVideo video;
private void button1_Click(object sender, EventArgs e)
{
btnPlay.Enabled = false;
btnStop.Enabled = true;
btnPz.Enabled = true;
video = new cVideo(pictureBox1.Handle, pictureBox1.Width, pictureBox1.Height);
video.StartWebCam();
}

老毕 2011-07-18
  • 打赏
  • 举报
回复
可能在整个程序范围内,定义有一个cVideo的实例对象video。

你在IDE里,在你红字的这几个video上点鼠标右链,转到定义,就能找到它在哪里声明的了。

110,534

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧