您的位置:程序门 -> vb -> 基础类



picturebox控件实现同时画两条线的问题


[收藏此页] [打印本页]选择字色:背景色:字体:[][][]


picturebox控件实现同时画两条线的问题[已结贴,结贴人:soery]
发表于:2007-03-17 22:45:26 楼主
1:如果选择check1在picture上画一条线,如果选择check2在picture上画另一条线,现在单独选择check1或check2都能实现画线,但是如果同时选择check1和check2还是画一条线,就是色彩交替而已。请问如何实现同时选择check1和check2,画两条不同的线
2:模拟程序全部代码如下:
dim   prevp(7)   as   long
dim   picture1color(7)   as   long
dim   j
dim   m
dim   rt1
dim   rt2


private   sub   check1_click()
if   check1.value   =   1   then
        rt1   =   1
        timer1.enabled   =   true
        timer1.interval   =   200
else
        rt1   =   0
end   if
end   sub

private   sub   check2_click()
if   check2.value   =   1   then
        rt2   =   1
        timer2.enabled   =   true
        timer2.interval   =   200
else
        rt2   =   0
end   if
end   sub

private   sub   form_load()

for   i   =   0   to   7
      prevp(i)   =   287
      next   i
     
picture1color(0)   =   &hff&   '设置颜色为红色
picture1color(1)   =   &h8000&   '设置颜色为色深绿色

timer3.enabled   =   true
timer3.interval   =   200

j   =   35
m   =   35
end   sub

private   sub   timer1_timer()
dim   k
dim   p(0)
dim   result2
if   rt1   =   1   then
'---------------------------------------温度图(t1的实现)的实现开始---------------------------------------------
                if   isnumeric(text1.text)   then
                        k   =   format(text1,   "##.0 ")   *   60   -   50   '+   1950
                        if   k   <=   2050   then                                                                           '程序开始的时候波动很大,35度*60-50=2050
                        k   =   2050
                        end   if
                else
                        text4.text   =   "温度待测 "
                end   if
                        result2   =   bitblt(picture5.hdc,   4,   0,   picture5.width   /   screen.twipsperpixelx,   picture5.height   /   screen.twipsperpixely,   picture5.hdc,   0,   0,   srccopy)
                        p(0)   =   ((-4)   *   val(k)   /   4095   +   3)   *   (picture5.height   /   screen.twipsperpixely)
                        'p   =   4   *   ((4095   -   csng(k)   -   1023)   /   4095   *   (picture5.height   /   screen.twipsperpixely))
                        ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' '****************************** ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' '
                        if   prevp(0)   <>   -1.003   then
                        picture5.line   (4,   p(0))-(8,   prevp(0)),   picture1color(1)   '在picture1上画线并设置颜色
                        prevp(0)   =   p(0)
                        end   if
                       
'---------------------------温度3的数据存入数据库开始-------------------------------------------------------
                if   wendu1   <   val(k)   then
                wendu1   =   val(k)
                end   if

'---------------------------------------温度图(t1的实现)的实现结束---------------------------------------------

end   if

end   sub

private   sub   timer2_timer()
dim   k
dim   p(1)
dim   result2
if   rt2   =   1   then
'---------------------------------------温度图(t2的实现)的实现开始---------------------------------------------
                if   isnumeric(text2.text)   then
                        k   =   format(text2,   "##.0 ")   *   60   -   50   '+   1950
                        if   k   <=   2050   then                                                                           '程序开始的时候波动很大,35度*60-50=2050
                        k   =   2050
                        end   if
                else
                        text5.text   =   "温度待测 "
                end   if
                        result2   =   bitblt(picture5.hdc,   4,   0,   picture5.width   /   screen.twipsperpixelx,   picture5.height   /   screen.twipsperpixely,   picture5.hdc,   0,   0,   srccopy)
                        p(1)   =   ((-4)   *   val(k)   /   4095   +   3)   *   (picture5.height   /   screen.twipsperpixely)
                        'p   =   4   *   ((4095   -   csng(k)   -   1023)   /   4095   *   (picture5.height   /   screen.twipsperpixely))
                        ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' '****************************** ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' '
                        if   prevp(0)   <>   -1.003   then
                        picture5.line   (4,   p(1))-(8,   prevp(0)),   picture1color(2)   '在picture1上画线并设置颜色
                        prevp(0)   =   p(1)
                        end   if
               
'----------------------------温度3的数据存入数据库开始-------------------------------------------------------
                if   wendu2   <   val(k)   then
                wendu2   =   val(k)
                end   if

'---------------------------------------温度图(t2的实现)的实现结束---------------------------------------------
end   if

end   sub

private   sub   timer3_timer()           '模拟采集卡采集到的温度

if   j   <=   50   then
j   =   j   +   0.01
text1.text   =   j
end   if

if   j   =   50   then
j   =   35
end   if

if   m   <=   50   then
m   =   m   +   0.02
text2.text   =   m
end   if

if   m   =   50   then
m   =   35
end   if

end   sub
发表于:2007-03-17 22:50:441楼 得分:0
可以把程序发过去,模拟程序很简单,只有picture5,check1,check2,text1,text2控件
发表于:2007-03-17 23:20:052楼 得分:0
自己顶一下吧
发表于:2007-03-18 09:52:053楼 得分:0
大家帮忙啊,分不够可以加分阿
发表于:2007-03-18 11:03:534楼 得分:0
你把timer1和timer2合并一下吧,否则,两个定时器事件,每次会把图形向左移动两次的。
发表于:2007-03-18 11:12:285楼 得分:0
就是要动态的不断的画图的阿
我合并过不行,我把程序发给你帮我看看
发表于:2007-03-18 11:25:326楼 得分:0
就是没人肯帮忙啊,怎么整的,对于高手来说这不是什么难题吧
发表于:2007-03-19 10:11:487楼 得分:20
private   sub   timer1_timer()
'---------------------------------------温度图的实现---------------------------------------------
                        k(0)   =   ad_chn(16,   readlen   -   1)       '从采集卡中采集数据1
                        result2   =   bitblt(picture1.hdc,   4,   0,   picture1.width   /   screen.twipsperpixelx,   picture1.height   /   screen.twipsperpixely,   picture1.hdc,   0,   0,   srccopy)
                        p(0)   =   ((-4)   *   val(k(0))   /   4095   +   3)   *   (picture1.height   /   screen.twipsperpixely)
                        k(1)   =   ad_chn(16,   readlen   -   1)       '从采集卡中采集数据2
                        result2   =   bitblt(picture1.hdc,   4,   0,   picture1.width   /   screen.twipsperpixelx,   picture1.height   /   screen.twipsperpixely,   picture1.hdc,   0,   0,   srccopy)
                        p(1)   =   ((-4)   *   val(k(1))   /   4095   +   3)   *   (picture1.height   /   screen.twipsperpixely)

        if   check1.value   =   vbchecked   and   check2.value   =   vbunchecked   then
                call   picline1
        elseif   check2.value   =   vbchecked   and   check1.value   =   vbunchecked   then
                call   picline2
        elseif   check1.value   =   vbchecked   and   check2.value   =   vbchecked   then
                call   picline1
                call   picline2
        end   if
                prevp(0)   =   p(0)
                prevp(1)   =   p(1)
end   sub

private   sub   check1_click()
    if   check1.value   =   vbchecked   then
            check1.caption   =   "画a线 "
      elseif   check1.value   =   vbunchecked   then
            check1.caption   =   "不画a线 "
      end   if
end   sub

private   sub   check2_click()
    if   check2.value   =   vbchecked   then
            check2.caption   =   "画b线 "
      elseif   check2.value   =   vbunchecked   then
            check2.caption   =   "不画b线 "
      end   if
end   sub

public   sub   picline1()
                        picture1.line   (4,   p(0))-(8,   prevp(0)),   picture1color1   '在picture1上画线并设置颜色
                       
end   sub
public   sub   picline2()
        picture1.line   (4,   p(1))-(8,   prevp(1)),   picture1color2   '在picture1上画线并设置颜色
end   sub


快速检索

最新资讯
热门点击