曲线画到picturebox的右边缘!正条曲线没有左移!帮忙啊!
以下是代码:
Dim y1 As Single
If x >= Picture1.ScaleWidth Then
BitBlt Picture1.hDC, 0, 0, Picture1.ScaleWidth - 1, Picture1.ScaleHeight, Picture1.hDC, 2, 0, &HCC0020
' End If
y1 = CInt(Sin((x - Picture1.Left) / 20 / 180 * pi) * Picture1.ScaleHeight / 2)
y1 = CInt((Picture1.ScaleHeight - 20) / 2) - y1
y1 = (sngYValue - y1) / sngYValue * Picture1.ScaleHeight '根据量程转变成具体坐标
Picture1.Line (x, y)-(x + 20, y1)
x = x + 20
y = y1
以下是代码:
Dim y1 As Single
If x >= Picture1.ScaleWidth Then
BitBlt Picture1.hDC, 0, 0, Picture1.ScaleWidth - 1, Picture1.ScaleHeight, Picture1.hDC, 2, 0, &HCC0020
' End If
y1 = CInt(Sin((x - Picture1.Left) / 20 / 180 * pi) * Picture1.ScaleHeight / 2)
y1 = CInt((Picture1.ScaleHeight - 20) / 2) - y1
y1 = (sngYValue - y1) / sngYValue * Picture1.ScaleHeight '根据量程转变成具体坐标
Picture1.Line (x, y)-(x + 20, y1)
x = x + 20
y = y1
1: 设置PICTURE控件得属性,AUTOREDRAW=TRUE; SCALEMODE=PIXEL等等
2:计算起点位置
3:在新位置画线或者画点(画完要REFRESH)
4:平移(也要refresh)
5:重复3,4两步直到最后
6:保存
楼主看看有没有遗漏什么PICTURE控件可以直接用PIANTPICTURE方法来平移,不必再用BITBLT得
二、在 BitBlt 左移 2 个坐标后,x 的值也应该 -2,否则就是在区域外绘图了