| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 592 人关注过本帖
标题:picturebox不够大怎么办?大家看下吧!谢谢
只看楼主 加入收藏
honeypuppy
Rank: 1
等 级:新手上路
帖 子:29
专家分:0
注 册:2007-5-5
收藏
 问题点数:0 回复次数:1 
picturebox不够大怎么办?大家看下吧!谢谢

大家好,我想请问一下,我想在picturebox里面把我采样到的数据绘成波形图,我用了给picturebox加滚动条的办法,“画一个PictureBox,采用VB提供的默认名字Picture1, 再在Picture1上面画一个PictureBox,默认名字为Picture2,设置:Picture2.AutoSize=TRUE;接着,加上水平滚动条,默认名字分别为:HScroll1;再在Picture2上绘图”

但是,我有问题,就是我用了滚动条后,画到7个字节多一点的数据的时候,再拖动滚动条已经不可以了,它已经到头了,而我要画的数据有几千字节,差的很多呢。详细点说,我画一个字节要用4000,而滚动条好像最大是32767,(是这样的吗?),我的图只能绘一点点,由谁知道这个问题可以怎么解决啊?是画图的代码有问题吗?

希望大家能够帮我看看,出出主意吧!
Private Sub form_load()
Picture1.AutoRedraw = True
Picture1.AutoSize = False
Picture2.AutoRedraw = True
Picture2.AutoSize = True
Picture2.Left = 0
Picture2.Top = 0
Picture2.Width = Picture1.Width
Picture2.Height = Picture1.Height
HScroll1.Min = 0
HScroll1.Max = Picture2.Width
'我看网上的例子是HScroll1.Max = Picture2.Width - Picture1.Width,但要用这句滚动条就不滚动了
If HScroll1.Max < 0 Then HScroll1.Enabled = False
PicScale Picture2 '调整图像框的坐标系
End Sub

'一位数据的画线过程,长度为500像素
Private Sub drawpicture(picX As PictureBox, TimeCountX As Long, DataFromComX As Integer, DataFromComLastX As Integer)
If TimeCountX - 1 > 0 Then
picX.Width = picX.Width + 1000 ‘我是用这两句来增加picture2的大小,以便于放下我要画的图
picX.Line ((TimeCountX - 1) * 500, DataFromComLastX)-Step(500, 0), vbRed
picX.Line -(TimeCountX * 500, DataFromComX), vbRed
picX.Line -Step(500, 0), vbRed
picX.Left = picX.Left + 1000
End If
End Sub

'画图过程,八位数据,SCL,SDA线的时序显示
Private Sub draw(temp1%)
Dim Scl0%, Scl1%, Scl2%
Dim Sda0%, Sda1%, Sda2%
Dim Scl00%
Dim Sda00%

Scl0 = (temp1 And &H80) / 128
Scl00 = Scl0
Sda0 = (temp1 And &H40) / 64
Sda00 = Sda0
Scl1 = (temp1 And &H20) / 32
Sda1 = (temp1 And &H10) / 16
Scl2 = (temp1 And &H8) / 8
Sda2 = (temp1 And &H4) / 4
SclLast = Scl3
SdaLast = Sda3
Scl3 = (temp1 And &H2) / 2
Sda3 = (temp1 And &H1)

TimeCounter = TimeCounter + 1
If Scl0 = 0 Then
Scl00 = 2500
Else
Scl00 = 3000
End If
If SclLast = 0 Then
SclLast = 2500
Else
SclLast = 3000
End If
drawpicture Form2.Picture2, TimeCounter, Scl00, SclLast

TimeCounter2 = TimeCounter2 + 1
If Sda0 = 0 Then
Sda00 = 1000
Else
Sda00 = 1500
End If
If SdaLast = 0 Then
SdaLast = 1000
Else
SdaLast = 1500
End If
drawpicture Form2.Picture2, TimeCounter2, Sda00, SdaLast

SclLast = Scl0
TimeCounter = TimeCounter + 1
If Scl1 = 0 Then
Scl00 = 2500
Else
Scl00 = 3000
End If
If SclLast = 0 Then
SclLast = 2500
Else
SclLast = 3000
End If
drawpicture Form2.Picture2, TimeCounter, Scl00, SclLast

SdaLast = Sda0
TimeCounter2 = TimeCounter2 + 1
If Sda1 = 0 Then
Sda00 = 1000
Else
Sda00 = 1500
End If
If SdaLast = 0 Then
SdaLast = 1000
Else
SdaLast = 1500
End If
drawpicture Form2.Picture2, TimeCounter2, Sda00, SdaLast

SclLast = Scl1
TimeCounter = TimeCounter + 1
If Scl2 = 0 Then
Scl00 = 2500
Else
Scl00 = 3000
End If
If SclLast = 0 Then
SclLast = 2500
Else
SclLast = 3000
End If
drawpicture Form2.Picture2, TimeCounter, Scl00, SclLast

SdaLast = Sda1
TimeCounter2 = TimeCounter2 + 1
If Sda2 = 0 Then
Sda00 = 1000
Else
Sda00 = 1500
End If
If SdaLast = 0 Then
SdaLast = 1000
Else
SdaLast = 1500
End If
drawpicture Form2.Picture2, TimeCounter2, Sda00, SdaLast

SclLast = Scl2
TimeCounter = TimeCounter + 1
If Scl3 = 0 Then
Scl00 = 2500
Else
Scl00 = 3000
End If
If SclLast = 0 Then
SclLast = 2500
Else
SclLast = 3000
End If
drawpicture Form2.Picture2, TimeCounter, Scl00, SclLast

SdaLast = Sda2
TimeCounter2 = TimeCounter2 + 1
If Sda3 = 0 Then
Sda00 = 1000
Else
Sda00 = 1500
End If
If SdaLast = 0 Then
SdaLast = 1000
Else
SdaLast = 1500
End If
drawpicture Form2.Picture2, TimeCounter2, Sda00, SdaLast
End Sub

搜索更多相关主题的帖子: picturebox PictureBox 数据 滚动 字节 
2007-05-10 09:00
honeypuppy
Rank: 1
等 级:新手上路
帖 子:29
专家分:0
注 册:2007-5-5
收藏
得分:0 
大家有没有更好的绘图办法呢?
很需要大家的帮助!
谢谢!~~~~~~~~~~~

为了爱我的人,和我爱的人,我要努力每一天
2007-05-10 09:32
快速回复:picturebox不够大怎么办?大家看下吧!谢谢
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.019524 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved