add image1,command1
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
add image1,command1
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