Dim drv As String
Private Declare Function StretchBlt Lib "gdi32" ( _
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
Private Sub Dir1_Change()
File1.path = Dir1.path
End Sub
Private Sub Dir1_Click()
With Dir1
.path = .List(.ListIndex)
End With
End Sub
Private Sub Dir1_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single)
With Dir1
.ToolTipText = .List(.ListIndex)
End With
End Sub
Private Sub Drive1_Change()
On Error GoTo Err
Dir1.path = Drive1
Exit Sub
Err:
Drive1 = drv
End Sub
Private Sub File1_Click()
Set pic.Picture = Nothing
Set p.Picture = Nothing
Dim path As String
Dim x As Single
Dim blnW As Boolean
If pic.Width > pic.Height Then
x = pic.Width / pic.Height
blnW = True
Else
x = pic.Height / pic.Width
blnW = False
End If
path = Dir1.path
If Right(path, 1) <> "\" Then path = path & "\"
pic.Picture = LoadPicture(path & File1.FileName)
pic.Refresh: DoEvents
If blnW Then
x = p.Height / x: DoEvents
StretchBlt p.hdc, 0, 0, p.Width, Int(x), pic.hdc, 0, 0, pic.Width, pic.Height, vbSrcCopy
Else
x = p.Width / x: DoEvents
StretchBlt p.hdc, 0, 0, Int(x), p.Height, pic.hdc, 0, 0, pic.Width, pic.Height, vbSrcCopy
End If
p.Refresh
End Sub
Private Sub Form_Load()
drv = Drive1
End Sub
问题是出现的缩略图是油彩一样,怎样让它不失真?