'На форме расположено окно PictureBox с именем pic1, параметр HasDC=True
'Код формы:
Option Explicit
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 GetWindowDC Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function GetDesktopWindow Lib "user32" () As Long
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
'Дескриптор десктопа
Private DC1 As Long
'Дескриптор PictureBox
Private DC2 As Long
'Необходимая константа
Private Const dwRop As Long = &HCC0020
Private Sub Form_Load()
'Получаем дескрипторы десктопа и PictureBox
DC1 = GetWindowDC(GetDesktopWindow)
DC2 = GetWindowDC(pic1.hwnd)
End Sub
Public Sub SaveDC()
Dim ScreenSizeX as Long
Dim ScreenSizeY as Long
ScreenSizeX = Screen.Width / Screen.TwipsPerPixelX
ScreenSizeY = Screen.Height / Screen.TwipsPerPixelY
'Копируем картинку с "устройства" десктопа на "устройство" PictureBox
BitBlt DC2, 0, 0, ScreenSizeX , ScreenSizeY, DC1, 0, 0, dwRop
End Sub
Private Sub pic1_Click()
SaveDC
End Sub
'Если сделать копирование "не по клику", то картинка в PictureBox сотрётся... :-|
Сейчас этот форум просматривают: Google-бот, SemrushBot, Yandex-бот и гости: 49