Private Sub Form_Resize()
If WindowState = vbMinimized Then Exit Sub
Image1.Move 0, 0, Form.ScaleWidth, Form.ScaleHeight
End Sub
[此贴子已经被作者于2005-3-18 19:16:38编辑过]
建一个窗体,放一个Frame,一个PictureBox,两个Option按钮,一个CommandButton,一个CommonDialog控件,加入以下代码: Option Explicit
Private Sub Command1_Click() CommonDialog1.FileName = "" CommonDialog1.Filter = "所有图片文件|*.jpg;*.gif;*.bmp" CommonDialog1.ShowOpen If CommonDialog1.FileName <> "" Then Picture1.Picture = LoadPicture(CommonDialog1.FileName) Call Form_Paint End If End Sub
'在Form_Paint事件中编写重绘代码。 Private Sub Form_Paint() If Picture1.Picture = 0 Then Exit Sub If Option1.Value = True Then Me.PaintPicture Picture1.Picture, 0, 0, Me.ScaleWidth, Me.ScaleHeight Else Dim i As Integer, j As Integer Picture1.AutoSize = True For i = 0 To Me.ScaleWidth \ Picture1.ScaleWidth For j = 0 To Me.ScaleHeight \ Picture1.ScaleHeight Me.PaintPicture Picture1.Picture, i * Picture1.Width, j * Picture1.Height Next Next End If End Sub
Private Sub Option1_Click() Call Form_Paint End Sub
Private Sub Option2_Click() Call Form_Paint End Sub 效果如下: