Click to See Complete Forum and Search --> : Finding the Location of a Control???
stever2003
Mar 8th, 2001, 07:28 PM
I need a code to find the location (in PIXELS) of the top left corner of a control. The control is a picture box named picMControl and only the location of the top left corner is important to me. Thanks for your help!!!
YoungBuck
Mar 8th, 2001, 11:59 PM
If you want the location of the PictureBox within a form just use the PicBox.Left and PicBox.Top properties.
If you want the location of the PictureBox on the screen use the GetWindowRect function....
Private Declare Function GetWindowRect Lib "user32" (ByVal hwnd As Long, lpRect As RECT) As Long
Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Private Sub Form_Load()
Dim rct As RECT
If Not GetWindowRect(Picture1.hwnd, rct) = 0 Then
MsgBox "The Left-Top corner of this Control/Window is located at x=" & rct.Left & " y=" & rct.Top
Else
MsgBox "Could Not retrieve the coordinates of the Control/Window"
End If
End Sub
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.