Private Sub CenterWindow(ByVal intHandle As Long)
Dim iScreenHeight As Long
Dim iScreenWidth As Long
'## PROVIDES SCREEN SIZE IN PIXELS
iScreenWidth = Screen.PrimaryScreen.WorkingArea.Width
iScreenHeight = Screen.PrimaryScreen.WorkingArea.Height
Dim iFormHeight As Long
Dim iFormWidth As Long
Dim myRect As RECT
If GetWindowRect(intHandle, myRect) > 0 Then
If (myRect.Right - myRect.Left < My.Computer.Screen.WorkingArea.Width) Or (myRect.Bottom - myRect.Top < My.Computer.Screen.WorkingArea.Height) Then
iFormHeight = myRect.Left
iFormWidth = myRect.Top
End If
End If
'## Next, we need to find the x/y location of the upper right hand corner
Dim iTopLoc As Long
Dim iLeftLoc As Long
iLeftLoc = iFormWidth / 2
iTopLoc = iFormHeight / 2
End Sub
Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.
When asked, what has been your best career decision?
Deciding to stick with EE.
Being involved with EE helped me to grow personally and professionally.
Connect with Certified Experts to gain insight and support on specific technology challenges including:
We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE