首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > VB >

利用VB怎么将picturebox中的内容保存成一张图片

2012-01-18 
利用VB如何将picturebox中的内容保存成一张图片?picturebox中的内容包括图片、Label、自己画的线等等,怎样能

利用VB如何将picturebox中的内容保存成一张图片?
picturebox中的内容包括图片、Label、自己画的线等等,怎样能把这些内容统统保存成一张图片?

[解决办法]
VB.SavePicture Picture1.Image, "E:\pic.jpg "
[解决办法]
给你段参考代码

转自 龙卷风

Private Declare Function GetDC Lib "user32 " (ByVal hwnd As Long) As Long
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 Sub Command1_Click()
Dim wScreen As Long
Dim hScreen As Long
Dim w As Long
Dim h As Long
Dim pic As PictureBox
Picture1.Cls
Picture1.AutoRedraw = True
wScreen = Screen.Width \ Screen.TwipsPerPixelX
hScreen = Screen.Height \ Screen.TwipsPerPixelY
Picture1.ScaleMode = vbPixels
w = Picture1.ScaleWidth
h = Picture1.ScaleHeight
hdcScreen = GetDC(0)
p = StretchBlt(Picture1.hdc, 0, 0, w, h, hdcScreen, 0, 0, wScreen, hScreen, vbSrcCopy)
Picture1.Refresh

End Sub

Private Sub Command2_Click()
SavePicture Picture1.Image, "c:\111.bmp "
End Sub

[解决办法]
用BitBlt或StretchBlt截图,再保存
[解决办法]
将PictureBox中的图形与控件一起保存为BMP图:
http://www.china-askpro.com/msg2/qa05.shtml
[解决办法]
bitblt,参考api手册

热点排行