请问谁有这方面的代码没啊!急用
用按钮控制放大缩小漫游
用按钮控制放大缩小漫游
解决方案 »
- 连接数据库方面
- 菜鸟来报告,怎样画可缩放且带分度的坐标轴
- 怎么解决MSFlexGrid多行删除??
- 有关文件打包问题!(安装时出错,)
- 如果用API函数得到win2000安装的版本(Advance Server、Server、Profession)?
- 有关IFF,巨简单,在线等!!!!!!!!!!分给第一跟人
- 急!:VB和WINDOWS应用程序怎样交换消息?------=高分相赠
- 如何实现多个winsock客户端与服务器端的连接
- 数据库访问的问题,请各位赐教!
- 请问如何用回车键代替TAB键做控件间的跳转?不要在每个控件中都加keypress!
- 如何在一个工程打印另一个工程中的变量?
- 【八卦头条】老鸟大叔的玉照
Private m_rate As DoublePrivate Sub Draw()
Picture1.Cls
Picture1.PaintPicture m_pic, 0, 0, 800 * m_rate, 600 * m_rate, 0, 0, 800, 600
End SubPrivate Sub Command1_Click()
m_rate = m_rate * 2
Draw
End SubPrivate Sub Command2_Click()
m_rate = m_rate / 2
Draw
End SubPrivate Sub Form_Load()
Set m_pic = LoadPicture("C:\WINDOWS\Web\Wallpaper\Bliss.bmp")
m_rate = 1
Picture1.AutoRedraw = True
Picture1.ScaleMode = vbPixels
Draw
End Sub
Picture1.Move X, YEnd SubPrivate Sub Picture1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
Picture1.Drag ' 拖标签轮廓。
End Sub
来源:cwwVB中图存档使用 SavePicture 指令,而它的叁数是
picture 产生图形档案的 PictureBox 控制项或 Image 控制项。
stringexpression 储存的图形档案名称而我的作法是:在PictureBox的Image属性上作动作,因为PictureBox上的Picture经设
定後,它就固定下来,我们在其上的绘图等动作,基本上没有动到Picture属性所指的图
,而想改变到图,就只能从Image上着手。所以了,一定得设定PictureBox的AutoRedraw
为True,这才会使绘图的动作在Image上发生,最後再使用SavePicture的指令,传Image
当第一个叁数来存档。这里有另一个重要的问题,如果PictureBox的大小是100*100,
而实际进来的图是50*50,那麽,PictureBox.Image其大小范围仍是100*100,因而我一开
始设定PictureBox的长宽各为1,等後来图放大後,PictureBox Image的大小也随之变大。
也正因我们使用的是PictureBox的Image物件,所以存档的结果只能是Bitmap图,这点要
特别注意。'需一个PictureBox, 一个Command button
Option Explicit
Dim pic As New StdPicture
Private Sub Command1_Click()
Set pic = LoadPicture("e:\girl.bmp") '请输入想放大/缩小的图
Call setScope(pic, 0.5, 0.5, Picture1) '缩小0.5倍,将之放入Picture1
SavePicture Picture1.Image, "e:\t2.bmp" '存档
Picture1.Visible = True
End Sub
Private Sub Form_Load()
Me.ScaleMode = 3
Picture1.AutoRedraw = True
Picture1.ScaleMode = 3Picture1.BorderStyle = 0
Picture1.Visible = FalsePicture1.Width = 1 '设定PictureBox为最小
Picture1.Height = 1End SubPrivate Sub setScope(pic As StdPicture, ByVal xRate As Double, _
ByVal yRate As Double, pic2 As PictureBox)
Dim dstWidth As Long, dstHeight As Long
Dim srcWidth As Long, srcHeight As Long
Dim x As Long, y As Long
Dim i As Long srcHeight = pic2.ScaleY(pic.Height, vbHimetric, vbPixels)
srcWidth = pic2.ScaleX(pic.Width, vbHimetric, vbPixels) dstHeight = CLng(srcHeight * yRate)
If dstHeight < 0 Then
y = -1 * dstHeight
Else
y = 0
End If
dstWidth = CLng(srcWidth * xRate)
If dstWidth < 0 Then
x = -1 * dstWidth
Else
x = 0
End If
pic2.Width = Abs(dstWidth) '改变PictureBox的大小
pic2.Height = Abs(dstHeight)
pic2.PaintPicture pic, x, y, dstWidth, dstHeight, 0, 0, srcWidth, srcHeightEnd Sub这个是我在:http://download.csdn.net/source/1627065中找到的
Private m_rate As Double
Private m_OnDrag As Boolean
Private m_MoveX As Single
Private m_MoveY As Single
Private m_LastMouseX As Single
Private m_LastMouseY As SinglePrivate Sub Draw()
Picture1.Cls
Picture1.PaintPicture m_pic, m_MoveX, m_MoveY, 800 * m_rate, 600 * m_rate, 0, 0, 800, 600
End SubPrivate Sub Command1_Click()
m_rate = m_rate * 2
m_MoveX = m_MoveX * 2
m_MoveY = m_MoveY * 2
Draw
End SubPrivate Sub Command2_Click()
m_rate = m_rate / 2
m_MoveX = m_MoveX / 2
m_MoveY = m_MoveY / 2
Draw
End SubPrivate Sub Form_Load()
Set m_pic = LoadPicture("C:\WINDOWS\Web\Wallpaper\Bliss.bmp")
m_rate = 1
Picture1.AutoRedraw = True
Picture1.ScaleMode = vbPixels
Draw
End SubPrivate Sub Picture1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = vbLeftButton Then
m_OnDrag = True
m_LastMouseX = X
m_LastMouseY = Y
End If
End SubPrivate Sub Picture1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If m_OnDrag Then
m_MoveX = m_MoveX + (X - m_LastMouseX)
m_MoveY = m_MoveY + (Y - m_LastMouseY)
m_LastMouseX = X
m_LastMouseY = Y
Draw
End If
End SubPrivate Sub Picture1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
If (Button = vbLeftButton) And m_OnDrag Then
m_OnDrag = False
m_MoveX = m_MoveX + (X - m_LastMouseX)
m_MoveY = m_MoveY + (Y - m_LastMouseY)
m_LastMouseX = X
m_LastMouseY = Y
Draw
End If
End Sub