Results 1 to 9 of 9

Thread: Capturing Desktop and saving to a file

  1. #1

    Thread Starter
    Fanatic Member 007shahid's Avatar
    Join Date
    Feb 2001
    Posts
    562

    Unhappy

    I want to capture the desktop including all the icons and save it to a file. VB World has an example, but it gives me an error... stack overflow!. HELP!!!

  2. #2
    Fanatic Member PsychoMark's Avatar
    Join Date
    Feb 2001
    Location
    Netherlands
    Posts
    540
    Code:
    Declare Function BitBlt Lib "gdi32" _
    (ByVal hDestDC As Integer, ByVal x As Integer, _
    ByVal y As Integer, ByVal nWidth As Integer, _
    ByVal nHeight As Integer, ByVal _
    hSrcDC As Integer, ByVal xSrc As Integer, _
    ByVal ySrc As Integer, ByVal dwRop As _
    Long) As Integer
    
    Declare Function GetDesktopWindow Lib "user32" () As Long
    
    Declare Function GetDC Lib "user32" _
    (ByVal hwnd As Long) As Long
    
    Sub Grabscreen(Dest As PictureBox)
        Dim DeskhWnd As Long, DeskDC As Long
    
        'Get the hWnd of the desktop
        DeskhWnd = GetDesktopWindow()
    
        'BitBlt needs the DC to copy the image. So, we
        'need the GetDC API.
        DeskDC = GetDC(DeskhWnd)
    
        Dest.AutoRedraw = True
        BitBlt Dest.hDC, 0, 0, _
        Screen.Width / Screen.TwipsPerPixelX, Screen.Height / Screen.TwipsPerPixelY, DeskDC, _
        0, 0, vbSrcCopy
        Dest.Refresh
    End Sub
    Teaudirenopossum.Musasapientumfixaestinaure.
    (I can't hear you. There's a banana in my ear)

  3. #3

    Thread Starter
    Fanatic Member 007shahid's Avatar
    Join Date
    Feb 2001
    Posts
    562

    Unhappy No Luck

    Thanks 4 trying to help, but I still get stack overflow error both in 640*480 pxl and 800*600 pxl!

  4. #4
    Fanatic Member PsychoMark's Avatar
    Join Date
    Feb 2001
    Location
    Netherlands
    Posts
    540
    That's weird, are you getting the error in the BitBlt line? (that's the only possibility I guess)...
    Teaudirenopossum.Musasapientumfixaestinaure.
    (I can't hear you. There's a banana in my ear)

  5. #5
    PowerPoster Fox's Avatar
    Join Date
    Jan 2000
    Location
    *afk*
    Posts
    2,088
    Try my Screenshot demo...

  6. #6

    Thread Starter
    Fanatic Member 007shahid's Avatar
    Join Date
    Feb 2001
    Posts
    562

    Question BitBlt

    Yes, u r right. Even in the example in the VB-World Graphics section, I am getting the same error

    Error: Stack overflow!

    If I get things right, I'll post a reply

  7. #7
    PowerPoster Fox's Avatar
    Join Date
    Jan 2000
    Location
    *afk*
    Posts
    2,088
    weird... whats your graphics card?

  8. #8

    Thread Starter
    Fanatic Member 007shahid's Avatar
    Join Date
    Feb 2001
    Posts
    562

    Talking Got it

    I got it. I tried the project from screenshot.zip from FOX's website. The only difference was he captured it to a Picture Box. Maybe thats where I got the error

  9. #9
    PowerPoster Fox's Avatar
    Join Date
    Jan 2000
    Location
    *afk*
    Posts
    2,088
    My demos are proofed

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