我现在在一个picture控件中做实时曲线,可是最小化,再最大化后,刚才画好的哪部分图就没了,用autordraw属性也不行的!!

解决方案 »

  1.   

    autordraw=true都不行吗??
    你是怎么样画的呢?
      

  2.   

    把Picture控件的AutoRedraw属性改为True
      

  3.   

    方案一:picture1.autodraw=true
    方案二:把绘图过程写在Picture1_paint事件中
      

  4.   

    总算我能答上一个了 哈哈
    picture1.autodraw=true
      

  5.   

    不行啊!!!picture1.autodraw=true 不行!!
    我最大化后,还是原来哪样,即画完的还在!!
    这是源码!Option Explicit 
    Public iAAlert As Integer     '报警值
    Const HY = 4000       'y轴的最大表示值
    Const LX = 30000      'x轴的最大位置Const iV = 200   '时间间隔
    Dim i As Long     '临时变量
    Dim iD As Long    'x的坐标
    Dim iA As Long    'y的坐标
    Dim Inum As Long  '实时y的坐标值Private Sub Command1_Click()
    Form2.Show
    End SubPrivate Sub Form_Load()Dim sA As String    '文件中的值
    main.Move (Screen.Width - main.Width) \ 2, (Screen.Height - main.Width) \ 2  '调整picture的位置
    Picture1.ScaleMode = 3
    Open App.Path & "\date.txt" For Input As #1
        Input #1, sA
    Close #1iAAlert = sA
       
    '初始化picture的位置
    Picture1.Top = 0
    Picture1.Left = 0
    Picture1.Width = main.Width
    Picture1.Scale (0, HY)-(LX, 0)     '建立自己的作标系统'初始化报警线的位置
    With Line1
        .X1 = 0
        .X2 = Picture1.ScaleWidth
        .Y1 = iAAlert
        .Y2 = iAAlert
    End WithEnd SubPrivate Sub Timer1_Timer()i = iD + iVWith Picture1    If iD > .ScaleWidth * 0.98 Then
            
            .Left = .Left - iV
            .Width = .Width + iV
            Line1.X1 = 0
            Line1.X2 = .ScaleWidth
            
        End If
        
        Randomize
        
        Inum = Int(3000 * Rnd) + 100   '产生一个界于100和4000之间的随机数
        
        If Inum > iAAlert Then
        
            Image1.Picture = alert.Picture
        Else
            Image1.Picture = ok.Picture
        End If
        
        Picture1.Line (iD, iA)-(i, Inum)
        iA = Inum
        
        
        If .Width > Me.ScaleWidth * 2 Then  '数据清零,防止溢出
            .Width = Me.ScaleWidth
            Line1.X1 = 0
            Line1.X2 = .ScaleWidth
            .Left = 0
            i = 0
        End If
       
    End With
        
     iD = iEnd Sub
      

  6.   

    不行的话,楼主把代码SHOW一下.楼上这么多的星级人物~!
      

  7.   

    在Form_Resize里加个判断Private Sub Form_Resize()
        If Me.WindowState = vbMinimized Then
            Timer1.Enabled = False
        Else
            Timer1.Enabled = True
        End If
    End Sub
      

  8.   

    加上下面这段代码就好了,我试过了
    Private Sub Form_Resize()
        If Me.WindowState = vbMinimized Then
            Timer1.Enabled = False
        Else
            Timer1.Enabled = True
        End If
    End Sub
      

  9.   

    不过Picture控件的AutoRedraw属性还是要设置为True
      

  10.   

    我就是直接用你的代码,然后加上一个判断,什么都没有:
    =================================================
    Option Explicit
    '=====================================================
    Private Sub Form_Resize()
        If Me.WindowState = vbMinimized Then
            Timer1.Enabled = False
        Else
            Timer1.Enabled = True
        End If
    End Sub
    '=====================================================
    '以下的都是你的源代码: 
    Public iAAlert As Integer     '报警值
    Const HY = 4000       'y轴的最大表示值
    Const LX = 30000      'x轴的最大位置Const iV = 200   '时间间隔
    Dim i As Long     '临时变量
    Dim iD As Long    'x的坐标
    Dim iA As Long    'y的坐标
    Dim Inum As Long  '实时y的坐标值Private Sub Command1_Click()
    Form2.Show
    End SubPrivate Sub Form_Load()Dim sA As String    '文件中的值
    main.Move (Screen.Width - main.Width) \ 2, (Screen.Height - main.Width) \ 2  '调整picture的位置
    Picture1.ScaleMode = 3
    Open App.Path & "\date.txt" For Input As #1
        Input #1, sA
    Close #1iAAlert = sA
       
    '初始化picture的位置
    Picture1.Top = 0
    Picture1.Left = 0
    Picture1.Width = main.Width
    Picture1.Scale (0, HY)-(LX, 0)     '建立自己的作标系统'初始化报警线的位置
    With Line1
        .X1 = 0
        .X2 = Picture1.ScaleWidth
        .Y1 = iAAlert
        .Y2 = iAAlert
    End WithEnd SubPrivate Sub Timer1_Timer()i = iD + iVWith Picture1    If iD > .ScaleWidth * 0.98 Then
            
            .Left = .Left - iV
            .Width = .Width + iV
            Line1.X1 = 0
            Line1.X2 = .ScaleWidth
            
        End If
        
        Randomize
        
        Inum = Int(3000 * Rnd) + 100   '产生一个界于100和4000之间的随机数
        
        If Inum > iAAlert Then
        
            Image1.Picture = alert.Picture
        Else
            Image1.Picture = ok.Picture
        End If
        
        Picture1.Line (iD, iA)-(i, Inum)
        iA = Inum
        
        
        If .Width > Me.ScaleWidth * 2 Then  '数据清零,防止溢出
            .Width = Me.ScaleWidth
            Line1.X1 = 0
            Line1.X2 = .ScaleWidth
            .Left = 0
            i = 0
        End If
       
    End With
        
     iD = iEnd Sub
      

  11.   

    如果不行,你可以新建一个工程来测试,记得把Picture1的AutoRedraw属性改为True
      

  12.   

    呵呵,问题解决拉!谢谢拉,我的picture1的autoredraw的属性不知道什么时候改回去的,呵呵,不好意思拉!!