Solved

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

Posted on 2004-10-08
7
201 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
  • 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
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 

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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

762 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now