|
-
Jul 29th, 2001, 07:53 AM
#1
Thread Starter
Hyperactive Member
getting the distance from the top left point and the lower left point of a rectange?
Hello,
How do i get the distance in pixels between the top left point and lower left point of a rectangle? What are all 4 points on a rectangle named? 0,0 1,1 or something?
Thanks for any help!
Visual Basic 6, HTML, JavaScript, learning C++
-
Jul 29th, 2001, 09:15 AM
#2
Addicted Member
To get the distance from top to bottom and left to right is very simple:
Distance from top to bottom = rectangle's height
Distance from left to right = rectangle's width
I don't quite follow your other question.
-
Jul 29th, 2001, 09:18 AM
#3
Addicted Member
BTW, if you wanted to get the distance from the top left vertex to the bottom right vertex of a rectangle, I think you would have to use Pythagoras' theory.
-
Jul 30th, 2001, 12:02 PM
#4
Use the Distance equation:
Code:
dist = sqrt(((x2-x1)^2) + ((y2-y1)^2))
Z.
-
Jul 31st, 2001, 05:28 AM
#5
PowerPoster
if the rectangle you mention is a form, then you can use the [color]GetClientrect[/color] API function call.
VB Code:
Option Explicit
'// WIN32API Function
Private Declare Function GetClientRect Lib "user32" (ByVal hwnd As Long, lpRect As RECT) As Long
'// WIN32API Structure
Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Private Sub Command1_Click()
Dim rc As RECT
GetClientRect Me.hwnd, rc
Debug.Print "(" & rc.Left & ", " & rc.Top & ") (" & rc.Right & "," & rc.Bottom & ")"
End Sub
regards,
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|