Login Register






HOW TO MAKE A SCREEN CAPTURER IN VB.NET filter_list
Author
Message
HOW TO MAKE A SCREEN CAPTURER IN VB.NET #1
TODAY I WILL BE TEACHING YOU ON HOW TO MAKE YOUR OWN SCREEN CAPTURER FOR FUTURE USE IN VB.NET
LETS START:

FIRST OF ALL SET UP A FORM:
1 PICTUREBOX
3 BUTTONS
1 SAVEFILEDIALOG

SET UP THE FORM AS IN BELOW:
[Image: easy.png]

FOR THE FORM: !
1)DISABLE MAXIMIZE ABILITY IN IT PROPERTIES.


OK NOW LETS CODING

CLICK THE "CAPTURE SCREEN" BUTTON AND ENTER THIS CODE:
Code:
Opacity = 0 Dim Bounds As Rectangle Dim Capture As System.Drawing.Bitmap Dim Graph As Graphics Bounds = Screen.PrimaryScreen.Bounds Capture = New System.Drawing.Bitmap(Bounds.Width, Bounds.Height, System.Drawing.Imaging.PixelFormat.Format32bppPArgb) Graph = Graphics.FromImage(Capture) Graph.CopyFromScreen(Bounds.X, Bounds.Y, 0, 0, Bounds.Size, CopyPixelOperation.SourceCopy) PictureBox1.Image = Capture Opacity = 100

NOW CLICK THE "SAVE" BUTTON AND ENTER THIS CODE:
Code:
Dim pic As Image SaveFileDialog1.DefaultExt = "*.bmp" SaveFileDialog1.Filter = "Bmp Files|*.bmp" pic = PictureBox1.Image SaveFileDialog1.ShowDialog() On Error Resume Next pic.Save(SaveFileDialog1.FileName)

NOW CLICK THE "EXIT" BUTTON AND ENTER THIS CODE:
Code:
END
NOW YOU HAVE YOUR OWN SCREEN CAPTURER.ENJOYS:rofl::rofl:
[Image: 7146de.png]

Reply

RE: HOW TO MAKE A SCREEN CAPTURER IN VB.NET #2
Sorry, you didn't teach anything at all. You just gave the code to copy and paste.
There aren't even comments in the code, and it's too sloppy.
You look like in a hurry.

I'll point out some stuff:-

  1. You are declaring a Bitmap and a Graphics again and again. Just declare them globally and create a new instance in form load.
  2. Your variable names and component names should be meaningful, else you'll be lost in a big code. As you don't even comment the code.
  3. Opacity doesn't even go beyond 1, its range is 0 to 1. So 50% opacity is 0.5 and not 50.
  4. DefaultExt has no meaning here. Since there is only one option to choose in the SaveFileDialogBox
  5. On Error Resume Next has NO PURPOSE here. It's a VB6 thing, and you should never use it anyways. If it's really important use Try.. Catch. But that too is not required in a SaveFileDialogBox. Instead use:-
    Code:
    If SaveFileDialog1.ShowDialog() = 1 Then '1 implies DialogResult.Ok 'Do whatever End If
  6. Do not save as BMP, they are huge. Choose JPEG. For this just do:-
    Code:
    pic.Save(Location, Imaging.ImageFormat.Jpeg)
[Image: rytwG00.png]
Redcat Revolution!

Reply

RE: HOW TO MAKE A SCREEN CAPTURER IN VB.NET #3
Code:
Dim Graph As Graphics

Graph as, Graphics? :unsure:

The naming conventions here are horrible. Nothing wrong with declaring Bitmap over and over in my opinion... The bad, is that if you're going to do that, you should be disposing of the resources... If you go Coder-San's way, then you only have one instance to deal with. So if you're too lazy to clean up after yourself, that's a quick solution.
ArkPhaze
"Object oriented way to get rich? Inheritance"
Getting Started: C/C++ | Common Mistakes
[ Assembly / C++ / .NET / Haskell / J Programmer ]

Reply

RE: HOW TO MAKE A SCREEN CAPTURER IN VB.NET #4
It won't make much difference in basic use of graphics like here, but if you, lets say, are making a Zoom function in a pictureviewer the memory usage will be astonishing.
[Image: rytwG00.png]
Redcat Revolution!

Reply

RE: HOW TO MAKE A SCREEN CAPTURER IN VB.NET #5
nice, just finished mine the other day with GUI polished.

Reply

RE: HOW TO MAKE A SCREEN CAPTURER IN VB.NET #6
thanx for sharing i like it >>>>>>>>

Reply

RE: HOW TO MAKE A SCREEN CAPTURER IN VB.NET #7
thnx i'm gonna impress my teacher with this simple trick Biggrin

Thanks for sharing man Smile
[Image: gVaMf3E.png?1]

Reply