How to capture a form's image? The form is a child form of MDI form

Posted on 2004-10-08
Medium Priority
Last Modified: 2010-05-02

I have troubles to capture a form's image (the form got all kinds of controls on it, e.g. textbox, line, shapes etc). I need capture the image of the form (how it looks like) and save it into a BMP file or JPEG file. Another hurdle is this form is a child form of a MDI form. The MDI form got menu on it. I want to capture the child form's whole image even though I can only see a part of the form.

I tried to use CaptureForm(frm1) to do it. The problem I encountered is since the function can only capture the part of the form which can be seen from the screen (the MDI Form cover other part of the form). So I have to copy all the controls to another form, then display the form as full-screen image and capture its image at that point, which is kind of dumb.

Wish some smart sample code from you!

Thanks a lot for your help.

Question by:yi02
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3

Expert Comment

ID: 12265872
download bellow zip file. it will give you all of u want


LVL 16

Expert Comment

ID: 12285741
You could always use Form1.PrintForm to print the entire form.  If you have a PDF printer (such as Acrobat Distiller, or CutePDF), you can print to this printer object.

Not a perfect solution, but a simple one...

Author Comment

ID: 12292373
Hi, Dear Shaival:

Thanks a lot for your suggestion. Indeed I knew something like that as I described in my question. the program from the site you suggested, still can not solve my problem.

Use a practical example to describe my problem: image a workbook opened and displayed within the microsoft Excel program, What I tried to do is to capture the image of this opened workbook even I can not see all the parts of this workbook ( part of it is being hided within the main Excel program window). My problem is very much like this:  I try to save or print the image of a child form of MDI form, which embedded inside the MDI form, even though we can not see all the parts of it.

The program you suggested only captures whatever can be seen in the active window or whole screen. If some parts are hiden and are not able to be seen, they still can not be captured.  I already figure out a way, although it is a clumsy one to deal with it. First I copy all the controls of the child form that I attempt to capture the image to a different form, which is not the child form of the MDI form, then make it full screen and then capture the image at that point. Now, I am looking for a better solution than that. Could you still help me out? Or somebody else?

Thanks a lot.


Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!


Author Comment

ID: 12292430
Dear jimbobmcgee:

Thanks for your comments. My problem seems more demanding than this solution. Could you please offer a better one? I really need help for this problem.

Best regards,

LVL 16

Expert Comment

ID: 12296466
I feel the problem lies with the way a screen is captured.  Take, for example, the clipboard; it is my understanding that, when you choose to copy a window (with Alt+PrtSrc), it actually takes the top, left, width and height of the window and copies the entire screen within that rectangle to the clipboard.  If there is another window in front of it, that too will be within the rectangle and will be copied also.

If it is not viable for you to move/resize/zorder your form before doing a screen grab, I reckon some sort of print method may be your only option.  A brief Google search found a number of Print-to-Bitmap drivers, such as:


If you had this, you could set your default printer to this, run Form1.Printform and reset the default printer back to what it was.

I hope this helps at least a little bit


Author Comment

ID: 12303224
Dear jimbobmcgee:

Thanks for your comments and suggestions.

I am not sure I completely understand what you suggested. What if my code is compiled and installed in another computer, that computer also needs to install the printer driver you suggested?

I can not believe that nobody can come up with a better solution. Think about how Microsoft Powerpoint prints a file with multiple slides, which do not have to be seen on the screen and appears to be so easy......

I will wait a little bit more. If I can not get a better solution, I will give you the points. Appreciated a lot.

Best regards,

LVL 16

Accepted Solution

jimbobmcgee earned 2000 total points
ID: 12308145
>> What if my code is compiled and installed in another computer, that computer also needs to install the printer driver you suggested?

Unfortunately so.

>> Think about how Microsoft Powerpoint prints a file with multiple slides

Powerpoint prints its own files, which are stored in memory.  It can interpret and handle all the objects in all the slides in this file because a team of Microsoft developers wrote a print/export routine for each and every possible object Powerpoint could handle.

As I see it, you have a number of options for your forms:

1.  Install a print-to-bitmap driver and call the PrintForm method for each form (requires third-party software)

2.  Make the form you want to be a bitmap visible and size it so it fits on the screen, before running the routines suggested by
     shaival_trivedi (requires reformatting of the form)

3.  Write routines for every control on your form, translating what you see on screen to what you see in a bitmap, then iterate
     through all the controls on the form (requires lots of work)



Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses
Course of the Month11 days, 5 hours left to enroll

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question