保存到记事本,然后另存为form1.frm VERSION 5.00 Begin VB.Form Form1 Caption = "Form1" ClientHeight = 4755 ClientLeft = 60 ClientTop = 345 ClientWidth = 5985 LinkTopic = "Form1" ScaleHeight = 4755 ScaleWidth = 5985 StartUpPosition = 3 '窗口缺省 Begin VB.CommandButton Command6 Caption = "Command6" Height = 495 Left = 1320 TabIndex = 6 Top = 4200 Width = 1215 End Begin VB.CommandButton Command5 Caption = "Command5" Height = 495 Left = 120 TabIndex = 5 Top = 4200 Width = 1215 End Begin VB.CommandButton Command4 Caption = "Command4" Height = 495 Left = 3720 TabIndex = 4 Top = 3600 Width = 1215 End Begin VB.PictureBox Picture1 Height = 3255 Left = 2520 Picture = "Form1.frx":0000 ScaleHeight = 3195 ScaleWidth = 3195 TabIndex = 3 Top = 120 Width = 3255 End Begin VB.CommandButton Command3 Caption = "Command3" Height = 495 Left = 2520 TabIndex = 2 Top = 3600 Width = 1215 End Begin VB.CommandButton Command2 Caption = "Command2" Height = 495 Left = 1320 TabIndex = 1 Top = 3600 Width = 1215 End Begin VB.CommandButton Command1 Caption = "Command1" Height = 495 Left = 120 TabIndex = 0 Top = 3600 Width = 1215 End End Attribute VB_Name = "Form1" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = False Attribute VB_PredeclaredId = True Attribute VB_Exposed = False Option Explicit 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 Declare Function BitBlt Lib "gdi32" (ByVal hDestDC 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 dwRop As Long) As Long '拷贝到窗体 Private Sub Command1_Click() Dim w As Integer, h As Integer Me.ScaleMode = vbPixels w = Picture1.Width h = Picture1.Height StretchBlt Me.hdc, 0, 0, w, h, Picture1.hdc, 0, 0, w, h, vbSrcCopy End Sub '放大: Private Sub Command2_Click() Dim w As Integer, h As Integer Me.ScaleMode = vbPixels w = Picture1.Width h = Picture1.Height StretchBlt Me.hdc, 0, 0, w * 2, h * 2, Picture1.hdc, 0, 0, w, h, vbSrcCopy End Sub '缩小: Private Sub Command3_Click() Dim w As Integer, h As Integer Me.ScaleMode = vbPixels w = Picture1.Width h = Picture1.Height StretchBlt Me.hdc, 0, 0, w / 2, h / 2, Picture1.hdc, 0, 0, w, h, vbSrcCopy End Sub '例3: 翻转图片 '左右翻转 Private Sub Command4_Click() Dim w As Integer, h As Integer Me.ScaleMode = vbPixels w = Picture1.Width h = Picture1.Height StretchBlt Me.hdc, w, 0, -w, h, Picture1.hdc, 0, 0, w, h, vbSrcCopy End Sub '上下翻转 Private Sub Command5_Click() Dim w As Integer, h As Integer Me.ScaleMode = vbPixels w = Picture1.Width h = Picture1.Height StretchBlt Me.hdc, 0, 0, w / 2, h / 2, Picture1.hdc, 0, 0, w, h, vbSrcCopy End Sub '左右并且上下翻转 Private Sub Command6_Click() Dim w As Integer, h As Integer Me.ScaleMode = vbPixels w = Picture1.Width h = Picture1.Height StretchBlt Me.hdc, w, h, -w, -h, Picture1.hdc, 0, 0, w, h, vbSrcCopy End Sub
VERSION 5.00
Begin VB.Form Form1
Caption = "Form1"
ClientHeight = 4755
ClientLeft = 60
ClientTop = 345
ClientWidth = 5985
LinkTopic = "Form1"
ScaleHeight = 4755
ScaleWidth = 5985
StartUpPosition = 3 '窗口缺省
Begin VB.CommandButton Command6
Caption = "Command6"
Height = 495
Left = 1320
TabIndex = 6
Top = 4200
Width = 1215
End
Begin VB.CommandButton Command5
Caption = "Command5"
Height = 495
Left = 120
TabIndex = 5
Top = 4200
Width = 1215
End
Begin VB.CommandButton Command4
Caption = "Command4"
Height = 495
Left = 3720
TabIndex = 4
Top = 3600
Width = 1215
End
Begin VB.PictureBox Picture1
Height = 3255
Left = 2520
Picture = "Form1.frx":0000
ScaleHeight = 3195
ScaleWidth = 3195
TabIndex = 3
Top = 120
Width = 3255
End
Begin VB.CommandButton Command3
Caption = "Command3"
Height = 495
Left = 2520
TabIndex = 2
Top = 3600
Width = 1215
End
Begin VB.CommandButton Command2
Caption = "Command2"
Height = 495
Left = 1320
TabIndex = 1
Top = 3600
Width = 1215
End
Begin VB.CommandButton Command1
Caption = "Command1"
Height = 495
Left = 120
TabIndex = 0
Top = 3600
Width = 1215
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
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 Declare Function BitBlt Lib "gdi32" (ByVal hDestDC 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 dwRop As Long) As Long
'拷贝到窗体
Private Sub Command1_Click()
Dim w As Integer, h As Integer
Me.ScaleMode = vbPixels
w = Picture1.Width
h = Picture1.Height
StretchBlt Me.hdc, 0, 0, w, h, Picture1.hdc, 0, 0, w, h, vbSrcCopy
End Sub
'放大:
Private Sub Command2_Click()
Dim w As Integer, h As Integer
Me.ScaleMode = vbPixels
w = Picture1.Width
h = Picture1.Height
StretchBlt Me.hdc, 0, 0, w * 2, h * 2, Picture1.hdc, 0, 0, w, h, vbSrcCopy
End Sub
'缩小:
Private Sub Command3_Click()
Dim w As Integer, h As Integer
Me.ScaleMode = vbPixels
w = Picture1.Width
h = Picture1.Height
StretchBlt Me.hdc, 0, 0, w / 2, h / 2, Picture1.hdc, 0, 0, w, h, vbSrcCopy
End Sub
'例3: 翻转图片
'左右翻转
Private Sub Command4_Click()
Dim w As Integer, h As Integer
Me.ScaleMode = vbPixels
w = Picture1.Width
h = Picture1.Height
StretchBlt Me.hdc, w, 0, -w, h, Picture1.hdc, 0, 0, w, h, vbSrcCopy
End Sub
'上下翻转
Private Sub Command5_Click()
Dim w As Integer, h As Integer
Me.ScaleMode = vbPixels
w = Picture1.Width
h = Picture1.Height
StretchBlt Me.hdc, 0, 0, w / 2, h / 2, Picture1.hdc, 0, 0, w, h, vbSrcCopy
End Sub
'左右并且上下翻转
Private Sub Command6_Click()
Dim w As Integer, h As Integer
Me.ScaleMode = vbPixels
w = Picture1.Width
h = Picture1.Height
StretchBlt Me.hdc, w, h, -w, -h, Picture1.hdc, 0, 0, w, h, vbSrcCopy
End Sub