VB6 - Save invisible form1 as image to c:\

Posted on 2011-09-24
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.
Question by:kidd12
  • 5
  • 2
LVL 11

Expert Comment

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.

Author Comment

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

Accepted Solution

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.
ScreenConnect 6.0 Free Trial

Discover new time-saving features in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI, app configurations and chat acknowledgement to improve customer engagement!

LVL 11

Expert Comment

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.
LVL 11

Expert Comment

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.
LVL 11

Expert Comment

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.

Author Closing Comment

ID: 36601911

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Suggested Solutions

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
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…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

777 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