Lost Password?

  #1 (permalink)  
Old 04-10-2008, 07:59 PM
travy92's Avatar   
travy92 travy92 is offline
Learning Programmer
 
Join Date: Sep 2007
Location: Australia
Age: 15
Posts: 71
Rep Power: 4
travy92 is on a distinguished road
Send a message via MSN to travy92
Post VB2008 Tutorial - Print Screen

Hello everyone! I recently saw TcM's code of Print Screen and i decided to try and make it to see if i could do what he could do .

So i ended up with a full code (not advanced as TcM's though, he's a much more experienced programmer).

__________________________________________________ _______________

GUI
Options Form:



Picture Form:

__________________________________________________ _______________

What you will need:

2 Forms named:

Options.vb (Form1)
Picture.vb (Form2)



On the options form:

4 Labels named:


Name: Label1
Text: "ScreenShot Name:"

Name: Label2
Text: "ScreenShot No."

Name: Label3
Text: "Label3"

Name: Label4
Text: "Label4"


1 Command Button named:
Name: Button1
Text: "Take ScreenShot"


On the Picture Form you will need:

1 PictureBox named:
Name: PictureBox1
__________________________________________________ _______________

Ok now for the code:
This is the full Code, the explanation follows:


This is the code for the Options Form.

Code:
Public Class Options

    Private Sub Options_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Label3.Text = "ScreenShot"
        Label4.Text = "0"
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Hide()
        Label3.Text = "ScreenShot"
        Label4.Text = Format(Val(Label4.Text) + 1)
        Threading.Thread.Sleep(2000)
        SendKeys.Send("{Prtsc}")
        Threading.Thread.Sleep(1000)
        Picture.Show()
        Picture.PictureBox1.Image = My.Computer.Clipboard.GetImage
        Try
            Picture.PictureBox1.Image.Save("ScreenShot " & Label4.Text & ".bmp")
        Catch
            MsgBox("ERROR! There is already a file named ScreenShot " & Label4.Text & ".", MsgBoxStyle.OkOnly & MsgBoxStyle.Critical, "ERROR!")
        End Try
        Show()
        Threading.Thread.Sleep(1000)
        Activate()
    End Sub
End Class
And this is the code for the Picture Form.

Code:
Public Class Picture

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Me.WindowState = FormWindowState.Maximized
    End Sub

    Private Sub Picture_MouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseClick
        Hide()
    End Sub

    Private Sub PictureBox1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles PictureBox1.Click
        Hide()
    End Sub
End Class
__________________________________________________ _______________

CODE EXPLANATION

For the Options Form:

Code:
Public Class Options
End Class
Basically means "The code for Options Form" and "Close coding for options form".
_____________________

Code:
Private Sub Options_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Label3.Text = "ScreenShot"
        Label4.Text = "0"
    End Sub
When the form loads (Options Form), Label3's text becomes "ScreenShot" and Label4's text becomes "0". Then Ends the Options_load event.

_____________________

Code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Hide()
        Label3.Text = "ScreenShot"
        Label4.Text = Format(Val(Label4.Text) + 1)
        Threading.Thread.Sleep(2000)
        SendKeys.Send("{Prtsc}")
        Threading.Thread.Sleep(1000)
        Picture.Show()
        Picture.PictureBox1.Image = My.Computer.Clipboard.GetImage
        Try
            Picture.PictureBox1.Image.Save("ScreenShot " & Label4.Text & ".bmp")
        Catch
            MsgBox("ERROR! There is already a file named ScreenShot " & Label4.Text & ".", MsgBoxStyle.OkOnly & MsgBoxStyle.Critical, "ERROR!")
        End Try
        Show()
        Threading.Thread.Sleep(1000)
        Activate()
    End Sub
Ok now this is a little more complicated.
When you click the Button1 Button, the following events are fired (in order of the code above):

- Hides Form
- Changes Label3's text to "ScreenShot"
- Changes Label4's text to + 1 of what it already is (eg. If Label4's text is 4 then it becomes 5)
- Make Thread Sleep (Pause for 2 sec)
- Send the keys (Prtsc) which is Print Screen
- Makes Thread Sleep (Pause for 1 sec)
- Show the Picture Form
- Get the Image that you jsut ScreenShotted
- Try to save the image with the name, but if there's already a file with the same name, do the following:
- Provides a message box telling you that there is another file with the same name
- Stops Try
- Shows the main form (Options.vb)
- Make Thread Sleep (Pause for 1 sec)
- Activate Options.vb (Options Form)
- End Codes for Button1

________________________________________

Picture Form Code:

Code:
Public Class Picture
End Class
Just means "Code for Picture Form" and "Stop code for Picture Form".

___________________

Code:
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Me.WindowState = FormWindowState.Maximized
    End Sub
When Form1 Loads (Picture.vb / Picture Form), Make the window state maximized). Stop coding for Picture.Load.

___________________

Code:
Private Sub Picture_MouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseClick
        Hide()
    End Sub
When you click the Picture Form, Hide the form.

___________________

Code:
Private Sub PictureBox1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles PictureBox1.Click
        Hide()
    End Sub
When you click PictureBox1, Hide the form.

__________________________________________________ _______________

Thankyou for reading this tutorial.

Made by Travy92,
Special thanks to TcM for giving me the idea

Attachments for my ScreenShot Program are below:
Attached Files To view attachments your post count must be 1 or greater. Your post count is 0 momentarily.
__________________
Quote:
The pacifist's task today is to find a method of helping and healing which provides a revolutionary constructive substitute for war.

Last edited by Jordan; 04-11-2008 at 11:42 AM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Sponsored Links
  #2 (permalink)  
Old 04-11-2008, 11:26 AM
Xav's Avatar   
Xav Xav is offline
Guru
 
Join Date: Mar 2008
Location: London, England
Posts: 3,190
Last Blog:
The Windows Registry
Rep Power: 28
Xav is a name known to allXav is a name known to allXav is a name known to allXav is a name known to allXav is a name known to allXav is a name known to all
Send a message via MSN to Xav
Default Re: VB2008 Tutorial - Print Screen

Nice one, travy.
__________________
Xav, the power of youth
Worship the Creator... not his creations
Web Site | Beta Site
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 05-16-2008, 01:34 PM
kridan kridan is offline
Newbie
 
Join Date: May 2008
Posts: 1
Rep Power: 0
kridan is on a distinguished road
Default Re: VB2008 Tutorial - Print Screen

this is good
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 05-16-2008, 11:57 PM
Martin_kp's Avatar   
Martin_kp Martin_kp is offline
Learning Programmer
 
Join Date: May 2008
Location: Indonesia
Age: 10
Posts: 47
Rep Power: 1
Martin_kp is on a distinguished road
Default Re: VB2008 Tutorial - Print Screen

Hey! I typed it up in Visual Basic and:
7 ERRORS.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 05-17-2008, 11:05 AM
Xav's Avatar   
Xav Xav is offline
Guru
 
Join Date: Mar 2008
Location: London, England
Posts: 3,190
Last Blog:
The Windows Registry
Rep Power: 28
Xav is a name known to allXav is a name known to allXav is a name known to allXav is a name known to allXav is a name known to allXav is a name known to all
Send a message via MSN to Xav
Default Re: VB2008 Tutorial - Print Screen

Don't type it - grab it straight from the ZIP file. Are you using VS2008?
__________________
Xav, the power of youth
Worship the Creator... not his creations
Web Site | Beta Site
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Sponsored Links
  #6 (permalink)  
Old 05-18-2008, 03:54 AM
Martin_kp's Avatar   
Martin_kp Martin_kp is offline
Learning Programmer
 
Join Date: May 2008
Location: Indonesia
Age: 10
Posts: 47
Rep Power: 1
Martin_kp is on a distinguished road
Default Re: VB2008 Tutorial - Print Screen

How'd ya know? didtca ask someone?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #7 (permalink)  
Old 05-18-2008, 07:41 AM
Xav's Avatar   
Xav Xav is offline
Guru
 
Join Date: Mar 2008
Location: London, England
Posts: 3,190
Last Blog:
The Windows Registry
Rep Power: 28
Xav is a name known to allXav is a name known to allXav is a name known to allXav is a name known to allXav is a name known to allXav is a name known to all
Send a message via MSN to Xav
Default Re: VB2008 Tutorial - Print Screen

Er, no. This tutorial is about VS2008, so I'm confirming you're using the .NET Framework v3.5. If not, the objects are slightly different.
__________________
Xav, the power of youth
Worship the Creator... not his creations
Web Site | Beta Site
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #8 (permalink)  
Old 05-20-2008, 01:24 AM
Martin_kp's Avatar   
Martin_kp Martin_kp is offline
Learning Programmer
 
Join Date: May 2008
Location: Indonesia
Age: 10
Posts: 47
Rep Power: 1
Martin_kp is on a distinguished road
Default Re: VB2008 Tutorial - Print Screen

Yeah I know. I'm using VS2008 (Visual Studio 2008 right?). Wait a minute... ARGH! I FORGOT IT'S IN 2.0 Mode last time! (forgot to exchange it.)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #9 (permalink)  
Old 05-20-2008, 02:25 PM
Xav's Avatar   
Xav Xav is offline
Guru
 
Join Date: Mar 2008
Location: London, England
Posts: 3,190
Last Blog:
The Windows Registry
Rep Power: 28
Xav is a name known to allXav is a name known to allXav is a name known to allXav is a name known to allXav is a name known to allXav is a name known to all
Send a message via MSN to Xav
Default Re: VB2008 Tutorial - Print Screen

So - you're obviously quite young (like me) - you're into programming? When did you start learning?
__________________
Xav, the power of youth
Worship the Creator... not his creations
Web Site | Beta Site
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #10 (permalink)  
Old 05-21-2008, 05:49 AM
Martin_kp's Avatar   
Martin_kp Martin_kp is offline
Learning Programmer
 
Join Date: May 2008
Location: Indonesia
Age: 10
Posts: 47
Rep Power: 1
Martin_kp is on a distinguished road
Default Re: VB2008 Tutorial - Print Screen

Uh, at 9 (or was it 10?) ?
Hey wait a minute. Aren't we off the topic?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Sponsored Links
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Tutorial - Smarterchild copy travy92 VB Tutorials 15 06-02-2008 02:06 PM
Code: Print Screen TcM VB Tutorials 16 04-22-2008 03:10 PM
CodeCall Tutorial Contest #4 Jordan Announcements 29 02-25-2008 11:25 AM
Code: Print Screen v2 TcM VB Tutorials 5 09-26-2007 07:17 AM
John's Java Tutorial Index John Java Tutorials 0 01-11-2007 03:05 PM


All times are GMT -5. The time now is 06:28 PM.

Contest Stats

dargueta ........ 128.00000
John ........ 127.00000
Xav ........ 107.00000
gaylo565 ........ 18.00000
Johnnyboy ........ 3.00000
navghost ........ 1.00000

Contest Rules

Ads