dcsimg
Results 1 to 21 of 21

Thread: How do I get a screenshot of an entire Form, not just what is visible in the window ?

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Nov 2013
    Posts
    214

    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.

  2. #2
    PowerPoster Zvoni's Avatar
    Join Date
    Sep 2012
    Location
    To the moon and then left
    Posts
    1,962

    Re: How do I get a screenshot of an entire Form, not just what is visible in the wind

    One System to rule them all, One IDE to find them,
    One Code to bring them all, and to the Framework bind them,
    in the Land of Redmond, where the Windows lie
    ---------------------------------------------------------------------------------
    People call me crazy because i'm jumping out of perfectly fine airplanes.
    ---------------------------------------------------------------------------------
    For health reasons i try to avoid reading unformatted Code

  3. #3
    Member
    Join Date
    Oct 2019
    Posts
    35

    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.

  4. #4
    Member
    Join Date
    Oct 2019
    Posts
    35

    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…)

  5. #5
    PowerPoster
    Join Date
    Dec 2004
    Posts
    24,543

    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 allprintscreen to printer.zip
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  6. #6

    Thread Starter
    Addicted Member
    Join Date
    Nov 2013
    Posts
    214

    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)

  7. #7
    Frenzied Member
    Join Date
    Dec 2008
    Posts
    1,222

    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.

  8. #8

    Thread Starter
    Addicted Member
    Join Date
    Nov 2013
    Posts
    214

    Re: How do I get a screenshot of an entire Form, not just what is visible in the wind

    Quote Originally Posted by Bobbles View Post
    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.

  9. #9
    Frenzied Member
    Join Date
    Dec 2008
    Posts
    1,222

    Re: How do I get a screenshot of an entire Form, not just what is visible in the wind

    Quote Originally Posted by JAAFAR View Post
    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'

  10. #10
    Frenzied Member
    Join Date
    Dec 2008
    Posts
    1,222

    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'
    Last edited by Bobbles; Oct 15th, 2019 at 12:52 AM.

  11. #11
    Frenzied Member
    Join Date
    Feb 2017
    Posts
    1,882

    Re: How do I get a screenshot of an entire Form, not just what is visible in the wind

    Quote Originally Posted by JAAFAR View Post
    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...

  12. #12

    Thread Starter
    Addicted Member
    Join Date
    Nov 2013
    Posts
    214

    Re: How do I get a screenshot of an entire Form, not just what is visible in the wind

    This is what I am referring to :



    Regards.

  13. #13
    Frenzied Member
    Join Date
    Feb 2017
    Posts
    1,882

    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.

  14. #14
    PowerPoster Arnoutdv's Avatar
    Join Date
    Oct 2013
    Posts
    3,605

    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?

  15. #15

    Thread Starter
    Addicted Member
    Join Date
    Nov 2013
    Posts
    214

    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.

  16. #16
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    34,184

    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.
    My usual boring signature: Nothing

  17. #17
    Frenzied Member
    Join Date
    Dec 2008
    Posts
    1,222

    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).

  18. #18

    Thread Starter
    Addicted Member
    Join Date
    Nov 2013
    Posts
    214

    Re: How do I get a screenshot of an entire Form, not just what is visible in the wind

    Quote Originally Posted by Bobbles View Post
    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.
    Last edited by JAAFAR; Oct 15th, 2019 at 11:20 PM.

  19. #19
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    34,184

    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.
    My usual boring signature: Nothing

  20. #20
    PowerPoster Arnoutdv's Avatar
    Join Date
    Oct 2013
    Posts
    3,605

    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.

  21. #21
    Frenzied Member
    Join Date
    Feb 2017
    Posts
    1,882

    Re: How do I get a screenshot of an entire Form, not just what is visible in the wind

    Quote Originally Posted by JAAFAR View Post
    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 View Post
    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.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width