求助:picturebox实时曲线图形整体左移时出现重叠问题?
实时曲线绘制到picturebox最右边极限时,图形整体左移时就会出现重叠,希哪位大虾解决一下,谢谢!!
PictureBox中曲线左平移.rar
(6.22 KB)
Option Explicit Dim TimeCount As Integer Dim DataFromCom As Integer Dim DataFromComLast As Integer Private Sub Form_Load() '后台进行绘图 picBack.Visible = False PicScale picBack '调整图像框的坐标系 PicXLine picBack '前台进行显示 PicScale picShow '调整图像框的坐标系 PicXLine picShow End Sub Private Sub Timer1_Timer() DataFromComLast = DataFromCom Randomize DataFromCom = CInt(1000 * Rnd) TimeCount = TimeCount + 1 If ((TimeCount + 1) * 60 > picBack.Width) Then picBack.PaintPicture picShow.Image, -60, 0, picShow.Width, picShow.Height, 0, 0, picShow.Width, picShow.Height '从前台复制到后台 picShow.PaintPicture picBack.Image, 0, 0, picShow.Width, picShow.Height, 0, 0, picBack.Width, picBack.Height '从后台显示到前台 TimeCount = TimeCount - 1 End If DrawRealLine picShow, TimeCount, DataFromCom, DataFromComLast 'OK End Sub Private Sub DrawRealLine(picX As PictureBox, TimeCountX As Integer, DataFromComX As Integer, DataFromComLastX As Integer) picX.Line ((TimeCountX - 1) * 60, DataFromComLastX)-(TimeCountX * 60, DataFromComX), vbGreen End Sub Private Sub PicScale(picX As PictureBox) '调整图像框的坐标系 picX.Scale (0, picX.ScaleHeight)-(picX.ScaleWidth, 0) End Sub Private Sub PicXLine(picX As PictureBox) Dim intStep As Integer For intStep = 0 To 5000 Step 500 picX.Line (0, intStep)-(picX.ScaleWidth, intStep), vbWhite Next End Sub
[此贴子已经被作者于2017-2-14 20:51编辑过]