Results 1 to 2 of 2

Thread: Finding the Location of a Control???

  1. #1

    Thread Starter
    Lively Member stever2003's Avatar
    Join Date
    Dec 2000
    Posts
    109

    Question

    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!!!

  2. #2
    Fanatic Member
    Join Date
    Sep 1999
    Location
    Bethel, North Carolina, USA
    Posts
    987
    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....


    Code:
    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
    {Insert random techno-babble here}

    {Insert quote from some long gone mofo here}

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width