VB中, 能否更改 Slider的背景颜色, 或者谁有自定义的slider控件, 共享一下, 谢了。
1个回答
展开全部
结果!
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
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询