Solved

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

Posted on 2004-10-08
7
206 Views
Last Modified: 2010-05-02
Hi,

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.

myi
0
Comment
Question by:yi02
[X]
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
7 Comments
 
LVL 2

Expert Comment

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

http://www.vbcode.com/asp/showzip.asp?ZipFile=capbit.zip&theID=165

bye
0
 
LVL 16

Expert Comment

by:jimbobmcgee
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...
0
 

Author Comment

by:yi02
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.

myi

0
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

by:yi02
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,

Ming
0
 
LVL 16

Expert Comment

by:jimbobmcgee
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:

       http://www.zan1011.com/feature_bitmap.htm

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

J.
0
 

Author Comment

by:yi02
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,

myi
0
 
LVL 16

Accepted Solution

by:
jimbobmcgee earned 500 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)

HTH

J.
0

Featured Post

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!

Question has a verified solution.

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

Suggested Solutions

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

740 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