form1.borderstyle=0 picture1.width=form1.width picture1.height=form1.height'dst:对像,如picture1 'xrate:宽度缩放倍数 'yrate:高度缩放倍数 'filename:要显示的图片文件 Public Sub DrawPicture(Dst As Object, ByVal xRate As Double, _ ByVal yRate As Double, ByVal filename As String) Dim dstWidth As Long, dstHeight As Long Dim srcWidth As Long, srcHeight As Long Dim X As Long, Y As Long Dim pic As StdPicture Dim i As Long Set pic = LoadPicture(filename) '读取图形档 srcHeight = Dst.ScaleY(pic.Height, vbHimetric, vbPixels) srcWidth = Dst.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 Dst.ScaleMode = 3 Dst.PaintPicture pic, X, Y, dstWidth, dstHeight, 0, 0, srcWidth, srcHeight End Sub
把form的BorderStyle设成None. Private Sub Form_Load() Me.Move 0, 0, Screen.Width, Screen.Height Picture1.Move 0, 0, Me.Width, Me.Height End Sub
picture1.width=form1.width
picture1.height=form1.height'dst:对像,如picture1
'xrate:宽度缩放倍数
'yrate:高度缩放倍数
'filename:要显示的图片文件
Public Sub DrawPicture(Dst As Object, ByVal xRate As Double, _
ByVal yRate As Double, ByVal filename As String)
Dim dstWidth As Long, dstHeight As Long
Dim srcWidth As Long, srcHeight As Long
Dim X As Long, Y As Long
Dim pic As StdPicture
Dim i As Long
Set pic = LoadPicture(filename) '读取图形档
srcHeight = Dst.ScaleY(pic.Height, vbHimetric, vbPixels)
srcWidth = Dst.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
Dst.ScaleMode = 3
Dst.PaintPicture pic, X, Y, dstWidth, dstHeight, 0, 0, srcWidth, srcHeight
End Sub
Private Sub Form_Load()
Me.Move 0, 0, Screen.Width, Screen.Height
Picture1.Move 0, 0, Me.Width, Me.Height
End Sub