Solved

VB6 - Save invisible form1 as image to c:\

Posted on 2011-09-24
7
429 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 500 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
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 
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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

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…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
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…

705 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

15 Experts available now in Live!

Get 1:1 Help Now