+ Reply to Thread
Results 1 to 8 of 8

Thread: Screen Shot

  1. #1
    Newbie VBnet is on a distinguished road VBnet's Avatar
    Join Date
    May 2009
    Location
    Sweden :D
    Posts
    18

    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 05:58 AM.

  2. #2
    Super Moderator WingedPanther has much to be proud of WingedPanther has much to be proud of WingedPanther has much to be proud of WingedPanther has much to be proud of WingedPanther has much to be proud of WingedPanther has much to be proud of WingedPanther has much to be proud of WingedPanther has much to be proud of WingedPanther has much to be proud of WingedPanther's Avatar
    Join Date
    Jul 2006
    Age
    36
    Posts
    11,660
    Blog Entries
    57

    Re: Screen Shot

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

  3. #3
    Xav
    Xav is offline
    Code Slinger Xav has much to be proud of Xav has much to be proud of Xav has much to be proud of Xav has much to be proud of Xav has much to be proud of Xav has much to be proud of Xav has much to be proud of Xav has much to be proud of Xav has much to be proud of Xav's Avatar
    Join Date
    Mar 2008
    Location
    The North Pole
    Posts
    13,210
    Blog Entries
    13

    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

  4. #4
    Newbie VBnet is on a distinguished road VBnet's Avatar
    Join Date
    May 2009
    Location
    Sweden :D
    Posts
    18

    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:

  5. #5
    Xav
    Xav is offline
    Code Slinger Xav has much to be proud of Xav has much to be proud of Xav has much to be proud of Xav has much to be proud of Xav has much to be proud of Xav has much to be proud of Xav has much to be proud of Xav has much to be proud of Xav has much to be proud of Xav's Avatar
    Join Date
    Mar 2008
    Location
    The North Pole
    Posts
    13,210
    Blog Entries
    13

    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

  6. #6
    Newbie VBnet is on a distinguished road VBnet's Avatar
    Join Date
    May 2009
    Location
    Sweden :D
    Posts
    18

    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

  7. #7
    Xav
    Xav is offline
    Code Slinger Xav has much to be proud of Xav has much to be proud of Xav has much to be proud of Xav has much to be proud of Xav has much to be proud of Xav has much to be proud of Xav has much to be proud of Xav has much to be proud of Xav has much to be proud of Xav's Avatar
    Join Date
    Mar 2008
    Location
    The North Pole
    Posts
    13,210
    Blog Entries
    13

    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

  8. #8
    Newbie VBnet is on a distinguished road VBnet's Avatar
    Join Date
    May 2009
    Location
    Sweden :D
    Posts
    18

    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. [Tutorial] Hackers Gibson, Desktop Customization
    By Donovan in forum Tutorials
    Replies: 21
    Last Post: 07-25-2009, 12:20 PM
  2. C++ and SDL Game
    By oogie in forum C and C++
    Replies: 3
    Last Post: 04-17-2009, 04:24 PM
  3. Need help inmediatly
    By -hetsteve- in forum Java Help
    Replies: 5
    Last Post: 01-01-2009, 06:33 AM
  4. Replies: 0
    Last Post: 08-25-2007, 10:16 PM
  5. capture screen shot from an application during run time
    By engr in forum Visual Basic Programming
    Replies: 1
    Last Post: 01-29-2007, 03:38 PM

Bookmarks

Bookmarks

     
        Algorithms and Data Structures

        Java tutorials

        Algorithms Forum

Posting Permissions

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