does anyone here know how to save a visual basic form in any file format such a jpeg??? im currently working on a program wherein i can view an image + i can add labels and save it in jpeg format. pls help. urgently needed... tnx in advance...

how to save a visual basic form in any file format such a jpeg?

A Visual Basic Form is not a picture form. It's a container for other objects.

In that sense, you can save the form with the picture on it.

There are other contols that you can use on the form to hold the picture: the PictureBox, and the Image control. You have more options with the PictureBox control

But you can set the picture property in the Property View and select a picture to be used on your form. Any controls dropped on the form will cover the picture.

Hi,

I previously had a function that gets a screen shot but i can't finf it any more. Look on the internet for a function that perform "Print Screen" and then a function to crop that picture.

Using the Win32 API, you need to:

1. CreateCompatibleDC to create a DC compatible with your window's DC
2. CreateCompatibleBitmap with the appropriate dimensions
3. SelectObject to select the window into the bitmap
4. BitBlt the window into the bitmap
5. Save the bitmap as Jpeg

Hope this helps.

how to save a visual basic form in any file format such a jpeg??

Okay, I'm confused. What do you really want to do: (1) take a screenshot of your form and save it in jpeg?, or (2) save an image to be used on your form?

I'll assume that what is required is the ability to load a picture into the form, put labels on it, and save it again. To do so one would load the picture into the form (or picturebox) use the Print Method along with the currentX or CurrentY properties, and then do a SavePicture() back to a Jpeg.

Fascinating question. Assume you have good reason for it. Either you're wanting to display a form and it's specific content as a picture such as in a help display or a tutorial which is ultra easy and outlined above or you want to save a form in Jpeg format as you stated, which, simply put is a yes, but pointless since the form will not be reusable. The other possibility is super sophisticated and implies you want to smuggle forms out in Jpeg files where the form content is not displayed but hidden in the unused portions of the Jpeg file. That is called steganography and there are multiple sources available for that technology.
So which door is it, 1, 2 or 3?

Solution:-

Dim dlg as New SaveFileDialogue
dlg.Tittle = "Save"
dlg.FileName = ""
dlg.Filter = "All Files (*.*)|*.*|PNG Files (*.png)|*.png|Jpeg Files (*.jpg)|*.jpg"
If dlg.ShowDialogue = DialogueResult.OK Then
If dlg.ShowDialog = DialogResult.OK Then
PictureBox1.Image.Save(dlg.FileName, System.Drawing.Imaging.ImageFormat.Png)
End If

Edited 4 Years Ago by deepakx250: n/a

This article has been dead for over six months. Start a new discussion instead.