-
Mar 13th, 2015, 12:25 AM
#1
Thread Starter
PowerPoster
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!
-
Mar 13th, 2015, 12:34 AM
#2
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.
-
Mar 13th, 2015, 12:56 AM
#3
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.
-
Mar 13th, 2015, 01:13 AM
#4
Thread Starter
PowerPoster
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.
-
Mar 13th, 2015, 06:41 AM
#5
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
-
Mar 14th, 2015, 09:54 AM
#6
Thread Starter
PowerPoster
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:
Dim rv As Long '*** get the titlebar image 'Picture2.Visible = False Picture2.Move Picture2.Left, Picture2.Top, Print100Chart.Width, Print100Chart.Height - Print100Chart.ScaleHeight rv = SendMessage(Print100Chart.hwnd, WM_PAINT, Picture2.hDC, 0) rv = SendMessage(Print100Chart.hwnd, WM_PRINT, Picture1.hDC, PRF_CHILDREN Or PRF_CLIENT Or PRF_OWNED Or PRF_NONCLIENT) 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?
-
Mar 14th, 2015, 10:01 AM
#7
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?
-
Mar 14th, 2015, 10:43 AM
#8
Thread Starter
PowerPoster
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?
-
Mar 14th, 2015, 11:22 AM
#9
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
-
Mar 14th, 2015, 06:17 PM
#10
Re: Capture a screenshot of a form and then pasting that screenshot in a smaller picu
Originally Posted by Justin M
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|