
正文
vb.net截图后保存,windows 截图 直接保存
提示:扫一扫查出行【扫一扫了解最新限行尾号】
复制提示
vb.net怎样保存图片文件,并且保存的图片名称为当前时间
将PictureBox控件里的图片,保存为文件:
1,文件格式不变化:
PictureBox1.Image.Save("C:\" Format(Now, "HH-mm-ss") ".bmp")
2,文件格式有变化:
PictureBox1.Image.Save("C:\" Format(Now, "HH-mm-ss") ".bmp", System.Drawing.Imaging.ImageFormat.Bmp)
相关问答
Q1: vb.net 2008 如何将指定的窗体截图并保存
INTOUCH自带的就有,打印屏幕的命令
自己写个时间条件运行那命令就可以了
PRINTSCREEN这个命令 具体怎么用 看下帮助
希望我的回答对你有所帮助
如有其他问题,可以继续追问,您的采纳是我前进的动力!
Q2: vb.net 如何保存当前页为图片
提供两个思路
用printscreen,将其保存到文件,再调用outlook发出去,但是您说的超出一屏,就麻烦了;
以下代码保存为文件,引用自MSDN,由于我的SD版本不支持我的outlook,所以暂时无法给发送邮件的例子,请参考吧!
system.Windows.Forms.SendKeys.Send("%{PRTSC}")
If Not System.Windows.Forms.Clipboard.GetDataObject() Is Nothing Then
Dim oDataObj As IDataObject = System.Windows.Forms.Clipboard.GetDataObject()
If oDataObj.GetDataPresent(System.Windows.Forms.DataFormats.Bitmap) Then
Dim oImgObj As System.Drawing.Image = oDataObj.GetData(DataFormats.Bitmap, True)
'To Save as Bitmap
oImgObj.Save("F:\Test.bmp", System.Drawing.Imaging.ImageFormat.Bmp)
'To Save as Jpeg
oImgObj.Save("D:\Test.jpeg", System.Drawing.Imaging.ImageFormat.Jpeg)
'To Save as Gif
oImgObj.Save("d:\Test.gif", System.Drawing.Imaging.ImageFormat.Gif)
End If
End If
2.另外出出报表,再调用outlook发出去,只给出数据性报表,而不一定是窗体本身;
Q3: 如何用vb截屏并保存到指定文件夹
一个非常简单的方法,非模拟按键。 只用一个timer控件,和一个按扭就可以。
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 Declare Function GetActiveWindow Lib "user32" () As Long
Dim a
Private Sub Command1_Click()
Timer1.Enabled = True
End Sub
Private Sub Form_Load()
On Error Resume Next
MkDir "c:\zt" '建文件夹
Me.AutoRedraw = True
End Sub
Private Sub Timer1_Timer()
a = a + 1
If a = 3 Then '三秒后开始抓屏
Me.Hide
BitBlt Me.hDC, 0, 0, Screen.Width, Screen.Height, _
GetDC(GetActiveWindow), 0, 0, vbSrcCopy '抓屏
Me.Show
Dim sFile As String
sFile = "C:\zt\" Format(Now, "yyyymmddhhmmss") ".BMP"
SavePicture Me.Image, sFile '保存Me.hDC
Timer1.Enabled = False
End If
End Sub
Q4: 请问:在vb.net2015中,如何编写截图程序?
Me.Refresh()
Dim memory As Image = New Bitmap(Me.Width, Me.Height)
Dim g As Graphics = Graphics.FromImage(memory)
g.CopyFromScreen(Me.Left, Me.Top, 0, 0, New Size(Me.Width, Me.Height)) '这里是截屏核心代码
Dim FilePath As String = ""
Dim d As New SaveFileDialog
d.Filter = "JPEG图像|*.JPEG"
If d.ShowDialog = Windows.Forms.DialogResult.OK Then
FilePath = d.FileName
If FilePath = "" Then Exit Sub
'If FilePath.Substring(FilePath.Length - 1, 1) "\" Then FilePath = FilePath "\"
Else
Exit Sub
End If
d.Dispose()
memory.Save(FilePath)
MessageBox.Show("图像已经保存到: " FilePath, "截图成功", MessageBoxButtons.OK, MessageBoxIcon.Information)
Q5: VB如何保存本窗体的截图 就像按alt+prtscr 保存窗体截图,但不要用发送按键 求大神解 ⊙
'添加如下声明
Private Declare Function BringWindowToTop Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function GetWindowRect Lib "user32" (ByVal hwnd As Long, lpRect As RECT) As Long
Private Declare Function GetWindowDC Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function ReleaseDC Lib "user32" (ByVal hwnd As Long, ByVal hdc 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 Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
'添加这个函数
Private Sub GetWndPic(Wnd As Long, Pic As PictureBox)
Dim R As RECT, DC As Long
GetWindowRect Wnd, R '获取指定窗口的左上角、右下角位置(以便获取其大小)
DC = GetWindowDC(Wnd) '得到dc
With Pic
.AutoRedraw = True: .BorderStyle = 0
.Parent.ScaleMode = vbPixels
.Move .Left, .Top, R.Right - R.Left, R.Bottom - R.Top '使PictureBox适合大小
BringWindowToTop Wnd '目标窗口提到前面(非置顶)
BitBlt .hdc, 0, 0, .Width, .Height, DC, 0, 0, vbSrcCopy '复制绘图
End With
ReleaseDC Wnd, DC '释放
End Sub
'调用示例(把句柄131454的程序窗口截图放到Picture1中)
GetWndPic 131454, Picture1







