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 GetDC Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
Private Declare Function GetDesktopWindow Lib "user32" () As Long
Private Type POINTAPI
x As Long
y As Long
End Type
Const SRCCOPY = &HCC0020
Dim Papi As POINTAPI
Private Sub Timer1_Timer()
GetCursorPos Papi
BitBlt GetDC(picMonitor.hwnd), 0, 0, picMonitor.ScaleWidth, picMonitor.ScaleHeight, GetDC(GetDesktopWindow), (Papi.x - (picMonitor.ScaleWidth / 2)), (Papi.y - (picMonitor.ScaleHeight / 2)), SRCCOPY
End Sub
Все работает, но когда пытаюсь сохранить картинку в файл:
Private Sub picMonitor_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 32 Then
SavePicture picMonitor.Image, App.Path & "\Screen.bmp"
End If
End Sub
сохраняеться просто желтый квадрат :(
ИМХО, дело в последнем параметре BitBlt.
2 Александр, как что нарисовано? GetDC(GetDesktopWindow). Рабочий стол вестимо
2 Ber, SRCCOPY в ApiViewer объявлена точно также как и у тебя, т.ч. с ней все в порядке
Я извеняюсь, мимо просто проходил, у тебя случайно picMonitor.BorderStyle не желтый? Так тогда сам понимаешь? А вообще сохранить Desktop
но уменьшив размеры в разы проще через StretchBlt
Option Explicit
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 hSrcWidth As Long, ByVal nSrcHeight As Long, _
ByVal dwRop As Long) As Long
' **************************
Private Declare Function GetDC Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
Private Declare Function GetDesktopWindow Lib "user32" () As Long
Private Type POINTAPI
X As Long
Y As Long
End Type
Const SRCCOPY = &HCC0020
Dim Papi As POINTAPI
Private Sub Form_Load()
picMonitor.AutoRedraw = True
picMonitor.ScaleMode = 3
End Sub
Private Sub Timer1_Timer()
GetCursorPos Papi
StretchBlt picMonitor.hdc, 0, 0, picMonitor.Width, picMonitor.Height, GetDC(GetDesktopWindow), Papi.X, Papi.Y, picMonitor.Width, picMonitor.Height, SRCCOPY
picMonitor.Refresh
End Sub
Private Sub picMonitor_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 32 Then
SavePicture picMonitor.Image, App.Path & "\Screen.bmp"
End If
End Su