Click here to Skip to main content
15,893,722 members
Articles / Programming Languages / Visual Basic

Screen Shot Application

Rate me:
Please Sign up or sign in to vote.
3.74/5 (69 votes)
24 Sep 2010CPOL5 min read 303.2K   18.6K   210  
Screen Shot is a simple application that allows a user to quickly capture images from the screen and save them in a user predefined folder.
Public Class RectangleForm
    Dim pt As Point = Nothing
    Dim tollbarFrm As ToolBarForm

    Private Sub CancelToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CancelToolStripMenuItem.Click
        Me.Close()
    End Sub

    Private Sub Form3_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.DoubleClick
        Me.tollbarFrm.CaptureRectangleTSB.PerformClick()
    End Sub

    Private Sub Form2_FormClosed(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosedEventArgs) Handles Me.FormClosed
        My.Forms.MenuForm.ObjectTSB.Enabled = True
    End Sub

    Private Sub Form3_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseDown
        Me.pt = e.Location
    End Sub

    Private Sub Form2_MouseEnter(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.MouseEnter
        Me.Focus()
    End Sub

    Private Sub Form3_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseMove
        If e.Button = Windows.Forms.MouseButtons.Left AndAlso Me.pt <> Nothing Then
            Me.Left += e.X - pt.X
            Me.Top += e.Y - pt.Y
        End If
    End Sub

    Private Sub Form3_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseUp
        Me.pt = Nothing
    End Sub

    Private Sub RectangleForm_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Me.tollbarFrm = New ToolBarForm
        Me.tollbarFrm.Left = Me.Left - 200
        Me.tollbarFrm.Top = Me.Top
        Me.tollbarFrm.Owner = Me
        Me.tollbarFrm.Show()
        My.Forms.MenuForm.ObjectTSB.Enabled = False
    End Sub

    Private Sub rectanglePanel_Paint(ByVal sender As System.Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles rectanglePanel.Paint
        Dim rect As Rectangle
        rect = New Rectangle(6, 6, Me.rectanglePanel.Width - 12, Me.rectanglePanel.Height - 12)
        Dim p1 As New Pen(My.Settings.PenColor, My.Settings.PenWidth)
        p1.DashStyle = My.Settings.DashStyle
        e.Graphics.DrawRectangle(p1, rect)
        p1.Dispose()
        Me.tollbarFrm.wLabel.Text = CStr(rect.Width - My.Settings.PenWidth)
        Me.tollbarFrm.hLabel.Text = CStr(rect.Height - My.Settings.PenWidth)
        Me.MinimumSize = New Size(32 + My.Settings.PenWidth, 32 + My.Settings.PenWidth)
        If rect.Width - My.Settings.PenWidth > 0 AndAlso rect.Height - My.Settings.PenWidth > 0 Then
            Me.tollbarFrm.CaptureRectangleTSB.Enabled = True
        Else
            Me.tollbarFrm.CaptureRectangleTSB.Enabled = False
        End If
    End Sub
End Class

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior) ZipEdTech
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions