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 Declare Function GetDC Lib "user32" (ByVal hwnd As Long) As Long Private Declare Function ReleaseDC Lib "user32" (ByVal hwnd As Long, ByVal hdc As Long) As LongPrivate Sub Command1_Click() Dim hdc As Long Dim sw As Integer Dim sh As Integer Picture1.AutoRedraw = True hdc = GetDC(Text1.hwnd) Picture1.Width = Text1.Width Picture1.Height = Text1.Height sw = Text1.Width sh = Text1.Height BitBlt Picture1.hdc, 0, 0, sw, sh, hdc, 0, 0, vbSrcCopy ReleaseDC Text1.hwnd, hdc Picture1.AutoRedraw = False Picture1.Refresh SavePicture Picture1.Image, "c:\a.bmp" End Sub
Private Declare Function GetDC Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function ReleaseDC Lib "user32" (ByVal hwnd As Long, ByVal hdc As Long) As LongPrivate Sub Command1_Click()
Dim hdc As Long
Dim sw As Integer
Dim sh As Integer
Picture1.AutoRedraw = True
hdc = GetDC(Text1.hwnd)
Picture1.Width = Text1.Width
Picture1.Height = Text1.Height
sw = Text1.Width
sh = Text1.Height
BitBlt Picture1.hdc, 0, 0, sw, sh, hdc, 0, 0, vbSrcCopy
ReleaseDC Text1.hwnd, hdc
Picture1.AutoRedraw = False
Picture1.Refresh
SavePicture Picture1.Image, "c:\a.bmp"
End Sub
即BitBlt截取的僅僅是text框,而不是圖片了。請問,是否可以直接從文件中讀文字,接著打印在picture框中?
如何取出你自己看看读写文本的方法