Post: VB.NET Programming Tutorial - SCREENSHOT PROGRAM
03-24-2013, 09:34 PM #1
Specter
Pro Memer
(adsbygoogle = window.adsbygoogle || []).push({}); *** THIS WILL WORK EVEN IF THE USER IS NOT CONNECTED TO THE INTERNET ***

Introduction:

Hey NGU, this is my second tutorial today, the last one being how to do password protected forms. This is the 4th installation of the VB.NET Programming Tutorial series, and in this installation we are going to be making a Screenshot Program (like puush or lightshot but with no cropping before snapshot or auto-upload)

Tutorial: #4 - Advanced Screenshot Program

Required Materials:

~ VB 2010 or 2008

Features:

We are going to be making a program that will be small, compact, not take up too much screen space, that will have an easy to access dropdown menu that can capture, save, and do some other functions.

Video:

[Coming Soon]




First, you're going to create a new WindowsFormApplication, OR a project that is already a WindowsFormApplication. I am going to name mine "NGU Screenshot Tool".

You must login or register to view this content.

Now once you have done this, you may customize the form and such. You should see something similar to this on your screen:

You must login or register to view this content.

I have customized my form, and now I am going to add a Menu Strip. To do this we will use toolbox -> Menu's and Toolbar's -> MenuStrip.

You must login or register to view this content.

Now we are going to add menu items. For the first menu, we are going to put "File". Under this we will put "Capture Screeshot", divider, "Save Screenshot", divider, "About", and "Exit". This should look similar to the picture below:

You must login or register to view this content.

For the second menu, we are going to put "Help". Under this we will put "Help Thread" and "Send Error Report". This should look similar to the picture below:

You must login or register to view this content.

Now we are going to add a picturebox. This is so a picture will display after the user has clicked the "Capture Screenshot" button. Drag a picturebox onto your form from the toolbox, and set its "dock" property to "fill".

You must login or register to view this content.

Now I changed the background colors of the picture box and the menu strip (Just a note for picture reasons).

Now for the coding (Yay).




First we are going to double click on "Capture Screenshot". This will bring the capture screenshot menu strip item up in the code tab. Here is what the "Capture Screenshot" function should look like when it is complete:

You must login or register to view this content.

Here is the code to copy:

    Dim bounds As Rectangle
Dim snapshot As System.Drawing.Bitmap
Dim graphix As Graphics

bounds = Screen.PrimaryScreen.Bounds
snapshot = New System.Drawing.Bitmap(bounds.Width, bounds.Height, System.Drawing.Imaging.PixelFormat.Format32bppArgb)
graphix = Graphics.FromImage(snapshot)
graphix.CopyFromScreen(bounds.X, bounds.Y, 0, 0, bounds.Size, CopyPixelOperation.SourceCopy)
PictureBox1.Image = snapshot


Second we are going to double click on "Save Snapshot". This will bring the save screenshot menu strip item up in the code tab. Here is what the "Save Screenshot" function should look like when it is complete: (Format will be PNG as in my opinion png is the best picture format)

You must login or register to view this content.

Now for the about tab, you can link it to another form and customize it and such, but to save space in the tutorial (and my time) I am just going to use a message box function (For those of you that don't know, "vbCrLf" basically means line down. Kinda like /n in gsc.)

You must login or register to view this content.

For the exit button, its one line of code so I'm not even gonna put a picture, just put the following code:
    me.close


Now for the help tab, I am not going to teach you guys how to do that in this tutorial, but probably in an add-on one in the end, because I am running out of time (Spent over an hour making this thread). Anyways, thats basically it! You now have a fully functioning screenshotting program!

You must login or register to view this content.

You must login or register to view this content.


Have a great day NGU.

The following user thanked Specter for this useful post:

ResistTheJamsha
03-26-2013, 07:36 PM #2
Woah!, Awesome thread bro this is super helpfull! Keep the good work

Copyright © 2024, NextGenUpdate.
All Rights Reserved.

Gray NextGenUpdate Logo