Option ExplicitPrivate Declare Function TextOut Lib "gdi32" Alias "TextOutA" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, ByVal lpString As String, ByVal nCount As Long) As Long Private Declare Function GetDC Lib "user32" (ByVal hwnd 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 LongPrivate Sub Form_Click() TextOut GetDC(Text1.hwnd), 0, 0, "hello world !", Len("hello world !")
BitBlt Picture1.hdc, 0, 0, Text1.Width, Text1.Height, GetDC(Text1.hwnd), 0, 0, vbSrcCopy SavePicture Picture1.Image, App.Path + "\tmp.bmp" End SubPrivate Sub Form_Load() Picture1.AutoRedraw = True End Sub======================================================================== bitblt 时的图片大小和位置自己控制调整好了
用picture控件的loadpicture方法加载这个图片就行。
Picture1.BackColor = Text1.BackColor
Picture1.Width = Text1.Width
Picture1.Height = Text1.Height
Picture1.Cls
Picture1.AutoRedraw = True
Picture1.Print Text1
SavePicture Picture1.Image, "h:\test.bmp"
Private Declare Function GetDC Lib "user32" (ByVal hwnd 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 LongPrivate Sub Form_Click()
TextOut GetDC(Text1.hwnd), 0, 0, "hello world !", Len("hello world !")
BitBlt Picture1.hdc, 0, 0, Text1.Width, Text1.Height, GetDC(Text1.hwnd), 0, 0, vbSrcCopy SavePicture Picture1.Image, App.Path + "\tmp.bmp"
End SubPrivate Sub Form_Load()
Picture1.AutoRedraw = True
End Sub========================================================================
bitblt 时的图片大小和位置自己控制调整好了