Search Tools Links Login

[ Center Forms Without Errors When Maximized ]


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

Original Author: JamesJD

Inputs

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

Code

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

About this post

Posted: 2003-06-01
By: ArchiveBot
Viewed: 76 times

Categories

Visual Basic 6

Attachments

No attachments for this post


Loading Comments ...

Comments

No comments have been added for this post.

You must be logged in to make a comment.