From 40fcd2794956de9374ca877b8960a1f39be8337e Mon Sep 17 00:00:00 2001 From: windowslogic Date: Sun, 15 Jun 2025 21:15:24 +0100 Subject: [PATCH] Fixed a few issues. - Version number is now gotten from the solution properties. - Moved some interface elements around to provide more context. - Made lock background grey to simulate classic Windows locking backgrounds. (I think this could be a customisable option in a future update.) --- ScreenLocker/Backdrop.Designer.vb | 6 +- ScreenLocker/LockUI.Designer.vb | 34 +++---- ScreenLocker/LockUI.vb | 10 +-- .../{Form1.Designer.vb => Main.Designer.vb} | 88 +++++++++---------- ScreenLocker/{Form1.resx => Main.resx} | 0 ScreenLocker/{Form1.vb => Main.vb} | 13 ++- .../My Project/Application.Designer.vb | 12 +-- ScreenLocker/My Project/Application.myapp | 5 +- ScreenLocker/My Project/AssemblyInfo.vb | 10 +-- ScreenLocker/ScreenLocker.vbproj | 10 +-- 10 files changed, 94 insertions(+), 94 deletions(-) rename ScreenLocker/{Form1.Designer.vb => Main.Designer.vb} (57%) rename ScreenLocker/{Form1.resx => Main.resx} (100%) rename ScreenLocker/{Form1.vb => Main.vb} (79%) diff --git a/ScreenLocker/Backdrop.Designer.vb b/ScreenLocker/Backdrop.Designer.vb index 2154b3e..7c33f3d 100644 --- a/ScreenLocker/Backdrop.Designer.vb +++ b/ScreenLocker/Backdrop.Designer.vb @@ -26,11 +26,13 @@ Partial Class Backdrop ' 'Backdrop ' - Me.AutoScaleDimensions = New System.Drawing.SizeF(8.0!, 16.0!) + Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font Me.BackColor = System.Drawing.Color.Black - Me.ClientSize = New System.Drawing.Size(800, 450) + Me.ClientSize = New System.Drawing.Size(600, 366) + Me.ForeColor = System.Drawing.Color.Gainsboro Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None + Me.Margin = New System.Windows.Forms.Padding(2, 2, 2, 2) Me.Name = "Backdrop" Me.Opacity = 0.7R Me.ShowIcon = False diff --git a/ScreenLocker/LockUI.Designer.vb b/ScreenLocker/LockUI.Designer.vb index be1e0e8..c5558f7 100644 --- a/ScreenLocker/LockUI.Designer.vb +++ b/ScreenLocker/LockUI.Designer.vb @@ -41,7 +41,7 @@ Partial Class LockUI Me.Label1.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.Label1.Location = New System.Drawing.Point(67, 105) Me.Label1.Name = "Label1" - Me.Label1.Size = New System.Drawing.Size(305, 18) + Me.Label1.Size = New System.Drawing.Size(253, 15) Me.Label1.TabIndex = 1 Me.Label1.Text = "This computer is in use and has been locked." ' @@ -51,9 +51,9 @@ Partial Class LockUI Me.Label2.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.Label2.Location = New System.Drawing.Point(68, 127) Me.Label2.Name = "Label2" - Me.Label2.Size = New System.Drawing.Size(311, 18) + Me.Label2.Size = New System.Drawing.Size(278, 15) Me.Label2.TabIndex = 2 - Me.Label2.Text = "Only DOMAIN\User can unlock this computer." + Me.Label2.Text = "Only the logged on user can unlock this computer." ' 'PictureBox2 ' @@ -69,54 +69,54 @@ Partial Class LockUI ' Me.PictureBox1.BackgroundImage = Global.ScreenLocker.My.Resources.Resources.Windows_10_Logo_svg Me.PictureBox1.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch - Me.PictureBox1.Location = New System.Drawing.Point(7, 12) + Me.PictureBox1.Location = New System.Drawing.Point(14, 8) Me.PictureBox1.Name = "PictureBox1" - Me.PictureBox1.Size = New System.Drawing.Size(414, 74) + Me.PictureBox1.Size = New System.Drawing.Size(477, 85) Me.PictureBox1.TabIndex = 0 Me.PictureBox1.TabStop = False ' 'TextBox1 ' - Me.TextBox1.Location = New System.Drawing.Point(84, 159) + Me.TextBox1.Location = New System.Drawing.Point(70, 159) Me.TextBox1.Name = "TextBox1" Me.TextBox1.PasswordChar = Global.Microsoft.VisualBasic.ChrW(42) - Me.TextBox1.Size = New System.Drawing.Size(333, 22) - Me.TextBox1.TabIndex = 4 + Me.TextBox1.Size = New System.Drawing.Size(349, 20) + Me.TextBox1.TabIndex = 0 ' 'Label3 ' Me.Label3.AutoSize = True Me.Label3.Location = New System.Drawing.Point(8, 162) Me.Label3.Name = "Label3" - Me.Label3.Size = New System.Drawing.Size(70, 16) + Me.Label3.Size = New System.Drawing.Size(56, 13) Me.Label3.TabIndex = 5 Me.Label3.Text = "Password:" ' 'Button1 ' - Me.Button1.Location = New System.Drawing.Point(342, 187) + Me.Button1.Location = New System.Drawing.Point(344, 189) Me.Button1.Name = "Button1" Me.Button1.Size = New System.Drawing.Size(75, 23) - Me.Button1.TabIndex = 6 + Me.Button1.TabIndex = 3 Me.Button1.Text = "Unlock" Me.Button1.UseVisualStyleBackColor = True ' 'Button2 ' - Me.Button2.Location = New System.Drawing.Point(261, 187) + Me.Button2.Location = New System.Drawing.Point(263, 189) Me.Button2.Name = "Button2" Me.Button2.Size = New System.Drawing.Size(75, 23) - Me.Button2.TabIndex = 7 + Me.Button2.TabIndex = 2 Me.Button2.Text = "Help" Me.Button2.UseVisualStyleBackColor = True ' 'CheckBox1 ' Me.CheckBox1.AutoSize = True - Me.CheckBox1.Location = New System.Drawing.Point(11, 187) + Me.CheckBox1.Location = New System.Drawing.Point(12, 193) Me.CheckBox1.Name = "CheckBox1" - Me.CheckBox1.Size = New System.Drawing.Size(124, 20) - Me.CheckBox1.TabIndex = 8 + Me.CheckBox1.Size = New System.Drawing.Size(101, 17) + Me.CheckBox1.TabIndex = 1 Me.CheckBox1.Text = "Show password" Me.CheckBox1.UseVisualStyleBackColor = True ' @@ -124,7 +124,7 @@ Partial Class LockUI ' Me.AcceptButton = Me.Button1 Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None - Me.ClientSize = New System.Drawing.Size(425, 216) + Me.ClientSize = New System.Drawing.Size(431, 224) Me.ControlBox = False Me.Controls.Add(Me.CheckBox1) Me.Controls.Add(Me.Button2) diff --git a/ScreenLocker/LockUI.vb b/ScreenLocker/LockUI.vb index 23720e3..2a8003f 100644 --- a/ScreenLocker/LockUI.vb +++ b/ScreenLocker/LockUI.vb @@ -9,15 +9,15 @@ End Sub Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click - If Form1.message.Length = 0 Then - MsgBox("This computer has been locked by ScreenLocker." + Environment.NewLine + "The user has not left a help message.") - Else MsgBox("This computer has been locked by ScreenLocker." + Environment.NewLine + "Help message left by user: " + Form1.message) + If Main.message.Length = 0 Then + MsgBox("This computer has been locked by ScreenLocker." + vbNewLine + "The user has not left a help message.") + Else MsgBox("This computer has been locked by ScreenLocker." + vbNewLine + "Help message left by user: " + Main.message) End If End Sub Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click - If TextBox1.Text = Form1.password Then - Form1.Close() + If TextBox1.Text = Main.password Then + Main.Close() Else MsgBox("Incorrect password!") End If diff --git a/ScreenLocker/Form1.Designer.vb b/ScreenLocker/Main.Designer.vb similarity index 57% rename from ScreenLocker/Form1.Designer.vb rename to ScreenLocker/Main.Designer.vb index 9cadd58..ab7e6b0 100644 --- a/ScreenLocker/Form1.Designer.vb +++ b/ScreenLocker/Main.Designer.vb @@ -1,5 +1,5 @@  _ -Partial Class Form1 +Partial Class Main Inherits System.Windows.Forms.Form 'Form overrides dispose to clean up the component list. @@ -22,83 +22,83 @@ Partial Class Form1 'Do not modify it using the code editor. _ Private Sub InitializeComponent() - Me.Button1 = New System.Windows.Forms.Button() + Me.LockButton = New System.Windows.Forms.Button() Me.TextBox1 = New System.Windows.Forms.TextBox() Me.TextBox2 = New System.Windows.Forms.TextBox() Me.Label1 = New System.Windows.Forms.Label() Me.Label2 = New System.Windows.Forms.Label() - Me.Button2 = New System.Windows.Forms.Button() - Me.Button3 = New System.Windows.Forms.Button() + Me.ExitButton = New System.Windows.Forms.Button() + Me.AboutButton = New System.Windows.Forms.Button() Me.CheckBox1 = New System.Windows.Forms.CheckBox() Me.SuspendLayout() ' - 'Button1 + 'LockButton ' - Me.Button1.Location = New System.Drawing.Point(174, 84) - Me.Button1.Name = "Button1" - Me.Button1.Size = New System.Drawing.Size(75, 23) - Me.Button1.TabIndex = 0 - Me.Button1.Text = "Lock" - Me.Button1.UseVisualStyleBackColor = True + Me.LockButton.Location = New System.Drawing.Point(174, 84) + Me.LockButton.Name = "LockButton" + Me.LockButton.Size = New System.Drawing.Size(75, 23) + Me.LockButton.TabIndex = 6 + Me.LockButton.Text = "Lock" + Me.LockButton.UseVisualStyleBackColor = True ' 'TextBox1 ' - Me.TextBox1.Location = New System.Drawing.Point(12, 12) + Me.TextBox1.Location = New System.Drawing.Point(74, 12) Me.TextBox1.Name = "TextBox1" Me.TextBox1.PasswordChar = Global.Microsoft.VisualBasic.ChrW(42) - Me.TextBox1.Size = New System.Drawing.Size(100, 22) + Me.TextBox1.Size = New System.Drawing.Size(172, 20) Me.TextBox1.TabIndex = 1 ' 'TextBox2 ' - Me.TextBox2.Location = New System.Drawing.Point(12, 56) + Me.TextBox2.Location = New System.Drawing.Point(114, 56) Me.TextBox2.Name = "TextBox2" - Me.TextBox2.Size = New System.Drawing.Size(100, 22) - Me.TextBox2.TabIndex = 2 + Me.TextBox2.Size = New System.Drawing.Size(132, 20) + Me.TextBox2.TabIndex = 3 ' 'Label1 ' Me.Label1.AutoSize = True - Me.Label1.Location = New System.Drawing.Point(118, 15) + Me.Label1.Location = New System.Drawing.Point(12, 15) Me.Label1.Name = "Label1" - Me.Label1.Size = New System.Drawing.Size(67, 16) + Me.Label1.Size = New System.Drawing.Size(56, 13) Me.Label1.TabIndex = 3 - Me.Label1.Text = "Password" + Me.Label1.Text = "Password:" ' 'Label2 ' Me.Label2.AutoSize = True - Me.Label2.Location = New System.Drawing.Point(118, 59) + Me.Label2.Location = New System.Drawing.Point(12, 59) Me.Label2.Name = "Label2" - Me.Label2.Size = New System.Drawing.Size(123, 16) + Me.Label2.Size = New System.Drawing.Size(96, 13) Me.Label2.TabIndex = 4 Me.Label2.Text = "Message (optional)" ' - 'Button2 + 'ExitButton ' - Me.Button2.Location = New System.Drawing.Point(93, 84) - Me.Button2.Name = "Button2" - Me.Button2.Size = New System.Drawing.Size(75, 23) - Me.Button2.TabIndex = 5 - Me.Button2.Text = "Exit" - Me.Button2.UseVisualStyleBackColor = True + Me.ExitButton.Location = New System.Drawing.Point(93, 84) + Me.ExitButton.Name = "ExitButton" + Me.ExitButton.Size = New System.Drawing.Size(75, 23) + Me.ExitButton.TabIndex = 5 + Me.ExitButton.Text = "Exit" + Me.ExitButton.UseVisualStyleBackColor = True ' - 'Button3 + 'AboutButton ' - Me.Button3.Location = New System.Drawing.Point(12, 84) - Me.Button3.Name = "Button3" - Me.Button3.Size = New System.Drawing.Size(75, 23) - Me.Button3.TabIndex = 6 - Me.Button3.Text = "About" - Me.Button3.UseVisualStyleBackColor = True + Me.AboutButton.Location = New System.Drawing.Point(12, 84) + Me.AboutButton.Name = "AboutButton" + Me.AboutButton.Size = New System.Drawing.Size(75, 23) + Me.AboutButton.TabIndex = 4 + Me.AboutButton.Text = "About" + Me.AboutButton.UseVisualStyleBackColor = True ' 'CheckBox1 ' Me.CheckBox1.AutoSize = True - Me.CheckBox1.Location = New System.Drawing.Point(12, 36) + Me.CheckBox1.Location = New System.Drawing.Point(12, 33) Me.CheckBox1.Name = "CheckBox1" - Me.CheckBox1.Size = New System.Drawing.Size(124, 20) - Me.CheckBox1.TabIndex = 7 + Me.CheckBox1.Size = New System.Drawing.Size(101, 17) + Me.CheckBox1.TabIndex = 2 Me.CheckBox1.Text = "Show password" Me.CheckBox1.UseVisualStyleBackColor = True ' @@ -108,13 +108,13 @@ Partial Class Form1 Me.ClientSize = New System.Drawing.Size(258, 114) Me.ControlBox = False Me.Controls.Add(Me.CheckBox1) - Me.Controls.Add(Me.Button3) - Me.Controls.Add(Me.Button2) + Me.Controls.Add(Me.AboutButton) + Me.Controls.Add(Me.ExitButton) Me.Controls.Add(Me.Label2) Me.Controls.Add(Me.Label1) Me.Controls.Add(Me.TextBox2) Me.Controls.Add(Me.TextBox1) - Me.Controls.Add(Me.Button1) + Me.Controls.Add(Me.LockButton) Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle Me.Name = "Form1" Me.Text = "ScreenLocker" @@ -123,12 +123,12 @@ Partial Class Form1 End Sub - Friend WithEvents Button1 As Button + Friend WithEvents LockButton As Button Friend WithEvents TextBox1 As TextBox Friend WithEvents TextBox2 As TextBox Friend WithEvents Label1 As Label Friend WithEvents Label2 As Label - Friend WithEvents Button2 As Button - Friend WithEvents Button3 As Button + Friend WithEvents ExitButton As Button + Friend WithEvents AboutButton As Button Friend WithEvents CheckBox1 As CheckBox End Class diff --git a/ScreenLocker/Form1.resx b/ScreenLocker/Main.resx similarity index 100% rename from ScreenLocker/Form1.resx rename to ScreenLocker/Main.resx diff --git a/ScreenLocker/Form1.vb b/ScreenLocker/Main.vb similarity index 79% rename from ScreenLocker/Form1.vb rename to ScreenLocker/Main.vb index fc982ba..7af3f4c 100644 --- a/ScreenLocker/Form1.vb +++ b/ScreenLocker/Main.vb @@ -1,5 +1,4 @@ - -Public Class Form1 +Public Class Main Public Shared password As String Public Shared message As String Dim Times As Integer @@ -7,20 +6,20 @@ Public Class Form1 Times = 0 End Sub - Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click + Private Sub Button2_Click(sender As Object, e As EventArgs) Handles ExitButton.Click Me.Close() End Sub - Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click - MsgBox("ScreenLocker v1.3 by Eri/Noxyntious" + Environment.NewLine + "Licensed under MIT") + Private Sub Button3_Click(sender As Object, e As EventArgs) Handles AboutButton.Click + MsgBox("ScreenLocker " + My.Application.Info.Version.ToString + " by Eri/Noxyntious" + Environment.NewLine + "Licensed under MIT") End Sub - Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click + Private Sub Button1_Click(sender As Object, e As EventArgs) Handles LockButton.Click If TextBox1.TextLength = 0 Then MsgBox("Set a password first!") ElseIf TextBox1.Text = TextBox2.Text Then If Times = 0 Then - MsgBox("Not a good idea to set the message as the password." + Environment.NewLine + "If you really want to, though, click the Lock button again.") + MsgBox("Not a good idea to set the message as the password." + vbNewLine + "If you really want to though, click the Lock button again.") Times = 1 Else GoTo Lock End If diff --git a/ScreenLocker/My Project/Application.Designer.vb b/ScreenLocker/My Project/Application.Designer.vb index 2a9cfaf..338cc54 100644 --- a/ScreenLocker/My Project/Application.Designer.vb +++ b/ScreenLocker/My Project/Application.Designer.vb @@ -13,15 +13,15 @@ Option Explicit On Namespace My - + 'NOTE: This file is auto-generated; do not modify it directly. To make changes, ' or if you encounter build errors in this file, go to the Project Designer ' (go to Project Properties or double-click the My Project node in ' Solution Explorer), and make changes on the Application tab. ' Partial Friend Class MyApplication - - _ + + _ Public Sub New() MyBase.New(Global.Microsoft.VisualBasic.ApplicationServices.AuthenticationMode.Windows) Me.IsSingleInstance = false @@ -29,10 +29,10 @@ Namespace My Me.SaveMySettingsOnExit = true Me.ShutDownStyle = Global.Microsoft.VisualBasic.ApplicationServices.ShutdownMode.AfterMainFormCloses End Sub - - _ + + _ Protected Overrides Sub OnCreateMainForm() - Me.MainForm = Global.ScreenLocker.Form1 + Me.MainForm = Global.ScreenLocker.Main End Sub End Class End Namespace diff --git a/ScreenLocker/My Project/Application.myapp b/ScreenLocker/My Project/Application.myapp index 1243847..db2c607 100644 --- a/ScreenLocker/My Project/Application.myapp +++ b/ScreenLocker/My Project/Application.myapp @@ -1,11 +1,10 @@  true - Form1 + Main false 0 true 0 - 0 true - + \ No newline at end of file diff --git a/ScreenLocker/My Project/AssemblyInfo.vb b/ScreenLocker/My Project/AssemblyInfo.vb index 97bfaea..238d7ea 100644 --- a/ScreenLocker/My Project/AssemblyInfo.vb +++ b/ScreenLocker/My Project/AssemblyInfo.vb @@ -9,10 +9,10 @@ Imports System.Runtime.InteropServices ' Review the values of the assembly attributes - - + + - + @@ -31,5 +31,5 @@ Imports System.Runtime.InteropServices ' by using the '*' as shown below: ' - - + + diff --git a/ScreenLocker/ScreenLocker.vbproj b/ScreenLocker/ScreenLocker.vbproj index a0b216b..c2a1f4b 100644 --- a/ScreenLocker/ScreenLocker.vbproj +++ b/ScreenLocker/ScreenLocker.vbproj @@ -101,11 +101,11 @@ Form - + Form - - Form1.vb + + Main.vb Form @@ -134,8 +134,8 @@ Backdrop.vb - - Form1.vb + + Main.vb LockUI.vb