Results 1 to 4 of 4

Thread: screenshot NOT from the whole screen or an application window

  1. #1

    Thread Starter
    New Member
    Join Date
    Jul 2000
    Posts
    5
    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

  2. #2
    Fanatic Member
    Join Date
    Apr 2000
    Location
    Whats a location?
    Posts
    516
    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.
    Courgettes.

  3. #3
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649
    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!

  4. #4

    Thread Starter
    New Member
    Join Date
    Jul 2000
    Posts
    5
    thanks for your reply, its working!

    broesel

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width