有列子最好
email: [email protected]
email: [email protected]
解决方案 »
- 高分请教一个有关水晶报表的简单问题
- 如果遇到字段是空值的时候怎么办?
- 在2000中一用realone控件VB就关了!
- 帮帮我吧,怎样让在系统中打开的EXCEL文件彻底关闭?
- 如何知道已经编译成的 dll 文件里有什么函数声明???
- 我想知道vb中是否有参数化打开一个窗口的方法
- 标题:access中通配符的使用
- 请教个控件的用法
- 让对象在窗体内来回移动,当移动到窗体边界又能反弹回去,这段代码怎么写?
- 怎样才能让DATAGRID随显示内容多少或窗体大小的改变而自动调整大小呢?
- 吐血大送分呀,谁知道vb中textbox1.text=chr(206)+chr(210)为什么不能显示一个汉字!
- datagrid 为何没有显示内容
to griefforyou(为你伤心) :
能让我瞧一瞧吗?
email: [email protected]
Declare Function StretchBlt Lib "gdi32" Alias "StretchBlt" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hSrcDC As Long, ByVal xSrc As Long, ByVal ySrc As Long, ByVal nSrcWidth As Long, ByVal nSrcHeight As Long, ByVal dwRop As Long) As Long
说明
将一幅位图从一个设备场景复制到另一个。源和目标DC相互间必须兼容。这个函数会在设备场景中定义一个目标矩形,并在位图中定义一个源图象。源矩形会根据需要进行伸缩,以便与目标矩形的大小相符
返回值
Long,非零表示成功,零表示失败。会设置GetLastError
参数表
参数 类型及说明
hdc Long,目标设备场景
x,y Long,目标矩形左上角的x,y坐标,以逻辑坐标表示
nWidth,nHeight Long,目标矩形的宽度和高度,以逻辑坐标表示
hSrcDC Long,源设备场景。如光栅运算未指定一个源,则这个参数应为零
xSrc,ySrc Long,用源DC的逻辑坐标表示的源矩形左上角位置
nSrcWidth,nSrcHeight Long,分别指定用逻辑单位(以源DC为基础)传输的一幅图象的宽度和高度。如其中有一个参数的符号(指正负号)与对应的目标参数不符,位图就会在对应的轴上作镜像转换处理
dwRop Long,传输过程中进行的光栅运算。如刷子属于光栅运算的一部分,就使用选入目标DC的刷子
把pivtureBox设为同窗体一样大
Private Sub Command1_Click()
Dim preImgWidth As Long
Dim preImgHeight As Long
Dim WndWidth As Long
Dim WndHeight As Long
Dim WRatio As Double
Dim HRatio As Double
Dim Ratio As Double
Dim preScaleMode As Integer
preScaleMode = Form1.ScaleMode
Form1.ScaleMode = 1
Image1.Stretch = False
'Image1.Visible = False
Image1.Picture = LoadPicture("d:\my pictures\06722.jpg")
Image1.Stretch = True
preImgWidth = Image1.Width
preImgHeight = Image1.Height
WndWidth = Form1.ScaleWidth
WndHeight = Form1.ScaleHeight
WRatio = WndWidth / preImgWidth
HRatio = WndHeight / preImgHeight
If WRatio > HRatio Then Ratio = HRatio
If Ratio < 1 Then
Image1.Width = preImgWidth * Ratio
Image1.Height = preImgHeight * Ratio
End If
Image1.Move (Form1.ScaleWidth - Image1.Width) / 2, (Form1.ScaleHeight - Image1.Height) / 2
Image1.Visible = True
Form1.ScaleMode = preScaleMode
End Sub
Private Sub Command1_Click()
Dim preImgWidth As Long
Dim preImgHeight As Long
Dim WndWidth As Long
Dim WndHeight As Long
Dim WRatio As Double
Dim HRatio As Double
Dim Ratio As Double
Dim preScaleMode As Integer
preScaleMode = Form1.ScaleMode
Form1.ScaleMode = 1
Image1.Stretch = False
'Image1.Visible = False
Image1.Picture = LoadPicture("d:\my pictures\06722.jpg")
Image1.Stretch = True
preImgWidth = Image1.Width
preImgHeight = Image1.Height
WndWidth = Form1.ScaleWidth
WndHeight = Form1.ScaleHeight
WRatio = WndWidth / preImgWidth
HRatio = WndHeight / preImgHeight
If WRatio > HRatio Then Ratio = HRatio
If Ratio < 1 Then
Image1.Width = preImgWidth * Ratio
Image1.Height = preImgHeight * Ratio
End If
Image1.Move (Form1.ScaleWidth - Image1.Width) / 2, (Form1.ScaleHeight - Image1.Height) / 2
Image1.Visible = True
Form1.ScaleMode = preScaleMode
End Sub
If WRatio > HRatio Then
Ratio = HRatio
Else
Ratio=WRatio
End if preImgWidth 图的实际宽度
preImgHeight 图的实际高度
WndWidth 窗口的宽度
WndHeight 窗口的高度
WRatio 图与窗口的宽度比 HRatio 图与窗口的高度比
Ratio 图全部显示的比例
图大于窗口时(Ratio>1)对图进行缩放