vb6里,把picture控件放在form里,如何让窗体出现垂直滚动条?

myface2011 2014-07-26 11:44:53
我在VB6里,放置了很多个picture控件,用来表示一些图形,但是现在有多个picture控件,我的form长和宽有限,我现在将多个picture控件直接放在form上,当form运行时,有些picture是挡住了,看不到,想用滚动条来看到所有的picture控件,请问如何解决?
...全文
701 12 打赏 收藏 转发到动态 举报
写回复
用AI写文章
12 条回复
切换为时间正序
请发表友善的回复…
发表回复
熊孩子开学喽 2014-11-03
  • 打赏
  • 举报
回复
简单点:用个msflexgrid,设成单列,每行一格, 各自加载图片即可
赵4老师 2014-08-04
  • 打赏
  • 举报
回复
美女!
pipi20091001 2014-08-03
  • 打赏
  • 举报
回复
计算位置,然后移动!
嗷嗷叫的老马 2014-08-01
  • 打赏
  • 举报
回复
引用 8 楼 zzyong00 的回复:
[quote=引用 7 楼 myjian 的回复:] http://www.m5home.com/bak_blog2/article/125.html 好老的代码了,给你参考吧
又见故人!老马你好啊 你压缩包里的美女真不错呀!!!!!!!!!!!!!!![/quote] 阿勇好啊!好久不见!就知道有人会说美女!哈哈
zzyong00 2014-07-28
  • 打赏
  • 举报
回复
引用 7 楼 myjian 的回复:
http://www.m5home.com/bak_blog2/article/125.html 好老的代码了,给你参考吧
又见故人!老马你好啊 你压缩包里的美女真不错呀!!!!!!!!!!!!!!!
Tiger_Zhao 2014-07-28
  • 打赏
  • 举报
回复
这个帖子的15楼,这是滚动一个图的。
多个图原理也一样,都是坐标偏移 (-HScroll1.Value, -VScroll1.Value)。
嗷嗷叫的老马 2014-07-28
  • 打赏
  • 举报
回复
http://www.m5home.com/bak_blog2/article/125.html 好老的代码了,给你参考吧
笨狗先飞 2014-07-27
  • 打赏
  • 举报
回复
你试一下这个,运行时候拖动一下pict试试

Private mx As Single, my As Single
Private numBox As Integer     '每行显示的盒子数
Private leftStart, topStart, HSpace, VSpace, WBox, HBox As Integer 'x,y起点;水平和垂直间距

Private Sub Form_Load()
    numBox = 8
    leftStart = 200
    topStart = 200
    HSpace = 40
    VSpace = 40
    WBox = 800
    HBox = 800
    CreatePictArray 400
    ListBox
End Sub

Private Sub CreatePictArray(ByVal Count As Integer)
    Dim I As Integer
    For I = 0 To Count - 1
        If I > pict.UBound Then Load pict(I)
        pict(I).Move leftsrart, topStart, WBox, HBox
        pict(I).Visible = True
        '===============
        pict(I).AutoRedraw = True
        pict(I).Print I
        '===============
    Next
End Sub

Private Sub ListBox()
    Dim xPos As Single, yPos As Single
    For I = 0 To pict.UBound
        xPos = leftStart + (I Mod numBox) * (WBox + HSpace)
        yPos = topStart + (I \ numBox) * (HBox + VSpace)
        If (xPos + (WBox + HSpace) > 0) And (yPos + (HBox + VSpace) > 0) And (xPos + (WBox + HSpace) < Me.ScaleWidth) And (yPos + (HBox + VSpace) < Me.ScaleHeight) Then
            pict(I).Move xPos, yPos
            pict(I).Visible = True
        Else
            pict(I).Visible = False
        End If
    Next
End Sub

Private Sub Form_Resize()
    If Me.WindowState = 1 Then Exit Sub
    ListBox
End Sub

Private Sub pict_MouseDown(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)
    If Button = 1 Then
        mx = X
        my = Y
    End If
End Sub

Private Sub pict_MouseMove(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)
    If Button = 1 Then
        'leftStart = leftStart + (X - mx)'不想水平方向移动就把这条注释掉
        topStart = topStart + (Y - my)
        ListBox
    End If
End Sub
myface2011 2014-07-26
  • 打赏
  • 举报
回复
新产生的picture的坐标位置包括宽度和高度,我都是计算可以得到,frame里如何放?如何产生滚动条
笨狗先飞 2014-07-26
  • 打赏
  • 举报
回复
要自己处理控件位置的,比如可以全放到一个Frame里,然后调整Frame的位置
myface2011 2014-07-26
  • 打赏
  • 举报
回复
我的代码这样:现在显示出来效果,但是当里面盒子数超过窗体的高度时,没有滚动条,窗体里放入一个picturebox控件,并且index设置成0,命名成pict
代码如下:
Dim numBox As Integer     '每行显示的盒子数
Dim leftStart, topStart, HSpace, VSpace, WBox, HBox As Integer 'x,y起点;水平和垂直间距
Dim oriTop As Integer 'y方向初始坐标值
Dim x_pos, y_pos As Integer '当前x,y的值
Private Sub Form_Load()
CreatePictArray
ListBox
End Sub

Private Sub CreatePictArray()
Dim i As Integer
For i = 1 To 400
Load pict(i)
pict(i).Width = 800
pict(i).Height = 800
pict(i).Visible = False
Next
pict(0).Visible = False
End Sub

Private Sub ListBox()
numBox = 8
leftStart = 200
topStart = 200
oriTop = 200
HSpace = 40
VSpace = 40
WBox = 800
HBox = 800
Dim i As Integer
For i = 1 To 60
If i Mod numBox = 0 Then
x_pos = leftStart + ((i Mod numBox) + numBox - 1) * (WBox + HSpace)
y_pos = topStart
pict(i).Visible = True
pict(i).Left = x_pos
pict(i).Top = y_pos
pict(i).Picture = LoadPicture("xxx.jpg")
topStart = (i / numBox) * (HBox + VSpace) + oriTop
Else
pict(i).Visible = True
x_pos = leftStart + ((i Mod numBox) - 1) * (WBox + HSpace)
y_pos = topStart
pict(i).Left = x_pos
pict(i).Top = y_pos
pict(i).Picture = LoadPicture("c:\xxx.jpg")
End If
Next i
End Sub

笨狗先飞 2014-07-26
  • 打赏
  • 举报
回复
怎么在运行时拖动控件知道吗? 只能给你个简单的例子自己看一下,剩下来的自己想吧,滚动条好看难看也是个烦心事

'窗体上加一个Frame1控件
Private mx As Single
Private my As Single

Private Sub Frame1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    If Button = 1 Then
        mx = X
        my = Y
    End If
End Sub

Private Sub Frame1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    If Button = 1 Then
        Frame1.Left = Frame1.Left + (X - mx)
        Frame1.Top = Frame1.Top + (Y - my)
    End If
End Sub

1,451

社区成员

发帖
与我相关
我的任务
社区描述
VB 控件
社区管理员
  • 控件
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧