明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 3945|回复: 0

VB6中的PictureBox控件的AutoRedraw属性的VB.Net做法

[复制链接]
发表于 2005-11-28 09:43:00 | 显示全部楼层 |阅读模式

VB6中的PictureBox控件的有AutoRedraw属性,设置为True,则窗口最小化或被覆盖后重新打开窗口,原来的图形还在(使用Line等函数画的图形),但VB.NET没有了这个属性,为此烦了好久,MSDN上也没有找到明确的代用方法,上星期去书店翻了翻,终于明白怎么会事.

    Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim Bmp As Bitmap
        Dim Gra As Graphics
        Dim Pen As New Pen(Color.White)
        Bmp = New Bitmap(PictureBox1.Width, PictureBox1.Height)
        Gra = Graphics.FromImage(Bmp)
        Dim Dia As Single = Math.Min(PictureBox1.Height, PictureBox1.Width) * 0.5!
        Gra.DrawArc(Pen, (PictureBox1.Width - Dia) / 2.0!, (PictureBox1.Height - Dia) / 2.0!, Dia, Dia, 0, 360)
        Gra.DrawLine(Pen, 0, 0, PictureBox1.Width / 2.0!, PictureBox1.Height / 2.0!)
        PictureBox1.Image = Bmp
    End Sub

上面代码画的图形在最小化后重新打开图形还在,下面的则没有了.

    Private Sub PictureBox1_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles PictureBox1.DoubleClick
        Dim Gra As Graphics = PictureBox1.CreateGraphics()
        Dim Pen As New Pen(Color.Magenta)
        Dim Dia As Single = Math.Min(PictureBox1.Height, PictureBox1.Width) * 0.5!
        Gra.DrawRectangle(Pen, (PictureBox1.Width - Dia) / 2.0!, (PictureBox1.Height - Dia) / 2.0!, Dia, Dia)
    End Sub

您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2024-11-25 07:06 , Processed in 0.227588 second(s), 23 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表