Results 1 to 15 of 15

Thread: Coordination Screenshot

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Sep 2010
    Posts
    200

    Coordination Screenshot

    The following code takes a picture automatically when you click the button

    Code:
       Public Class Form1
        Private Sub ConstructFromResourceSaveAsGif(ByVal e As PaintEventArgs)
    
        End Sub
        Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
            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
    
    
        End Sub
    
    End Class
    The next part is responsible for Coordination image (where to where this photograph) So I want to take the Coordination from Form2, how I can do this?
    Code:
    graph.CopyFromScreen(bounds.X, bounds.Y, 0, 0, bounds.Size, CopyPixelOperation.SourceCopy)

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,344

    Re: Coordination Screenshot

    I think you mean "coordinates" rather than "coordination". If so then you need to use the Bounds property of Form2 rather than of Screen.PrimaryScreen.

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Sep 2010
    Posts
    200

    Re: Coordination Screenshot

    yes,like hare in the video:
    http://www.youtube.com/watch?v=SLJiSG5aQ3g
    (5:20 - 5:50 mins)

    u can give me example?

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Sep 2010
    Posts
    200

    Re: Coordination Screenshot

    Help..

  5. #5
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,344

    Re: Coordination Screenshot

    I already told you what you need to do: use the Bounds property of the form. What exactly is the problem?

  6. #6

    Thread Starter
    Addicted Member
    Join Date
    Sep 2010
    Posts
    200

    Re: Coordination Screenshot

    want to do it in Form2, you can give me an example code?

  7. #7
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,344

    Re: Coordination Screenshot

    You've already got example code. You posted it yourself. You just need to change it as I have already suggested.
    use the Bounds property of Form2 rather than of Screen.PrimaryScreen

  8. #8

    Thread Starter
    Addicted Member
    Join Date
    Sep 2010
    Posts
    200

    Re: Coordination Screenshot

    I do not understand, what is the code?


    Code:
    graph.CopyFromScreen(form2.X, form2.Y, 0, 0, bounds.Size, CopyPixelOperation.SourceCopy)
    ?

  9. #9
    Hyperactive Member Skatebone's Avatar
    Join Date
    Jan 2009
    Location
    Malta
    Posts
    279

    Re: Coordination Screenshot

    Did you write that code yourself? If so you should understand what jm means.

    Here he means something like this I think but I didnt read your case.

    Code:
            Dim bounds As Rectangle = Form2.Bounds
            Dim screenshot As System.Drawing.Bitmap = New System.Drawing.Bitmap(bounds.Width, bounds.Height, System.Drawing.Imaging.PixelFormat.Format32bppArgb)
            Dim Graph As Graphics= Graphics.FromImage(screenshot)
            Graph.CopyFromScreen(bounds.X, bounds.Y, 0, 0, bounds.Size, CopyPixelOperation.SourceCopy)
    	PictureBox1.Image = screenshot
    Last edited by Skatebone; Nov 17th, 2010 at 07:23 AM.
    Life runs on code

  10. #10

    Thread Starter
    Addicted Member
    Join Date
    Sep 2010
    Posts
    200

    Re: Coordination Screenshot

    Quote Originally Posted by Skatebone View Post
    Did you write that code yourself? If so you should understand what jm means.

    Here he means something like this I think but I didnt read your case.

    Code:
            Dim bounds As Rectangle = Form2.Bounds
            Dim screenshot As System.Drawing.Bitmap = New System.Drawing.Bitmap(bounds.Width, bounds.Height, System.Drawing.Imaging.PixelFormat.Format32bppArgb)
            Dim Graph As Graphics= Graphics.FromImage(screenshot)
            Graph.CopyFromScreen(bounds.X, bounds.Y, 0, 0, bounds.Size, CopyPixelOperation.SourceCopy)
    	PictureBox1.Image = screenshot
    Thanks but that's not accurate, it takes all the screen and not just the part I want (I want mark it with Form2 course)

  11. #11

    Thread Starter
    Addicted Member
    Join Date
    Sep 2010
    Posts
    200

    Re: Coordination Screenshot

    up..

  12. #12
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,344

    Re: Coordination Screenshot

    You need to use the Bounds of the form you want. That code is using the default instance of Form2 to get the Bounds. Is it the default instance that you displayed in the first place? If you don;t know what a default instance is, follow the Blog link in my signature and read my post on the subject.

  13. #13

    Thread Starter
    Addicted Member
    Join Date
    Sep 2010
    Posts
    200

    Re: Coordination Screenshot

    I do not see, you can give me a link?

  14. #14
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,344

    Re: Coordination Screenshot

    I already have.
    the Blog link in my signature

  15. #15

    Thread Starter
    Addicted Member
    Join Date
    Sep 2010
    Posts
    200

    Re: Coordination Screenshot

    v. thx...

Posting Permissions

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



Click Here to Expand Forum to Full Width