• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 210
  • Last Modified:

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

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
yi02
Asked:
yi02
  • 3
  • 3
1 Solution
 
shaival_trivediCommented:
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
 
jimbobmcgeeCommented:
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
 
yi02Author Commented:
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
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
yi02Author Commented:
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
 
jimbobmcgeeCommented:
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
 
yi02Author Commented:
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
 
jimbobmcgeeCommented:
>> 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

Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now