-
How do I get a screenshot of an entire Form, not just what is visible in the window ?
Hi,
I have a scrollable form whose client area is longer than the screen height.
Is it possible to get a snapshot of the the entire client area ?
I have used PrintWindow as well as BitBlt but these APIs only grab the visible portion.
I could temporarly zoom down the Form and then use StretchBit but that results in a very bad image quality.
Any ideas ?
Regards.
-
Re: How do I get a screenshot of an entire Form, not just what is visible in the wind
-
Re: How do I get a screenshot of an entire Form, not just what is visible in the wind
hi,
You had to create a new ghost form and add a blank control in it.
Copy all values from the fix control to the ghosted one, and set his width to display all values.
Set the ghosted form to the Inside control, and get the mirrored control picture, and save it.
-
Re: How do I get a screenshot of an entire Form, not just what is visible in the wind
Hi,
Example to mirror a fix ListView in a form to another form:
http://dl.free.fr/f5dJXcQpI
In this demo, the form height capture is hang to 788 pixels (max height for a form/screen)
You had to split datas, or use another stuff to capture your datas… picturebox, printer form…)
-
1 Attachment(s)
Re: How do I get a screenshot of an entire Form, not just what is visible in the wind
microsoft had a vb sample for printing different screen areas, but i believe the link is now gone
i will attach the original download, you can see if it helps at allAttachment 171587
-
Re: How do I get a screenshot of an entire Form, not just what is visible in the wind
Thanks everyone for answering.
@Zvoni
Tried subclassing the form and intercepting the WM_PAINT and WM_PRINTCLIENT as per this article but no joy. The screen grab I get is only the visible portion of the form's client area.
@XavSnap
The liink is not working.
@westconn1
No joy, it only captures the visible section of the client's area... The region that is towards the scrollable bottom is not captured even when increasing the height in the call to the CreateCompatibleBitmap API.
What I have seen so far seems to address the issue when the form's main window is obscured by another window or is partly off-screen but none of the solutions I have seen so far seem to address the issue when the client area is larger than the form's inside height\width. (ie: when the form requires scrollbars to bring into view the entire contents of the client area)
-
Re: How do I get a screenshot of an entire Form, not just what is visible in the wind
Could you attach your project (for 2 reasons) -
1) I have tried to make a form bigger than the screen in the past, and have never succeeded. Thus I am curious as to how you did that.
2) We can experiment with your project, and see if we can solve your problem.
-
Re: How do I get a screenshot of an entire Form, not just what is visible in the wind
Quote:
Originally Posted by
Bobbles
Could you attach your project (for 2 reasons) -
1) I have tried to make a form bigger than the screen in the past, and have never succeeded. Thus I am curious as to how you did that.
2) We can experiment with your project, and see if we can solve your problem.
The form is not bigger than the screen. The client area of the form is the one that is bigger that's why the form requires a scrollbar to navigate its contents.
-
Re: How do I get a screenshot of an entire Form, not just what is visible in the wind
Quote:
Originally Posted by
JAAFAR
The form is not bigger than the screen. The client area of the form is the one that is bigger that's why the form requires a scrollbar to navigate its contents.
I am not grasping what you mean with 'The client area of the form is the one that is bigger'
-
Re: How do I get a screenshot of an entire Form, not just what is visible in the wind
I have a project which uses the free SGrid 2
When the data selected (nu of columns, and the nu of records) is such that the user has to use (SGrid 2) scrollbars to see the extra columns Or the extra rows.
Is that what you mean by 'the client area' ?
Rob
PS I previously mastered the ability to create a JPG of the whole grid contents, which can be wider and longer than Texas
PPS If I am correct, then perhaps your OP should not have described it as 'a scrollable form'
-
Re: How do I get a screenshot of an entire Form, not just what is visible in the wind
Quote:
Originally Posted by
JAAFAR
The form is not bigger than the screen. The client area of the form is the one that is bigger that's why the form requires a scrollbar to navigate its contents.
Unless you made something special, the standard VB6 Forms don't have the client area bigger than the form itself. Only the MDI parent forms can do that (normally).
Perhaps if you could post a sample project of this issue...
-
Re: How do I get a screenshot of an entire Form, not just what is visible in the wind
-
Re: How do I get a screenshot of an entire Form, not just what is visible in the wind
What I said: VB6 forms don't do that (they are not scrollable).
We don't know what you are using.
-
Re: How do I get a screenshot of an entire Form, not just what is visible in the wind
@JAAFAR: Which component or what kind of user control do you use?
-
Re: How do I get a screenshot of an entire Form, not just what is visible in the wind
Sorry guys for the confusion ... I am actually using an office form .
Regardless of the type of form, we are dealing here with a scrollable window whose client area length exceeds the height of the main window and I just need to be able to get a screen capture of the entire client area via code.
I thought maybe there would be some API workaround to achieve what seems something that should be doable.
I have used some hackish trickery to achieve what I want by scrolling the form one line at a time and BitBliting to a temporary memory DC then placing the resulting bitmap in the clipboard.
I was hoping to find a more elegant solution without the need to scroll the form and I am still interested to see if it can be done.
In case anybody is interested, here is a working DEMO WORKBOOK.
Regards.
-
Re: How do I get a screenshot of an entire Form, not just what is visible in the wind
Office VBA is VERY similar to VB6, but it isn't the same thing.
I doubt that this can be done. It you think of the whole client area as some large surface much larger than the form, with the window being just a rectangular hole that you can move around over the form, then it would make sense that there is some method that would capture that whole client area rather than just what is visible through the hole. That's not the case, though. The part that isn't displayed isn't rendered, so there is no bitmap that can be copied anywhere. After all, the cost of rendering is much higher than the cost of clipping to the area of the form, so rendering what can't be seen is an expensive waste.
Scrollbars are essentially just tricks. Without scrollbars, the window is rendering from 0,0 to the size of the window. The scrollbar is just adding integers to that 0,0 such that the start point is different. The parts outside the window might as well not exist, as far as the graphics are concerned. So, some kind of "hackish" solution is going to have to happen.
-
Re: How do I get a screenshot of an entire Form, not just what is visible in the wind
You have wasted a lot of people's time, by asking vague question with no attempt to provide full details of what you were doing.
And repeatedly ignoring requests to provide such details (and an example).
-
Re: How do I get a screenshot of an entire Form, not just what is visible in the wind
Quote:
Originally Posted by
Bobbles
You have wasted a lot of people's time, by asking vague question with no attempt to provide full details of what you were doing.
And repeatedly ignoring requests to provide such details (and an example).
Sorry for any inconvinience caused... I thought there would be a generic solution that could be applied to windows regardless of the envirenment they were in and thought that posting a specific example would only confuse and complicate things further.
Again, my apologies to everyone.
-
Re: How do I get a screenshot of an entire Form, not just what is visible in the wind
Frankly, I think you are right in that assumption. The specific problem is not really related to the language, because any form that can show controls can have this question asked of it. Whether or not there is a specific question IS dependent on the language, as I'm not aware of any language that doesn't implement some form of clipping. So, it may be that one language has a means to render to a bitmap those parts of the display that are not visible, while another language does not. I know of no such feature in .NET, and others clearly know of no such feature in VB6. If there is such a feature in VBA...well, it's unlikely, but I don't know VBA well enough to say (or VB6, for that matter).
Still, while the terminology is unsettled, it became clear enough early on what it was you wanted to do, so I think the criticism of the question is unfounded. Perhaps there is some accepted terminology for the part of the display area not in the visible frame, but I don't know what it is, either.
-
Re: How do I get a screenshot of an entire Form, not just what is visible in the wind
To cut it short, VB6 doesn't have a scrollable view port on a form, hence the questions what kind of (viewport) control was used.
Maybe VBA both and .Net forms do have this functionality and is getting the complete content of the non-visible easy peasy.
-
Re: How do I get a screenshot of an entire Form, not just what is visible in the wind
Quote:
Originally Posted by
JAAFAR
I have used some hackish trickery to achieve what I want by scrolling the form one line at a time and BitBliting to a temporary memory DC then placing the resulting bitmap in the clipboard.
That is probably the way to do it.
Quote:
Originally Posted by
Shaggy Hiker
The part that isn't displayed isn't rendered, so there is no bitmap that can be copied anywhere. After all, the cost of rendering is much higher than the cost of clipping to the area of the form, so rendering what can't be seen is an expensive waste.
That is also my guess of how this works.