⑴ vb中如何使图片自动放大和缩小
用image控件,设置image1的Stretch属性值为True,图像就缩放为image控件大小。
⑵ 如何用VB制作图片放大和缩小
Dim ph%, pw%
Private Sub Form_Load()
ph = Picture1.Height
pw = Picture1.Width
End Sub
Private Sub HScroll1_Change()
Picture1.Left = -HScroll1.Value
Picture1.Width = pw + HScroll1.Value
End Sub
Private Sub Picture1_Click()
End Sub
Private Sub VScroll2_Change()
Picture1.Top = -VScroll2.Value
Picture1.Height = ph + VScroll2.Value
End Sub
⑶ VB中如何才能自动放大缩小图片填充到图片框中啊
实现代码:
VERSION 5.00
BeginVB.FormForm1
Caption="使用PictureBox控件实现图像放大和缩小"
ClientHeight=5580
ClientLeft=60
ClientTop=345
ClientWidth=7935
LinkTopic="Form1"
ScaleHeight=5580
ScaleWidth=7935
StartUpPosition=3'窗口缺省
BeginVB.PictureBoxPicture1
AutoRedraw=-1'True
AutoSize=-1'True
Height=3960
Left=-15
Picture="Form1.frx":0000
ScaleHeight=3900
ScaleWidth=6240
TabIndex=2
Top=15
Width=6300
End
BeginVB.CommandButtonCommand2
Caption="放大"
Height=360
Left=6540
TabIndex=1
Top=5070
Width=1140
End
BeginVB.CommandButtonCommand1
Caption="缩小"
Height=360
Left=5160
TabIndex=0
Top=5070
Width=1140
End
End
AttributeVB_Name="Form1"
AttributeVB_GlobalNameSpace=False
AttributeVB_Creatable=False
AttributeVB_PredeclaredId=True
AttributeVB_Exposed=False
DimiAsInteger
DimjAsInteger
PrivateSubCommand1_Click()
Picture1.Cls
i=i-100:j=j-100
Picture1.PaintPicturePicture1.Picture,0,0,i,j
Picture1.Width=i:Picture1.Height=j
EndSub
PrivateSubCommand2_Click()
Picture1.Cls
Picture1.Width=i:Picture1.Height=j
i=i+100:j=j+100
Picture1.PaintPicturePicture1.Picture,0,0,i,j
EndSub
PrivateSubForm_Load()
i=Picture1.Width:j=Picture1.Height
Picture1.Cls
EndSub
VB6.0通过PictureBox控件实现图片放大和图片缩小功能
(3)如何把vb中放大的工具箱缩小扩展阅读:
其它方法:
例子前请先下载Gdiplus.tlb,并将其放置到C:\Windows\System32中
Gdiplus.tlb下载
VisualBasiccode
使用Gdiplus.tlb,将其放到system32中,然后添加对其的引用
手动设置Form的AutoRedraw=True,ScaleMode=Pixels
OptionExplicit
DimlngGraphicsAsLong
DimlngImageHandleAsLong
DimlngTextureBrushAsLong
DimgpPAsGpStatus
DimlngPen1AsLong
DimlngTokenAsLong
PrivateSubCommand1_Click()
DimintPAsInteger
gpP=GdipCreateFromHDC(Me.hDC,lngGraphics)'创建绘图区域设备场景
gpP=GdipLoadImageFromFile(App.Path&"\启动.png",lngImageHandle)'读取图片到内存
gpP=GdipDrawImage(lngGraphics,lngImageHandle,0,0)'等大小绘制
gpP=GdipDrawImageRect(lngGraphics,lngImageHandle,200,0,300,300)'在指定的区域内绘制(放大或缩小)
gpP=GdipDrawImageRectRectI(lngGraphics,lngImageHandle,550,0,400,400,20,20,80,80,UnitPixel)'在400*400的区域内显示图片部分区域
gpP=GdipCreateTexture(lngImageHandle,WrapModeTile,lngTextureBrush)'设置一定排列方式的刷子平铺方式
gpP=GdipFillRectangle(lngGraphics,lngTextureBrush,0,300,400,300)'在指定区域内按指定的格式绘制图片
IflngGraphics<>
IflngImageHandle<>
IflngTextureBrush<>
Me.Refresh
EndSub
PrivateSubForm_Load()
DimbolPAsBoolean
WithMe
.Caption="GDIPlus范例"
.Width=960*15
.Height=720*15
.Left=(Screen.Width-.Width)*0.5
.Top=(Screen.Height-.Height)*0.5
EndWith
GpInput.GdiplusVersion=1
IflngToken=0ThenbolP=(GdiplusStartup(lngToken,GpInput)=Ok)
EndSub
⑷ 在VB中,如何实现图片的等比例放大或缩小
给你一个我原来做过的实例吧。imgPreview 为Image对象。
Private Type PreviewSize
sngLeft As Single
sngTop As Single
sngWidth As Single
sngHeight As Single
intZoon As Integer
End Type
Private muPreviewSize As PreviewSize
Private Const cmChangeSize = 1.2
'// 缩小
Private Sub Command1_Click()
With muPreviewSize
.intZoon = .intZoon - 1
.sngHeight = .sngHeight / cmChangeSize
.sngWidth = .sngWidth / cmChangeSize
imgPreview.Stretch = True
imgPreview.Move .sngLeft, .sngTop, .sngWidth, .sngHeight
'// 如果已经缩小了9倍则缩小按钮不可用
If .intZoon < -9 Then
Command1.Enabled = False
Command2.Enabled = True
Else
Command2.Enabled = True
End If
End With
End Sub
'// 放大
Private Sub Command2_Click()
With muPreviewSize
.intZoon = .intZoon + 1
.sngHeight = .sngHeight * cmChangeSize
.sngWidth = .sngWidth * cmChangeSize
imgPreview.Stretch = True
imgPreview.Move .sngLeft, .sngTop, .sngWidth, .sngHeight
'// 如果已经放大了9倍则放大按钮不可用
If .intZoon > 9 Then
Command2.Enabled = False
Command1.Enabled = True
Else
Command1.Enabled = True
End If
End With
End Sub
Private Sub Form_Load()
With muPreviewSize
.intZoon = 0
'// + 0.5 为Image的边框
.sngHeight = imgPreview.Height + 0.5
.sngWidth = imgPreview.Width + 0.5
.sngLeft = imgPreview.Left
.sngTop = imgPreview.Top
End With
End Sub
⑸ vb 如何放大或缩小图片,用Picture控件
用 PictureBox 肯定是可以的,但我猜想你只是想显示一下而已,那为什么不用 Image 控件呢?
尝试一下 Image 控件的 Stretch 属性吧。
⑹ VB中“窗体放大一倍”和窗体缩小一倍怎么做
Private Sub Command1_Click() ' 这里是窗口放大2倍
Form1.Height = Form1.Height * 2 'form1就是窗口的名字,
Form1.Width = Form1.Width * 2
End Sub
Private Sub Command2_Click() ' 这里是窗口缩小2倍
Form1.Height = Form1.Height / 2
Form1.Width = Form1.Width / 2
End Sub
⑺ vb语言中怎么使窗体和窗体里的控件同时放大缩小
思路在form1的load和resize里设置每个控件的长宽,都用form1的长宽表示,比如command1.width=1/20*me.width 这样当当窗体宽度改变后按钮的宽度始终是它的1/20高度类同
⑻ VB中如何设置将程序缩小至工具栏
缩小至工具栏需要用API Shell_NotifyIcon
用Windows的计划任务。
或者程序启动后检查是不是星期1~5,不是的话就退出。
⑼ VB 运行时如何使picture控件随窗体放大缩小
首先在设计时确定窗体与Picturebox之间的关系,例如Picture1.Left=? Picture1.Top=? Picture1.Width 与 me.Width 的比例关系,Picture1.Height 与 me.Height 的比例关系
那么,在Form_Resize事件中就可以按比例放大或缩小控件尺寸,但控件位置不变,例如
Dim X As Single, Y As Single
Private Sub Form_Load()
X = Picture1.Height / Me.Height
Y = Picture1.Width / Me.Width
End Sub
Private Sub Form_Resize()
Picture1.Height = Me.Height * X
Picture1.Width = Me.Width * Y
End Sub
⑽ 用VB怎样实现图片按比例放大缩小
用image控件 把stretch属性改为true
例
Private Sub Form_Load()
Image1.Stretch = True
End Sub
Private Sub Command1_Click()
Image1.Height = Image1.Height * Val(Text1.Text)
Image1.Width = Image1.Width * Val(Text1.Text)
End Sub