在winform中通过form初始化后的名字.invoke可以往主界面控件上抛出东西,
可是在做控件的时候,发现只有在调用控件的时候才会初始化,名字就没有办法知道,invoke语句也就没法写了
请问各位大大有什么办法没有呢?比较急:)
可是在做控件的时候,发现只有在调用控件的时候才会初始化,名字就没有办法知道,invoke语句也就没法写了
请问各位大大有什么办法没有呢?比较急:)
解决方案 »
- VS2008添加项目数据源的时候总是出错怎么回事呢.
- 怎么在vs2012上的metro界面的txt框里显示文件名
- 数组的方法与返回值
- The type or namespace name 'Windows' does not exist in the namespace
- 关于c#桌面应用软件开发前景
- Windows应用程序中如何显示Oracle数据库Blob类型的图片?
- saveFileDialog保存一个Excel表时,覆盖同名文件时出错 源码大大的有,兄弟们来帮我看看怎么解决
- c# 写txt文件
- 如何固定DATAGRID的行与列的固定大小?
- 新人求教
- 请问中外程序员的开发协作问题!有外企工作经验的开发人员请进。
- datagridview数据怎样导出到dbf?
否则1楼对了!哈哈
VedioAdd是自定义的委托,怎么把控件主线程里的方法挂上的问题,
不是做控件,而是直接写winform的时候比较简单,在Program里面Application.Run();以前自定义一个静态主窗体来run就可以了,
比如Form1 mMainForm =new Form1();
Application.Run(mMainForm);
然后我委托只要挂
public mMainForm.VedioAdd mVedioAdd = new mMainForm.VedioAdd(mMainForm.InsertPicture);
可是在一个如果要在叫UserControl1的控件里面做同样的就没有办法做相同的操作了,那我该怎么做呢?public delegate void VedioAdd(byte[] DecodedPicture, int ScreenIndex);
public void InsertPicture(byte[] DecodedPicture,int ScreenIndex)
{ DateTime CurrentTime = DateTime.Now;
if (this.pictureBoxGroup [ScreenIndex ].InvokeRequired)
{
//OutDelegate d = new OutDelegate(OutEventLog);
this.BeginInvoke(new VedioAdd(InsertPicture), DecodedPicture,ScreenIndex );
}
else
{
Monitor.Enter(this.pictureBoxGroup[ScreenIndex]);
//if (OutLog.Items.Count > 2) // OutLog.Clear();
try
{
MemoryStream PictureStream = new MemoryStream(DecodedPicture);
Graphics g = this.pictureBoxGroup[ScreenIndex].CreateGraphics();
g.DrawImage(Image.FromStream(PictureStream), new Rectangle(0, 0, this.pictureBoxGroup[ScreenIndex].Size.Width, this.pictureBoxGroup[ScreenIndex].Size.Height));
g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.NearestNeighbor;
g.PixelOffsetMode = System.Drawing.Drawing2D.PixelOffsetMode.Half;
//System.Threading.Thread.Sleep(60);
PictureStream.Close();
}
catch (System.ObjectDisposedException)
{
this.pictureBoxGroup[ScreenIndex].Dispose();
}
//pictureBoxGroup[PlayingBoxVedioIndex]//.Items.Add(CurrentTime.Date.ToShortDateString() + " " + CurrentTime.ToLongTimeString() + " " + text, IconFlag);
Monitor.Exit(this.pictureBoxGroup[ScreenIndex]);
} }