Here is the code. I am of course writing bad code since I am a beginner and far from a full time programmer, but am glad to learn how to write better code. I would also be happy to learn how to make this a control which I can put on a lot of forms.
Dim filN As String = "p83.png"
Call Label20_DoubleClick(sender, e) : Me.Refresh()
Call SaveFromScreen(Me, filN)
Call Label20_DoubleClick(sender, e)
Private Sub Label20_DoubleClick(sender As Object, e As EventArgs) Handles Label20.DoubleClick
Dim YN As Boolean = False
If Me.Height = 600 Then YN = True
Me.WindowState = FormWindowState.Normal
If YN Then
Me.Height = plotarea.Bottom + 110
Me.Width = plotarea.Right + plotarea.Left + 16
Else
Me.Height = 600
Me.Width = 800
End If
If plotarea.Height > 250 Then
If Me.Height = plotarea.Bottom + 110 Then YN = True
If YN Then
Me.Height = plotarea.Bottom + 260
Me.Width = Screen.PrimaryScreen.Bounds.Width
Else
Me.Height = plotarea.Bottom + 110
Me.Width = plotarea.Right + plotarea.Left + 16
End If
End If
End Sub
Sub SaveFromScreen(frm As Form, filn As String)
Dim img As New Bitmap(frm.ClientSize.Width, frm.ClientSize.Height)
Using gr As Graphics = Graphics.FromImage(img)
gr.CopyFromScreen(frm.PointToScreen(frm.ClientRectangle.Location), Point.Empty, frm.ClientSize)
End Using
img.Save(filn, Imaging.ImageFormat.Png)
End Sub
This was working fine on Windows 7, but does not work on Windows 10. Thanks for your help.