From f2e275c8bde42bed84450e94fe1f03b5125f420b Mon Sep 17 00:00:00 2001 From: Jonathan Jenne Date: Fri, 16 Jun 2023 10:32:50 +0200 Subject: [PATCH] Base: add RetoreWindowSize --- Base/ScreenEx.vb | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/Base/ScreenEx.vb b/Base/ScreenEx.vb index d408d680..19a0648f 100644 --- a/Base/ScreenEx.vb +++ b/Base/ScreenEx.vb @@ -3,6 +3,9 @@ Imports System.Drawing Imports System.Windows.Forms Public Class ScreenEx + Public Const DEFAULT_WINDOW_HEIGHT = 480 + Public Const DEFAULT_WINDOW_WIDTH = 640 + Public Shared Function GetLocationWithinScreen(pLocation As Point) As Point? For Each screen As Screen In Screen.AllScreens If screen.Bounds.Contains(pLocation) Then @@ -46,6 +49,17 @@ Public Class ScreenEx RestoreFormState(pForm, oFormState) End Sub + Public Shared Sub RetoreWindowSize(pForm As Form, pFormSize As Size) + Dim oFormSize As Size + If pFormSize.Height < 1 Or pFormSize.Width < 1 Or pFormSize.IsEmpty Then + oFormSize = New Size(DEFAULT_WINDOW_WIDTH, DEFAULT_WINDOW_HEIGHT) + Else + oFormSize = pFormSize + End If + + pForm.Size = oFormSize + End Sub + ''' ''' Checks if a point is Visible on any screen '''