怎么用VB中的slider控件控制控件
控制的控件是张图片来的,就是我插入的一张图片后,然后再图片上加个方框,slider的值大了,那个方框就变大,改小方框就变小。怎么弄啊,高手们帮帮忙,好人一生平安。谢谢。现...
控制的控件是张图片来的,就是我插入的一张图片后,然后再图片上加个方框,slider的值大了,那个方框就变大,改小方框就变小。怎么弄啊,高手们帮帮忙,好人一生平安。谢谢。
现在问题是那个方框不知道要用什么控件来画。不能档住图片,但又要在图片上面。还要能增大缩小。。! 展开
现在问题是那个方框不知道要用什么控件来画。不能档住图片,但又要在图片上面。还要能增大缩小。。! 展开
推荐于2018-04-11 · 知道合伙人软件行家
关注
展开全部
VB可通过Slider控件的Scroll事件,获得Slider控件的Value 属性来控制某个控件的变化。
Scroll 事件(Slider 控件)
当单击控件或使用键盘命令移动 Slider 控件上的滑块时,该事件发生。
Value 属性
返回或设置对象的值。
以下是一段实现代码,控制Shape控件的宽高尺寸,在图片框上改变。
Option Explicit
Dim X As Long, Y As Long
Dim Po As Long
Private Sub Form_Load()
Picture1.ForeColor = vbRed
Slider1.Min = 0
Slider1.Max = 100
X = 500: Y = 500 * Picture1.Height / Picture1.Width
Po = 0
Shape1.BorderColor = vbWhite
Shape1.Top = 10
Shape1.Left = 10
Shape1.Height = Y
Shape1.Width = X
End Sub
Private Sub Slider1_Scroll()
If Slider1.Value > Po Then
X = X + Slider1.Value * 3
Y = Y + Slider1.Value * 3 * Picture1.Height / Picture1.Width
Else
X = X - Slider1.Value * 3
Y = Y - Slider1.Value * 3 * Picture1.Height / Picture1.Width
End If
Po = Slider1.Value
Shape1.Height = Y
Shape1.Width = X
End Sub
展开全部
简单的写了这么一段代码,看是不是能达到你所期望的结果!
1、在窗体中添加一个Slider控件,两个PictureBox控件,即:Picture1 和 Picture2;
2、在属性窗口中设置picture2的picture属性,即载入一张大小合适的背景图像;同时设置picture2的visible属性为false
代码如下:
Dim x1 As Long, y1 As Long
Dim x2 As Long, y2 As Long
Dim p As Long
Private Sub Form_Load()
Picture1.ForeColor = vbRed
Slider1.Min = 0
Slider1.Max = 100
x1 = 100: y1 = 100
x2 = 500: y2 = 500
Picture1.Line (x1, y1)-(x2, y2), , B
p = 0
End Sub
Private Sub Slider1_Scroll()
Picture1.PaintPicture Picture2.Picture, 0, 0, , , , , , , vbSrcCopy
If Slider1.Value > p Then
x2 = x2 + Slider1.Value
y2 = y2 + Slider1.Value
Else
x2 = x2 - Slider1.Value
y2 = y2 - Slider1.Value
End If
p = Slider1.Value
Picture1.Line (x1, y1)-(x2, y2), , B
End Sub
1、在窗体中添加一个Slider控件,两个PictureBox控件,即:Picture1 和 Picture2;
2、在属性窗口中设置picture2的picture属性,即载入一张大小合适的背景图像;同时设置picture2的visible属性为false
代码如下:
Dim x1 As Long, y1 As Long
Dim x2 As Long, y2 As Long
Dim p As Long
Private Sub Form_Load()
Picture1.ForeColor = vbRed
Slider1.Min = 0
Slider1.Max = 100
x1 = 100: y1 = 100
x2 = 500: y2 = 500
Picture1.Line (x1, y1)-(x2, y2), , B
p = 0
End Sub
Private Sub Slider1_Scroll()
Picture1.PaintPicture Picture2.Picture, 0, 0, , , , , , , vbSrcCopy
If Slider1.Value > p Then
x2 = x2 + Slider1.Value
y2 = y2 + Slider1.Value
Else
x2 = x2 - Slider1.Value
y2 = y2 - Slider1.Value
End If
p = Slider1.Value
Picture1.Line (x1, y1)-(x2, y2), , B
End Sub
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询