绘图图形在VB.net中消失 [英] Drawing Graphics Disappear in VB.net

查看:151
本文介绍了绘图图形在VB.net中消失的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个简单的程序,可以用FillEllipse和FillRectangle在屏幕上绘制。我的问题是,当您将另一个窗口拖过屏幕的一小部分时,该部分将被擦除。当您拖动另一个窗口时,发生这种情况,松手并将其拖回。有什么方法可以解决这个问题?

  Dim MyFormObject As Graphics = Me.CreateGraphics 
选择案例形状
CaseEllipse
MyFormObject.FillEllipse(brush,eX - CInt(brushWidth / 2),eY - CInt(brushHeight / 2),brushWidth,brushHeight)
CaseRectangle
MyFormObject .FillRectangle(刷子,eX-CInt(brushWidth / 2),eY-CInt(brushHeight / 2),brushWidth,brushHeight)
结束选择


解决方案

您可以将一个PictureBox控件放在窗体上并绘制到该窗体上,并且在其他窗口绘制时不会被删除:



在form_load上执行一次操作:

  pictureBox1。图片=新的位图(宽度,高度); b 




Graphics.FromImage(pictureBox1.Image).FillRectangle(Brushes.Black,0,0,100,100);
pictureBox1.Refresh();


I have a simple program that you can draw on the screen with FillEllipse and FillRectangle. My problem is that when you drag another window over even a small portion of the screen, that part will be erased. This happens when you drag the other window over, let go, and drag it back off. Is there any way to fix this?

Dim MyFormObject As Graphics = Me.CreateGraphics
        Select Case shape
            Case "Ellipse"
                MyFormObject.FillEllipse(brush, e.X - CInt(brushWidth / 2), e.Y - CInt(brushHeight / 2), brushWidth, brushHeight)
            Case "Rectangle"
                MyFormObject.FillRectangle(brush, e.X - CInt(brushWidth / 2), e.Y - CInt(brushHeight / 2), brushWidth, brushHeight)
        End Select

解决方案

You can put a PictureBox control on your form and draw to that instead and it won't be erased when other windows paint over it:

do this once, on form_load or something:

pictureBox1.Image = new Bitmap(Width, Height);

to draw:

Graphics.FromImage(pictureBox1.Image).FillRectangle(Brushes.Black, 0, 0, 100, 100);
pictureBox1.Refresh();

这篇关于绘图图形在VB.net中消失的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆