您现在的位置: > 首页 > 程序开发 > vb教程
>> 最新教程
>> 热门教程
>> 最新游戏资讯
>> 热门游戏资讯
VB入门技巧50例(四)
作者:本站                来自:安迪教程网                 加入时间:08-07-22                进入论坛讨论

  41.如何在小画面上显示大图片

  方法一:

  一个picturebox控件,一个image控件(以picturebox为容器),图片加载在image中,一个HScroll1,VScroll1(以picturebox为容器)。

Private Sub Bar1_Change()
Image1.Left = -bar1.Value
End Sub
Private Sub Bar2_Change()
Image1.Top = -Bar2.Value
End Sub
Private Sub Form_Load()
Image1.Left = 0
Image1.Top = 0
bar1.SmallChange = 300
Bar2.SmallChange = 300
bar1.Max = Image1.Width - Picture1.Width
Bar2.Max = Image1.Height - Picture1.Height
bar1.Min = 0
Bar2.Min = 0
End Sub

  方法二:利用鼠标移动图片

  一个picturebox控件,一个image控件(以picturebox为容器),图片加载在image中

Dim ix As Integer
Dim iy As Integer
Private Sub Form_Load()
Image1.Left = 0
Image1.Top = 0
End Sub
Private Sub Image1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = vbLeftButton Then
ix = X
iy = Y
End If
End Sub
Private Sub Image1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Dim ipx As Integer
Dim ipy As Integer
If Button = vbLeftButton Then
ipx = Image1.Left + X - ix
ipy = Image1.Top + Y - iy
If ipx > 0 Then
Image1.Left = 0
Else
If ipx < Picture1.Width - Image1.Width Then
ipx = Picture1.Width - Image1.Width
Else
Image1.Left = ipx
End If
End If
If ipy > 0 Then
Image1.Top = 0
Else
If ipy < Picture1.Height - Image1.Height Then
ipy = Picture1.Height - Image1.Height
Else
Image1.Top = ipy
End If
End If
End If
End Sub
Private Sub Image1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
Me.MousePointer = 0
End Sub

  42. 使窗体不出屏幕左边界

<<< << < 1 2 3 4 5 > >> >>>
联系方式:QQ:6084884 email:agwcn@126.com 粤ICP备05055782号
本网站中发布的文章只代表发表人的个人观点,不代表安迪教程网网站的立场
copyright© 2000-2004 安迪教程网 All rights reserved agwcn.com