1,451
社区成员
发帖
与我相关
我的任务
分享
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
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
'窗体上加一个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