我在picture 控件上绘制一个256 * 256 的长度为2厘米的方格,
将其AutoRedraw属性设为True,但是在动态绘制时出现如上错误, 我该怎么办好呢??

解决方案 »

  1.   

    建立一个临时 Picture 对像,在这个里面做操作,然后送给你现在的这个 picture 控件。
    当picture 的 AutoRedraw 属性设为 True 时,不能动态绘制了。
      

  2.   

    没问题啊,你怎么画的,不就是往picture上面调用line么?
      

  3.   

    是啊,好吧。代码如下:Public Type Point
        x As Double
        y As Double
    End Type
    Public Rownum As Integer
    Public Colnum As Integer
    Public StartPoint As Point
    Public ValRadius As DoublePublic Sub DrawPane(pic As PictureBox, row As Integer, col As Integer, radius As Double, StartPoint As Point)    pic.ScaleMode = 7
        pic.DrawWidth = 1
        pic.FillColor = RGB(128, 128, 128)
        pic.FillStyle = 1 
        For i = 1 To row Step 1
            For j = 1 To col Step 1
                pic.Line (StartPoint.x + (i - 1) * (2 * radius), StartPoint.y + (j - 1) * (2 * radius))-(StartPoint.x + i * (2 * radius), StartPoint.y + j * (2 * radius)), RGB(255, 255, 255), B
            Next
        Next
    End SubPrivate Sub sizecmd_Click()
        
        If holdcurrendtrawings = False Then
            Untitledfrm1.BKpic.Cls
        End If    With StartPoint
            .x = Val(startpointxtxt.Text)
            .y = Val(startpointytxt.Text)
        End With
        Rownum = Val(Rowtxt.Text)
        Colnum = Val(Coltxt.Text)
        ValRadius = Val(Radiustxt.Text)
        '/////////////////////////
        With Untitledfrm1.BKpic
            .Left = 0.423
            .Top = 0.423
            .ScaleMode = 7
            .Height = Colnum * 2 * ValRadius + StartPoint.y * 2     
            .Width = Rownum * 2 * ValRadius + StartPoint.x * 2      
        End With
        
        '////////////////////////////////////
        Call DrawPane(Untitledfrm1.BKpic, Rownum, Colnum, ValRadius, StartPoint)
        
    End Sub
    这是调用的全过程, 运行时出现如上的问题。即 rownum= 256 ,colnum = 256 时出现。
    Help
      

  4.   

    我也遇到过,这是由于图形太大,系统无法分配足够大的内存造成的(我估计的,呵呵,)
    我用Picture模拟A3纸时出错,模拟4纸时则正常。解决方法是设置hdc的比例。我的绘图过程是用VC做的DLL,所以是在VC内解决的,大概VB直接调用API也可以解决。
      

  5.   

    不好意思,说错了。我的这个问题也没有解决,解决的是另一个问题。不过是不是可以用两个picture连起来啊。