Как снять скриншот с экрана и записать его в bmp, jpg или gif файл?
Пожалуйста с примером.
Спасибо.
Option Explicit
Private Declare Function GetDesktopWindow Lib "user32" () 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 Long
Private Const SRCCOPY = &HCC0020
Private Sub Command1_Click()
Dim hDesk, hDeskDC
hDesk = GetDesktopWindow()
hDeskDC = GetDC(hDesk)
BitBlt picShot.hDC, 0, 0, Width, Height, hDeskDC, 0, 0, SRCCOPY
SavePicture picShot.Image, "C:\PicOut.bmp"
End Sub
Не обязательно, можно у pcShot AutoRedraw=true поставить, и тогда будет не обязательно растягивать его!:wink:Sirik писал(а):
- Код: Выделить всё
Option Explicit
Private Declare Function GetDesktopWindow Lib "user32" () 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 Long
Private Const SRCCOPY = &HCC0020
Private Sub Command1_Click()
Dim hDesk, hDeskDC
hDesk = GetDesktopWindow()
hDeskDC = GetDC(hDesk)
BitBlt picShot.hDC, 0, 0, Width, Height, hDeskDC, 0, 0, SRCCOPY
SavePicture picShot.Image, "C:\PicOut.bmp"
End Sub
Единственное что, надо компонент Picture (picShot) был "застянут" на весь экран
Сейчас этот форум просматривают: нет зарегистрированных пользователей и гости: 114