vb大侠请帮帮忙,vb如何将picture控件中包含的控件保存为图片?谢谢 100
例如在picture控件里有label、textbox、line、shape等的控件,然后把它保存为图片。我在网上找到一段代码,却是保存整个代码(包括窗口那些边框),但我...
例如在picture控件里有label、textbox、line、shape等的控件,然后把它保存为图片。我在网上找到一段代码,却是保存整个代码(包括窗口那些边框),但我只要保存picture里的为图片,谢谢!!!
代码:
ivate Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte, ByVal bScan As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long)
Const theForm = 1
Const theScreen = 0
Private Sub Command1_Click()
Picture1.Visible = False
Picture1.Move 0, 0, Me.Width, Me.Height
Call keybd_event(vbKeySnapshot, theForm, 0, 0) '截取活动的本窗体,若theForm改成theScreen则Copy整个Screen
DoEvents
Picture1.Picture = Clipboard.GetData(vbCFBitmap) 'Picture1.Picture得到剪切板的内容(截取的本窗体)
Clipboard.Clear
PhotoName = "\VB截图.Bmp"
PhotoName1 = App.Path & PhotoName
SavePicture Picture1.Image, PhotoName1
End Sub 展开
代码:
ivate Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte, ByVal bScan As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long)
Const theForm = 1
Const theScreen = 0
Private Sub Command1_Click()
Picture1.Visible = False
Picture1.Move 0, 0, Me.Width, Me.Height
Call keybd_event(vbKeySnapshot, theForm, 0, 0) '截取活动的本窗体,若theForm改成theScreen则Copy整个Screen
DoEvents
Picture1.Picture = Clipboard.GetData(vbCFBitmap) 'Picture1.Picture得到剪切板的内容(截取的本窗体)
Clipboard.Clear
PhotoName = "\VB截图.Bmp"
PhotoName1 = App.Path & PhotoName
SavePicture Picture1.Image, PhotoName1
End Sub 展开
1个回答
2014-11-02 · 知道合伙人软件行家
yfcp
知道合伙人软件行家
向TA提问 私信TA
知道合伙人软件行家
采纳数:1748
获赞数:5545
有多年网站建设相关工作经验。熟悉ASP、ASP.net、VB、JavaScript、HTML等语言和CSS、Ajax等相关技术。
向TA提问 私信TA
关注
展开全部
你好,你可以尝试一下 下面的vb截图代码:可以截取picture2控件的图片:
添加一个picture1,picture2 和一个command1。picture2中你可以任意放控件,都可以成功截取。保存为vb.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 Long
Private Sub Command1_Click()
Picture1.AutoRedraw = True
Picture1.Width = Picture2.Width
Picture1.Height = Picture2.Height
'pictrue1.visible=false
BitBlt Picture1.hDC, 0, 0, Picture2.Width, Picture2.Height, GetDC(Picture2.hwnd), 0, 0, vbSrcCopy '抓屏
Dim sFile As String
sFile = App.Path & "\vb.BMP"
Set Picture1.Picture = Picture1.Image
SavePicture Picture1.Picture, sFile '保存
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询