注册 登录
编程论坛 VB6论坛

实时曲线移植到多窗体工程的问题

quanquanwang 发布于 2012-12-26 11:47, 572 次点击
单窗体可以显示的实时曲线,移植到多窗体中无法显示是什么情况?请高手指点
4 回复
#2
风吹过b2012-12-26 12:59
看你绘图函数 是怎么写的。是不是指定的 窗体。
还有,绘图函数在什么地方调用的?调用前是否需要检测 显示窗体是否被关闭?
#3
quanquanwang2012-12-26 15:34
回复 2楼 风吹过b
直接用picture.line写的,后面用到bitblt函数,都是在当前窗体中的。
下面是源代码:
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 VbSrcCopy As Long) As Long
Public s As Long
Dim x As Single
Dim hvar As Long
Dim y(0) As Single

Private Sub Command1_Click()
  Picture1.Refresh
 Timer1.Enabled = True
 Timer1.Interval = 20
Call AdsOcx1.AdsCreateVarHandle("MAX1.x", hvar)
End Sub

Private Sub Form_Load()
 AdsOcx1.EnableErrorHandling = True
 AdsOcx1.AdsAmsServerNetId = AdsOcx1.AdsAmsClientNetId
 AdsOcx1.AdsAmsServerPort = 801                  'CX1000的Run-Time System 1的端口号
 AdsOcx1.AdsAmsConnect
 Call AdsOcx1.AdsCreateVarHandle("MAX1.x", hvar)
Picture1.Scale (-4400, 2600)-(4400, -2600)
  Picture1.ScaleMode = 1
  Picture1.Refresh
  Picture1.AutoRedraw = True
  s = 200

End Sub

Private Sub Form_Unload(Cancel As Integer)
  Call AdsOcx1.AdsDeleteVarHandle(hvar)
    AdsOcx1.AdsAmsDisconnect
End Sub

Private Sub Timer1_Timer()
'Read variable
Call AdsOcx1.AdsSyncReadSingleVarReq(hvar, 4, x)
Text1.Text = CStr(x)

Call AdsOcx1.AdsSyncReadReq(&HF030&, 100&, 4&, y)
Text2.Text = CStr(y(0))

Dim w As Long, h As Long, y1 As Single, m As Single
Dim hBmp As Long, ShowMode As Long, ii As Long, t1 As Integer
w = Picture1.Width
h = Picture1.Height
hBmp = Picture1.hDC
ShowMode = &HCC0020 'ROP模式(复制)
Picture1.DrawWidth = 1
y1 = (s - y(0)) / s * h * 2 - 5000

ii = BitBlt(hBmp, 0, 0, w - 6, h, hBmp, -1, 0, ShowMode)
Picture1.Line (w - 1, m)-(w, y1), RGB(255, 0, 0)
m = y1
End Sub
求指点!
#4
风吹过b2012-12-26 16:07
看代码 ,没有 与 MDI 模式下冲突的方面。

要么你这样做,在 MDI 模式下,这个窗体不要设为 MID子窗体进行测试一下。

没用过这个对象。
#5
quanquanwang2012-12-26 21:01
回复 4楼 风吹过b
没用MDI窗体啊 ,直接添加了多个窗体。利用picturebox画图时,应该不用进行什么特殊的属性设置吧?
1