Results 1 to 17 of 17

Thread: Taking screenshot of object...

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Feb 2005
    Posts
    107

    Unhappy Taking screenshot of object...

    Is there an easy method for taking a screenshot and the saving it automaticall?

    Thanks in advanmce
    Last edited by BefunMunkToloGen; May 6th, 2005 at 09:13 PM.

  2. #2
    PowerPoster RhinoBull's Avatar
    Join Date
    Mar 2004
    Location
    New Amsterdam
    Posts
    24,132

    Re: Taking and saving screenshot.

    Take a look @ this thread .

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Feb 2005
    Posts
    107

    Re: Taking and saving screenshot.

    Is it possible to take a screenshot of just a picture box i have?

  4. #4
    Frenzied Member sciguyryan's Avatar
    Join Date
    Sep 2003
    Location
    Wales
    Posts
    1,763

    Re: Taking and saving screenshot.

    Why would you want to do that...?


    Would you not just be able to "grab the contents" of that pitcure box and use that the same way?

    RyanJ
    My Blog.

    Ryan Jones.

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Feb 2005
    Posts
    107

    Re: Taking and saving screenshot.

    Im creating a client for a game, the game is played inside a picture box. So I want screenshots to be taken of the game not of the entire window.

    Cheers

  6. #6
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: Taking and saving screenshot.

    This should do what you need. Make sure you install and register the .dll before running. I have included instructions on what you need to do.
    Enjoy.

  7. #7
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Taking and saving screenshot.

    How about
    VB Code:
    1. SavePicture Picture1.Image, "c:\test.bmp"

  8. #8

    Thread Starter
    Lively Member
    Join Date
    Feb 2005
    Posts
    107

    Re: Taking and saving screenshot.

    Quote Originally Posted by Hack
    How about
    VB Code:
    1. SavePicture Picture1.Image, "c:\test.bmp"
    That saves the screenshot that's printed into Picture1. The attachment was good, but it still doesn't solve my problem. I'm trying to take a screenshot of a picturebox inside a form, not the whole form.

    Thanks
    Last edited by BefunMunkToloGen; May 4th, 2005 at 07:53 PM.

  9. #9

    Thread Starter
    Lively Member
    Join Date
    Feb 2005
    Posts
    107

    Re: Taking and saving screenshot.

    Right, i've managed to get it to work. However i have to drag this annoying picture to the 'object' to get it to work. How can i set my picture box to it already without having to move the image to get the window shot?

    this might help...
    VB Code:
    1. Private Sub Command1_Click()
    2.  
    3. Dim WndRECT As RECT
    4. GetWindowRect SelWnd, WndRECT
    5. SavePicture hDCToPicture(GetDC(SelWnd), 0, 0, (WndRECT.Right - WndRECT.Left), (WndRECT.Bottom - WndRECT.Top)), App.Path & "\ok.bmp"
    6. Set Image1.Picture = hDCToPicture(GetDC(SelWnd), 0, 0, (WndRECT.Right - WndRECT.Left), (WndRECT.Bottom - WndRECT.Top))
    7. End Sub
    8.  
    9. Private Sub Picture1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    10. Me.MousePointer = 99
    11. Me.MouseIcon = Picture1.Picture
    12. Picture1.Visible = False
    13.  
    14. End Sub
    15.  
    16. Private Sub Picture1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
    17. Dim mousexy As PointAPI
    18. GetCursorPos mousexy
    19. SelWnd = WindowFromPoint(mousexy.X, mousexy.Y)
    20. Me.MousePointer = 0
    21. Picture1.Visible = True
    22.  
    23. End Sub
    24.  
    25. Private Sub Timer1_Timer()
    26. Dim mousexy As PointAPI
    27. GetCursorPos mousexy
    28. label2.Caption = WindowFromPoint(mousexy.X, mousexy.Y)
    29. End Sub

    Or, if you really feel like it, you can see the whole lot from here.

  10. #10
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: Taking and saving screenshot.

    Did you look at the attachment that I posted? It saves to jpeg, also.

  11. #11

    Thread Starter
    Lively Member
    Join Date
    Feb 2005
    Posts
    107

    Re: Taking and saving screenshot.

    Yeah very helpful. I've sorted the saving out . Now i'm trying to take a screenshot of an object (picturebox).
    Last edited by BefunMunkToloGen; May 5th, 2005 at 02:37 AM.

  12. #12

    Thread Starter
    Lively Member
    Join Date
    Feb 2005
    Posts
    107

    Re: Taking and saving screenshot.

    If you have a look at http://vtforce.com/cruel/window_bitblt.zip , it shows how to drag this picture to an object to take a screenshot of. I want to do this but I dont want to have to use the picture to find the object. I want a command button to automatically take a screenshot of the object. Sorry it's hard to explain.

  13. #13

    Thread Starter
    Lively Member
    Join Date
    Feb 2005
    Posts
    107

    Re: Taking and saving screenshot.

    This is unsolved , please help...

  14. #14
    Fanatic Member
    Join Date
    Mar 2002
    Location
    AUSTRALIA
    Posts
    603

    Re: Taking screenshot of object...

    This is unsolved , please help...

    Sorry it's hard to explain
    Surely you could explain what you want.

    Imagine I offered you the services of the best programmer in the world.
    He now lives in a cave in Tibet (portable generator).
    He has no phone and no Internet.
    I visit him once a year.
    If you can type up your spec, I will take it to him, and I will return with the completed project.
    If he misunderstands your spec, I can take the amendments/corrections/clarification with me 12 months later on my next visit.

    Go on, have a wee go at explaining what you want.
    Rob C

  15. #15

    Thread Starter
    Lively Member
    Join Date
    Feb 2005
    Posts
    107

    Re: Taking screenshot of object...

    Right, I can understand as the subject has sightly changed. I will try to explain in as much detail as possible.

    I am trying to take a screenshot of an object within my form. The object is a picture box. I have some code that does this, however you have to move a picture (looks like a crosshairover) the object like below:



    So, i am trying to get a screenshot of the picture box (that has a web browser inside) without moving the crosshair image over.

    Heres some of the code:
    VB Code:
    1. Private Declare Function GetPixel Lib "gdi32" (ByVal hdc As Long, ByVal X As Long, ByVal Y As Long) As Long
    2. Private Declare Function WindowFromPoint Lib "user32" (ByVal xPoint As Long, ByVal yPoint As Long) As Long
    3. Private Declare Function GetCursorPos Lib "user32" (lpPoint As PointAPI) As Long
    4. Private Declare Function GetWindowRect Lib "user32" (ByVal hWnd As Long, lpRect As RECT) As Long
    5. Private Type RECT
    6.     Left As Long
    7.     Top As Long
    8.     Right As Long
    9.     Bottom As Long
    10. End Type
    11. Private Type PointAPI
    12.     X As Long
    13.     Y As Long
    14. End Type
    15. Dim SelWnd As Long
    16.  
    17.  
    18. Private Sub Command1_Click()
    19.  
    20. Dim WndRECT As RECT
    21. GetWindowRect SelWnd, WndRECT
    22. SavePicture hDCToPicture(GetDC(SelWnd), 0, 0, (WndRECT.Right - WndRECT.Left), (WndRECT.Bottom - WndRECT.Top)), App.Path & "\ok.bmp"
    23. Set Image1.Picture = hDCToPicture(GetDC(SelWnd), 0, 0, (WndRECT.Right - WndRECT.Left), (WndRECT.Bottom - WndRECT.Top))
    24. End Sub
    25.  
    26. Private Sub Picture1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    27. Me.MousePointer = 99
    28. Me.MouseIcon = Picture1.Picture
    29. Picture1.Visible = False
    30.  
    31. End Sub
    32.  
    33. Private Sub Picture1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
    34. Dim mousexy As PointAPI
    35. GetCursorPos mousexy
    36. SelWnd = WindowFromPoint(mousexy.X, mousexy.Y)
    37. Me.MousePointer = 0
    38. Picture1.Visible = True
    39.  
    40. End Sub
    41.  
    42. Private Sub Timer1_Timer()
    43. Dim mousexy As PointAPI
    44. GetCursorPos mousexy
    45. label2.Caption = WindowFromPoint(mousexy.X, mousexy.Y)
    46. End Sub
    47.  
    48. Private Sub form_load()
    49. WebBrowser1.Navigate ("http://www.runescape.com")
    50. End Sub

    For the whole code take a look at this:

    http://vtforce.com/cruel/window_bitblt.zip

    Thanks! Hope that clears a few things up...

  16. #16
    Fanatic Member
    Join Date
    Mar 2002
    Location
    AUSTRALIA
    Posts
    603

    Re: Taking screenshot of object...

    Hi,
    Thanks for explaining more.
    The attachment is the same one you posted before, I think ?
    I could not work out how to use either of them.
    I click the button.
    I click and drag the mouse, and let go.
    I see the rectangle whilst doing that
    What am i supposed to do next.
    I'm attaching screen shot of the latest zip, in case you attached the wrong one.
    Attached Images Attached Images  
    Rob C

  17. #17
    New Member
    Join Date
    May 2005
    Posts
    7

    Re: Taking screenshot of object...

    The function uses the window handle to retrieve picture content. So you must provide the correct window handle to be able to take the screenshot. If you don't want to have to drag the crosshairs then you'll have to use a series of FindWindow and FindWindowEx api calls.
    Luckily if you're just wanting a screenshot of a picture box, then you can just use Picture1.hWnd

    That being said, here's the revised button event:
    Code:
    Private Sub Command1_Click()
    Dim WndRECT As RECT
    GetWindowRect Picture2.hwnd, WndRECT
    SavePicture hDCToPicture(GetDC(Picture2.hwnd), 0, 0, (WndRECT.Right - WndRECT.Left), (WndRECT.Bottom - WndRECT.Top)), App.Path & "\ok.bmp"
    End Sub
    I tested and it should work. If not, post the problem.
    Last edited by Cruel__Machine; May 8th, 2005 at 03:29 PM.

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