?
Solved

VB6 - Save invisible form1 as image to c:\

Posted on 2011-09-24
7
Medium Priority
?
491 Views
Last Modified: 2012-05-12
hello friends, i am have a invisible form and i am need save this to image, in this have webbrowser, i am need save for display contents in webbrowser as image in c:\
i am tried
Set Picture1.Picture = CaptureForm(Me)
 SavePicture Picture1.Image, "c:\img.bmp"
with no success, i am need save the form and webbrowser as image in invisible.
0
Comment
Question by:kidd12
  • 5
  • 2
7 Comments
 
LVL 11

Expert Comment

by:kbirecki
ID: 36595365
Does it have to be a BMP file?  I haven't tried the first part, but maybe you could automate printing the page to a PDF file, and then use ImageMagick to convert from PDF to BMP.

Or another idea would be to use a web browser control on your form, with the web browser object setting .visible=false, and then print that.  Again, I haven't tried printing a web browser control, but it might be another avenue to try.
0
 

Author Comment

by:kidd12
ID: 36595915
no problem if is pdf, PDF or BMP is good for me. thanks
0
 
LVL 11

Accepted Solution

by:
kbirecki earned 2000 total points
ID: 36598452
OK, I misunderstood at first when you referenced the web browser contorl.  I thought you only wanted to capture the contents of the web browser control.  You want the whole form, so it doesn't really matter that there is (or is not) any particular control on the form, right?

Here's a project that will take a snapshot of the current form to a BMP file.  There are comments in the source code and references to sources for some of the code.  There is also a comment in the form source code to a site with sample code to convert BMP to JPG if you want to compress the file to save space or transmission time.

This sample project captures the current form including all contents to the clipboard, and then saves it to a BMP file in the application folder.
DemoSaveFormToImageFile.zip
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 11

Expert Comment

by:kbirecki
ID: 36598469
I forgot to mention that to do this, the form has to be visible, but you can move it off screen so it is not displayed and then use these concepts to capture it.
0
 
LVL 11

Expert Comment

by:kbirecki
ID: 36598494
Oops, you'll have to do this in reverse.  If you move the form off screen, the capture process will grab some of the desktop instead of the form.  Since your form is already invisible, I'd suggest making it briefly visible during the capture.  At the beginning of the capture process, make your form visible (or bring it on screen), do the capture as shown in the demo project above, then make your form invisible again (or move it off screen).  I think it will go so fast no one will see it.

Let me know how it goes.
0
 
LVL 11

Expert Comment

by:kbirecki
ID: 36598513
Also, I just noticed I left a "Debug.Print Now & " busy"" statement in the btnGo_Click routine.  You'll probably want to comment that out.
0
 

Author Closing Comment

by:kidd12
ID: 36601911
thanks
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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

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…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
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…
Suggested Courses
Course of the Month16 days, 5 hours left to enroll

850 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