Results 1 to 10 of 10

Thread: Capture a screenshot of a form and then pasting that screenshot in a smaller picutreb

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    May 2006
    Posts
    2,295

    Capture a screenshot of a form and then pasting that screenshot in a smaller picutreb

    Hi there folks! I have seen code examples of using VB to take a screenshot of a partciular form. Would anyone know how I could take that screenshot and put it in a picturebox? The picturebox would be smaller, so the image would need to be resized, so maybe I should use am image box instead?

    Thanks!

  2. #2
    PowerPoster
    Join Date
    Feb 2006
    Posts
    24,482

    Re: Capture a screenshot of a form and then pasting that screenshot in a smaller picu

    Try a search. There are about a dozen alternatives for doing this, several of which were just covered in here again over the past week.

  3. #3
    PowerPoster
    Join Date
    Jan 2008
    Posts
    11,074

    Re: Capture a screenshot of a form and then pasting that screenshot in a smaller picu

    It appears you already know how to do what you ask. After you take the screenshot just reload it back into an image control (which you also have stated) so that the screenshot will be resized


    Anything I post is an example only and is not intended to be the only solution, the total solution nor the final solution to your request nor do I claim that it is. If you find it useful then it is entirely up to you to make whatever changes necessary you feel are adequate for your purposes.

  4. #4

    Thread Starter
    PowerPoster
    Join Date
    May 2006
    Posts
    2,295

    Re: Capture a screenshot of a form and then pasting that screenshot in a smaller picu

    Great stuff. I found a thread with a module. It works great and I use an image. This may seem odd, but is there a way to take a screenshot a form that is not visible. I would like to run the form at start up, but hide it.

  5. #5
    PowerPoster SamOscarBrown's Avatar
    Join Date
    Aug 2012
    Location
    NC, USA
    Posts
    9,145

    Re: Capture a screenshot of a form and then pasting that screenshot in a smaller picu

    Justin...seeing as how you like to search for stuff....Google "Visual Basic 6" Capture Hidden Window (or something similar).

    There are MANY examples of this....
    here is one:

    http://vbcity.com/forums/t/47982.aspx

  6. #6

    Thread Starter
    PowerPoster
    Join Date
    May 2006
    Posts
    2,295

    Re: Capture a screenshot of a form and then pasting that screenshot in a smaller picu

    Awesome.

    I found this snippet that takes an image of a title bar.

    VB Code:
    1. Dim rv As Long
    2.  
    3.   '*** get the titlebar image
    4.   'Picture2.Visible = False
    5.   Picture2.Move Picture2.Left, Picture2.Top, Print100Chart.Width, Print100Chart.Height - Print100Chart.ScaleHeight
    6.   rv = SendMessage(Print100Chart.hwnd, WM_PAINT, Picture2.hDC, 0)
    7.   rv = SendMessage(Print100Chart.hwnd, WM_PRINT, Picture1.hDC, PRF_CHILDREN Or PRF_CLIENT Or PRF_OWNED Or PRF_NONCLIENT)
    8.   Picture2.Picture = Picture2.Image

    IS there something I can add or edit to let me grab a picture of the form itself and all of it? I don't really need the title bar.

    Thanks.

    I played around with it, and got rid of the part where it takes a snapshot of the title bar. But the screenshot it gives me is about as thick as the title bar would be, is there a property that lets me just grab the whole form?

  7. #7
    PowerPoster SamOscarBrown's Avatar
    Join Date
    Aug 2012
    Location
    NC, USA
    Posts
    9,145

    Re: Capture a screenshot of a form and then pasting that screenshot in a smaller picu

    Well, I would imagine it has something to do with your Print100Chart.Height or scaleHeight....

    That one (of many) link I showed doesn't do it for you?

  8. #8

    Thread Starter
    PowerPoster
    Join Date
    May 2006
    Posts
    2,295

    Re: Capture a screenshot of a form and then pasting that screenshot in a smaller picu

    Oh it did. I looked at the bottom of the thread from the link that talked about someone else looking for a hidden form screen shot.

    Thanks for letting me know about the scaleheight.

    So, now I can take a screenshot of the form, that is pretty awesome. The only thing is I am using a picture box per the instructions from the thread I got the code from. So the picturebox resizes itself to fit the size of the form. The image control will resize and stretch. Is there a way to do that with a picturebox so the picturebox stays the same, but the image in it resizes to fit the picture box?


    Edit. I just copied the image from the picturebox to the image box, that does the trick, but would picturebox do it on its own?

  9. #9
    PowerPoster SamOscarBrown's Avatar
    Join Date
    Aug 2012
    Location
    NC, USA
    Posts
    9,145

    Re: Capture a screenshot of a form and then pasting that screenshot in a smaller picu

    Not an expert on PB's, but from what i've read, ..no...unless of course dilettante comes up with an API

  10. #10
    PowerPoster
    Join Date
    Aug 2011
    Location
    B.C., Canada
    Posts
    2,887

    Re: Capture a screenshot of a form and then pasting that screenshot in a smaller picu

    Quote Originally Posted by Justin M View Post
    but would picturebox do it on its own?
    On it's own no, but you can use the .paintpicture function to resize (won't be much code) or use an STDPicture's .Render function.
    No need for API's unless you need to add Anti-Alias or other smoothing functions that is supported by the API

    You could simply stick with the image control and it's stretch property to keep it simple.

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