-
hi,
how can i make a screenshot NOT from the whole screen
or an application window? for example i wanna screenshot only a little window at:
point1 x=200,y=200;
point2 x=300,y=200;
point3 x=200,y=300;
point4 x=300,y=300.
Y
|
4 |
3 | . .
2 | . . <- screen to grab
1 |
|------------ X
1 2 3 4 5 ...
does somebody have a clue how i could handle this?
thank you
-broesel
-
An Idea would be to BitBlt it to a PictureBox, and then save the picture.
But I'm not really specialised on this area, so I'll leave it all to the more knowledgeable wombats *ahem* Gurus.
-
Try this.
Start a new standard EXE project and add a CommandButton to the form. Then add the following code:
Code:
Private Declare Function GetDesktopWindow _
Lib "user32" () As Long
Private Declare Function GetDC _
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 Const SRCCOPY = &HCC0020
Private Sub Form_Load()
'You could set these properties at design time if you like
Me.ScaleMode = vbPixels
Me.AutoRedraw = True
End Sub
Private Sub Command1_Click()
Dim hDC&, hWnd&
hWnd = GetDesktopWindow
hDC = GetDC(hWnd)
BitBlt Me.hdc, 0&, 0&, 100&, 100&, hDC, 200&, 200&, SRCCOPY
Me.Refresh
ReleaseDC hWnd, hDC
End Sub
Good luck!
-
thanks for your reply, its working!
broesel