Results 1 to 15 of 15

Thread: Screencaptures

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jun 2002
    Location
    Far.. far away! (Netherlands)
    Posts
    169

    Screencaptures

    Hi everyone!

    I want to make a screencapture of my program and put it in a picturebox. Is this possible in vb?

    Thanks in advance,

    Shell

  2. #2

    Thread Starter
    Addicted Member
    Join Date
    Jun 2002
    Location
    Far.. far away! (Netherlands)
    Posts
    169
    btw, i want to do it with code offcourse

  3. #3
    Fanatic Member Mushroom Realm's Avatar
    Join Date
    Mar 2002
    Location
    Murrieta, California
    Posts
    650
    VB Code:
    1. Private Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte, ByVal bScan As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long)
    2.  
    3. Private Sub Command1_Click()
    4.     keybd_event vbKeySnapshot, 1, 0&, 0&
    5. End Sub

  4. #4
    Addicted Member Sheppe's Avatar
    Join Date
    Sep 2002
    Location
    Kelowna, BC
    Posts
    245
    Originally posted by Shell
    btw, i want to do it with code offcourse
    It is possible, but it requires the use of the API. Sadly, I don't have the code to do it here. A search at www.codehound.com should turn something up for ya.
    [vbcode]
    On Error Goto Hell
    [/vbcode]
    Sheppe Pharis, MCSD
    Check out http://www.vb-faq.com
    Click here for access to the free Code-Express source code and component sharing network for VB6
    Want a better way to skin your .NET applications? Click here!

  5. #5
    Addicted Member Sheppe's Avatar
    Join Date
    Sep 2002
    Location
    Kelowna, BC
    Posts
    245
    Originally posted by Mushroom Realm
    VB Code:
    1. Private Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte, ByVal bScan As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long)
    2.  
    3. Private Sub Command1_Click()
    4.     keybd_event vbKeySnapshot, 1, 0&, 0&
    5. End Sub
    That will copy it to the clipboard, not place it in a picturebox.
    [vbcode]
    On Error Goto Hell
    [/vbcode]
    Sheppe Pharis, MCSD
    Check out http://www.vb-faq.com
    Click here for access to the free Code-Express source code and component sharing network for VB6
    Want a better way to skin your .NET applications? Click here!

  6. #6

    Thread Starter
    Addicted Member
    Join Date
    Jun 2002
    Location
    Far.. far away! (Netherlands)
    Posts
    169
    Thanks for the adress sheppe, its a good site
    Still looking for a way to do this

    Shell

  7. #7
    Good Ol' Platypus Sastraxi's Avatar
    Join Date
    Jan 2000
    Location
    Ontario, Canada
    Posts
    5,134
    You do know about VB's clipboard object, do you not?
    VB Code:
    1. Picture1.Picture = Clipboard.GetData(2)
    2.     Picture1.Refresh
    Unfortunately Mushroom's code seems to only capture the form.
    All contents of the above post that aren't somebody elses are mine, not the property of some media corporation.
    (Just a heads-up)

  8. #8

    Thread Starter
    Addicted Member
    Join Date
    Jun 2002
    Location
    Far.. far away! (Netherlands)
    Posts
    169
    Yes, i know how tu use the clipboard, but I dont want to use it now because my program allready uses it for some other data

  9. #9
    Addicted Member Sheppe's Avatar
    Join Date
    Sep 2002
    Location
    Kelowna, BC
    Posts
    245
    Originally posted by Sastraxi
    You do know about VB's clipboard object, do you not?
    VB Code:
    1. Picture1.Picture = Clipboard.GetData(2)
    2.     Picture1.Refresh
    Unfortunately Mushroom's code seems to only capture the form.
    I know about it too; I just regard it as a shortcut hack. No offense intended.
    [vbcode]
    On Error Goto Hell
    [/vbcode]
    Sheppe Pharis, MCSD
    Check out http://www.vb-faq.com
    Click here for access to the free Code-Express source code and component sharing network for VB6
    Want a better way to skin your .NET applications? Click here!

  10. #10
    Addicted Member Sheppe's Avatar
    Join Date
    Sep 2002
    Location
    Kelowna, BC
    Posts
    245
    Originally posted by Shell
    Thanks for the adress sheppe, its a good site
    Still looking for a way to do this

    Shell
    Here's a link to a fellow's code that will capture the screen. It will even print it if ya want. It should be enough to get you started.

    http://www.thescarms.com/Downloads/Capture.zip
    [vbcode]
    On Error Goto Hell
    [/vbcode]
    Sheppe Pharis, MCSD
    Check out http://www.vb-faq.com
    Click here for access to the free Code-Express source code and component sharing network for VB6
    Want a better way to skin your .NET applications? Click here!

  11. #11

    Thread Starter
    Addicted Member
    Join Date
    Jun 2002
    Location
    Far.. far away! (Netherlands)
    Posts
    169
    Ah!! Victory!!

    I took a look at the program you posted, and made my own function, behold!!

    Code:
    <script language="vbScript">
    <!--
    Public Function CaptureScreen(lHwnd as long,lDestDC as long,iScreenWidth as integer,iScreenHeight as integer)
    Dim lhDc As Long
    lhDc = GetDC(lHwnd )
    
    BitBlt lDestDC , 0, 0, iScreenWidth , iScreenHeight , lhDc, 0, 0, SRCCOPY
    //-->
    </script>
    Thanks all

  12. #12

    Thread Starter
    Addicted Member
    Join Date
    Jun 2002
    Location
    Far.. far away! (Netherlands)
    Posts
    169
    lol, formatting messed up

  13. #13
    Good Ol' Platypus Sastraxi's Avatar
    Join Date
    Jan 2000
    Location
    Ontario, Canada
    Posts
    5,134
    That's OK Sheppe, just remember, lots of times, the easiest way is sometimes the best.
    All contents of the above post that aren't somebody elses are mine, not the property of some media corporation.
    (Just a heads-up)

  14. #14
    Addicted Member Sheppe's Avatar
    Join Date
    Sep 2002
    Location
    Kelowna, BC
    Posts
    245
    Originally posted by Sastraxi
    That's OK Sheppe, just remember, lots of times, the easiest way is sometimes the best.
    Sometimes, but not always. In this instance, blowing away the user's clipboard contents could be regarded as a problem. True, a simple backup of the contents would solve that, but then you have to wonder what he wants as far as functionality. Does he want to capture the whole form, or a region of the form. Perhaps he wants to capture the entire screen with the form as it is displayed. There are a lot of factors to consider, and with the prolific amount of code on the net, I would say that the easiest, and most efficient way in this case, would be to find a code example on how to do a proper screen capture, as was done.
    [vbcode]
    On Error Goto Hell
    [/vbcode]
    Sheppe Pharis, MCSD
    Check out http://www.vb-faq.com
    Click here for access to the free Code-Express source code and component sharing network for VB6
    Want a better way to skin your .NET applications? Click here!

  15. #15
    Good Ol' Platypus Sastraxi's Avatar
    Join Date
    Jan 2000
    Location
    Ontario, Canada
    Posts
    5,134
    I was merely telling how to capture the clipboard as that's what he asked to do, I'm not condoning it
    All contents of the above post that aren't somebody elses are mine, not the property of some media corporation.
    (Just a heads-up)

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