romiebehunin
asked on
Center another applications window using it's handle VB.NET
Hi experts...
Is there a way that I can center another applications child window using that windows handle?
Here's what I have written so far but not sure where to go from here:
Is there a way that I can center another applications child window using that windows handle?
Here's what I have written so far but not sure where to go from here:
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
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER