VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Center Forms Without Errors When Maximized

by JamesJD (11 Submissions)
Category: Custom Controls/Forms/Menus
Compatability: Visual Basic 5.0
Difficulty: Beginner
Date Added: Wed 3rd February 2021
Rating: (2 Votes)

This will center forms and when you maximize the form the Command Button which you click to re-center it will be disabled.

Inputs
You will need: One Command Button (you just need to keep there default names)

Rate Center Forms Without Errors When Maximized

Private Sub Command1_Click()
If Form1.WindowState = 0 Then
Form1.Left = Screen.Width / 2 - Form1.Width / 2
Form1.Top = Screen.Height / 2 - Form1.Height / 2
Else
Command1.Enabled = False
End If
End Sub
Private Sub Form_Load()
Form1.Left = Screen.Width / 2 - Form1.Width / 2
Form1.Top = Screen.Height / 2 - Form1.Height / 2
End Sub
Private Sub Form_Resize()
If Form1.WindowState = 2 Then
Command1.Enabled = False
Else
Command1.Enabled = True
End If
End Sub

Download this snippet    Add to My Saved Code

Center Forms Without Errors When Maximized Comments

No comments have been posted about Center Forms Without Errors When Maximized. Why not be the first to post a comment about Center Forms Without Errors When Maximized.

Post your comment

Subject:
Message:
0/1000 characters