Note that there are some explanatory texts on larger screens.

plurals
  1. POscreen capture with 2 windows forms
    primarykey
    data
    text
    <p>I am trying to make a screen capture application, but I am having a problem understanding the code. From what I understand the Form2 window is the part that will be captured. So then why does FOrm1 cover the entire screen when I run this application? How can I make the Form1 window be visible and then when a button is clicked activate the mousedown event and hide the Form1 to system trey? Here is an example of what I see and nothing else <img src="https://i.stack.imgur.com/gvhrt.png" alt="enter image description here"> i only want to activate the region screenshot when the button is pressed. Not right away.</p> <pre><code>Public Class Form1 Private Sub Form1_KeyDown(sender As Object, e As KeyEventArgs) Handles Me.KeyDown If e.KeyCode = Keys.Escape Then Me.Close() End If End Sub Private Sub Form1_MouseDown(sender As Object, e As MouseEventArgs) Handles Me.MouseDown Form2.Show() Form2.Location = Cursor.Position Form2.Location = Form2.Location End Sub Private Sub Form1_MouseMove(sender As Object, e As MouseEventArgs) Handles Me.MouseMove Form2.Size = Cursor.Position - Form2.Location End Sub Private Sub Form1_MouseUp(sender As Object, e As MouseEventArgs) Handles Me.MouseUp Form2.Hide() Me.Hide() Dim bounds As Form2 Dim screenshot As System.Drawing.Bitmap Dim graph As Graphics bounds = Form2 screenshot = New System.Drawing.Bitmap(bounds.Width, bounds.Height, System.Drawing.Imaging.PixelFormat.Format32bppArgb) graph = Graphics.FromImage(screenshot) graph.CopyFromScreen(Form2.Bounds.X, Form2.Bounds.Y, 0, 0, bounds.Size, CopyPixelOperation.SourceCopy) Form2.BackgroundImage = screenshot Dim sPath As New SaveFileDialog sPath.Filter = "Image (*.png)|*,*" sPath.ShowDialog() Dim bmp As Bitmap Try bmp = Form2.BackgroundImage bmp.Save(sPath.FileName + ".png") Catch ex As Exception MsgBox(ex.Message) End Try Me.Close() End Sub Private Sub Form1_Resize(sender As Object, e As EventArgs) Handles Me.Resize Try If Me.WindowState = FormWindowState.Minimized Then Me.Visible = False ScreenShot.Visible = True End If Catch ex As Exception MsgBox(ex.Message) End Try End Sub End Class </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload