+ Reply to Thread
Results 1 to 8 of 8

Thread: Screen Shot

  1. #1
    VBnet's Avatar
    VBnet is offline Newbie
    Join Date
    May 2009
    Location
    Sweden :D
    Posts
    18
    Rep Power
    11

    Screen Shot

    Hello CodeCall Members!!

    I will be showing you how to take a screen shot with VB.NET

    First youŽll need 2 Buttons and a picture box wich covers a big area

    place the first button and rename it to "Take Screenshot", then add the code :
    Code:
    Dim bounds As Rectangle
            Dim screenshot As System.Drawing.Bitmap
            Dim graph As Graphics
            bounds = Screen.PrimaryScreen.Bounds
            screenshot = New System.Drawing.Bitmap(bounds.Width, bounds.Height, 
    
    System.Drawing.Imaging.PixelFormat.Format32bppArgb)
            graph = Graphics.FromImage(screenshot)
            graph.CopyFromScreen(bounds.X, bounds.Y, 0, 0, bounds.Size, CopyPixelOperation.SourceCopy)
            PictureBox1.Image = screenshot
    then place the second button, name it "Save", then add the code :
    Code:
    Dim savefiledialog1 As New SaveFileDialog
            Try
                savefiledialog1.Title = "Save File"
                savefiledialog1.FileName = "*.jpeg"
                savefiledialog1.Filter = "JPEG |*.jpeg"
                If savefiledialog1.ShowDialog() = DialogResult.OK Then
                    PictureBox1.Image.Save(savefiledialog1.FileName, System.Drawing.Imaging.ImageFormat.Bmp)
                End If
            Catch ex As Exception 'Do Nothing
            End Try
    and at last add the picture box, make sure it covers a big area so that the screenshot will fit in.
    Last edited by WingedPanther; 05-07-2009 at 03:58 AM.

  2. CODECALL Circuit advertisement
    Join Date
    Always
    Location
    Advertising world
    Posts
    Many

     
  3. #2
    Join Date
    Jul 2006
    Posts
    16,486
    Blog Entries
    75
    Rep Power
    143

    Re: Screen Shot

    Not bad, but PLEASE be sure to use the code tags (the # button) when posting code, especially in a tutorial.
    Programming is a branch of mathematics.
    My CodeCall Blog | My Personal Blog

  4. #3
    Join Date
    Mar 2008
    Location
    The North Pole
    Posts
    13,174
    Blog Entries
    13
    Rep Power
    114

    Re: Screen Shot

    Look at these properties:

    Code:
    savefiledialog1.Title = "Save File"
                savefiledialog1.FileName = "*.jpeg"
                savefiledialog1.Filter = "JPEG |*.jpeg"
    Why not simply add a dialog from the toolbox? It would save a lot of coding work.

    Quote Originally Posted by Jordan View Post
    Good members, like yourself, stick around and post for ages to come!
    Mr. Xav | Blog | Forums

  5. #4
    VBnet's Avatar
    VBnet is offline Newbie
    Join Date
    May 2009
    Location
    Sweden :D
    Posts
    18
    Rep Power
    11

    Smile Re: Screen Shot

    Quote Originally Posted by Xav View Post
    Look at these properties:

    Code:
    savefiledialog1.Title = "Save File"
                savefiledialog1.FileName = "*.jpeg"
                savefiledialog1.Filter = "JPEG |*.jpeg"
    Why not simply add a dialog from the toolbox? It would save a lot of coding work.
    hmm. dunno why.. i dont mind doing some code work.. :001_tt2:

  6. #5
    Join Date
    Mar 2008
    Location
    The North Pole
    Posts
    13,174
    Blog Entries
    13
    Rep Power
    114

    Re: Screen Shot

    Lol - but if it's easier, then why not?

    Quote Originally Posted by Jordan View Post
    Good members, like yourself, stick around and post for ages to come!
    Mr. Xav | Blog | Forums

  7. #6
    VBnet's Avatar
    VBnet is offline Newbie
    Join Date
    May 2009
    Location
    Sweden :D
    Posts
    18
    Rep Power
    11

    Re: Screen Shot

    Quote Originally Posted by Xav View Post
    Lol - but if it's easier, then why not?
    because i dont mind typing 3 lines of coding

  8. #7
    Join Date
    Mar 2008
    Location
    The North Pole
    Posts
    13,174
    Blog Entries
    13
    Rep Power
    114

    Re: Screen Shot

    I thought you like to keep tutorials simple?

    +rep for the tutorial.

    Quote Originally Posted by Jordan View Post
    Good members, like yourself, stick around and post for ages to come!
    Mr. Xav | Blog | Forums

  9. #8
    VBnet's Avatar
    VBnet is offline Newbie
    Join Date
    May 2009
    Location
    Sweden :D
    Posts
    18
    Rep Power
    11

    Re: Screen Shot

    Quote Originally Posted by Xav View Post
    I thought you like to keep tutorials simple?

    +rep for the tutorial.
    Yeah i do

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Taking snap shot on video.
    By deepman in forum Visual Basic Programming
    Replies: 3
    Last Post: 02-17-2011, 03:07 PM
  2. Screen resolution issue and getting rid of gaps around the edges of the screen...
    By HumansAreFriendsNotFood in forum HTML Programming
    Replies: 10
    Last Post: 06-07-2010, 11:07 AM
  3. Creating a Screen Shot tool - VB.NET
    By Vswe in forum Visual Basic Tutorials
    Replies: 8
    Last Post: 12-23-2009, 05:04 AM
  4. capture screen shot from an application during run time
    By engr in forum Visual Basic Programming
    Replies: 1
    Last Post: 01-29-2007, 01:38 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts