Option Explicit
Private Declare Function BitBlt Lib "GDI32" (ByVal hDestDC As Long, ByVal X As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hSrcDC As Long, ByVal xSrc As Long, ByVal ySrc As Long, ByVal DrawStyle As Long) As Long
Dim GobalS As Long '秖祘
Dim GobalL As Long 'Ω?Г?
Dim GobalT, yy As Integer 'Ω??だ
Dim objCn As ADODB.Connection
Dim rs As ADODB.Recordset
Private Sub Form_Load()
Set objCn = New Connection
objCn.ConnectionString = "driver=SQL Server;server=(LOCAL);database=dt"
objCn.Open
Set rs = New Recordset
rs.Open "select * from line", objCn, adOpenKeyset, adLockOptimistic
rs.MoveFirst
Picture1.AutoRedraw = False
Picture1.ScaleMode =
GobalL = -1
GobalS = 400
GobalT = 1
yy = 0
End SubPrivate Sub Timer1_Timer()
Dim w As Long, h As Long, y1 As Long, Data As Long
Dim hBmp, ShowMode As Long, ii As Long, t1 As Integer
rs.MoveNext
w = Picture1.Width
h = Picture1.Height
hBmp = Picture1.hDC
ShowMode = &HCC0020
Data = rs("line")
y1 = (GobalS - Data) / GobalS * h
ii = BitBlt(hBmp, 0, 0, w - 1, h, hBmp, 1, 0, ShowMode)
Picture1.Line (w - 1, yy)-(w, y1), RGB(56, 255, 0)
yy = y1
t1 = Val(Mid$(Time$, 3, 2))
If GobalT <> t1 Then
Picture1.CurrentX = w - 16
Picture1.CurrentY = h - 8
Picture1.Print Mid$(Time$, 1, 5)
GobalT = t1
End IfEnd Sub
我这我的一个程序,想让它能动态的显示数据,画出曲线,可是就是不能,不知道哪错了,还望名位给我指点一下,谢谢
Private Declare Function BitBlt Lib "GDI32" (ByVal hDestDC As Long, ByVal X As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hSrcDC As Long, ByVal xSrc As Long, ByVal ySrc As Long, ByVal DrawStyle As Long) As Long
Dim GobalS As Long '秖祘
Dim GobalL As Long 'Ω?Г?
Dim GobalT, yy As Integer 'Ω??だ
Dim objCn As ADODB.Connection
Dim rs As ADODB.Recordset
Private Sub Form_Load()
Set objCn = New Connection
objCn.ConnectionString = "driver=SQL Server;server=(LOCAL);database=dt"
objCn.Open
Set rs = New Recordset
rs.Open "select * from line", objCn, adOpenKeyset, adLockOptimistic
rs.MoveFirst
Picture1.AutoRedraw = False
Picture1.ScaleMode =
GobalL = -1
GobalS = 400
GobalT = 1
yy = 0
End SubPrivate Sub Timer1_Timer()
Dim w As Long, h As Long, y1 As Long, Data As Long
Dim hBmp, ShowMode As Long, ii As Long, t1 As Integer
rs.MoveNext
w = Picture1.Width
h = Picture1.Height
hBmp = Picture1.hDC
ShowMode = &HCC0020
Data = rs("line")
y1 = (GobalS - Data) / GobalS * h
ii = BitBlt(hBmp, 0, 0, w - 1, h, hBmp, 1, 0, ShowMode)
Picture1.Line (w - 1, yy)-(w, y1), RGB(56, 255, 0)
yy = y1
t1 = Val(Mid$(Time$, 3, 2))
If GobalT <> t1 Then
Picture1.CurrentX = w - 16
Picture1.CurrentY = h - 8
Picture1.Print Mid$(Time$, 1, 5)
GobalT = t1
End IfEnd Sub
我这我的一个程序,想让它能动态的显示数据,画出曲线,可是就是不能,不知道哪错了,还望名位给我指点一下,谢谢
你好
其实上面的程序,我也不怎样理解是从网上找的,我是昨天才接触到API的,几乎什么都不懂,可是我现在急着写一个监控软件,是从PLC中读取数据,然后以实时曲线显示出来,用到一个Picture控件作用曲线的容器,和一个定时器,每一分钟取一次数据,动态的显示数据和时间.我不知道怎样写,能帮个忙吗,谢谢,谢谢
其实一些api函数的功能完全可以自己定义函数来完成的。
不知道我有没有理解到搂主的意思。
比方说你已经在picture上画了一条曲线了,现在过了一分钟,你要画第二条曲线了,那第一条曲线还要在picture上吗?还是只要picture上只有第二条曲线就可以了?
TO Hassle ,我给你加十分,