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 Const SRCCOPY = &HCC0020
Private WithEvents pic1 As PictureBox
Sub Form_Load()
Me.Move 0, 0, 11000, 8500
Set pic1 = Controls.Add("vb.picturebox", "pic1", Me)
With pic1
.Visible = True
.Move 3600, 2700, 3600, 2700
.ScaleMode = 3
.Appearance = 0
.BackColor = Me.BackColor
.CurrentX = 0
.CurrentY = 0
.FontSize = 60
.ForeColor = vbBlue
.FontName = "隶书"
End With
End Sub
Sub Form_Click()
Dim w As Integer, h As Integer
pic1.Print "人之初" & vbCrLf & "性本善"
w = pic1.ScaleWidth
h = pic1.ScaleHeight
StretchBlt Me.hdc, w, h, -w, h, pic1.hdc, 0, 0, w, h, SRCCOPY
StretchBlt Me.hdc, 3 * w, h, -w, h, pic1.hdc, 0, 0, w, h, SRCCOPY
StretchBlt Me.hdc, w, h, w, -h, pic1.hdc, 0, 0, w, h, SRCCOPY
StretchBlt Me.hdc, w, 3 * h, w, -h, pic1.hdc, 0, 0, w, h, SRCCOPY
End Sub
效果如下:
博客展示了一段VB代码,包含对StretchBlt函数的声明和常量定义,在Form_Load事件中设置窗体和图片框属性,在Form_Click事件里打印文字并使用StretchBlt函数进行绘图操作,呈现特定效果。
2256

被折叠的 条评论
为什么被折叠?



