Software Developer's Kit - ChemDraw

Send comments on this topic
PtInRect Method
See Also 
newVal
newVal is a point

Description

Member of ChemDraw Control.Rect.

Indicates whether a specified point is within this rectangle.

Syntax

Visual Basic
Public Function PtInRect( _
   ByVal newVal As Point _
) As Boolean

Parameters

newVal
newVal is a point

Return Type

Boolean

Remarks

The expression (myRect.PtInRect(myPoint)) will return True: if myPoint is within the boundaries of myRect. Otherwise it will return False.

Example

'Declares the variables
 Dim myObject As ChemDrawControl10Ctl.Object
 Dim vObject As ChemDrawControl10Ctl.Object  
 Dim myRect As ChemDrawControl10Ctl.Rect 
 Dim myPoint As ChemDrawControl10Ctl.Point
'Checks that there is an object loaded in the variable 
 Private Sub ctlChemDraw_SelectionChanged(ByVal selection As _
        ChemDrawControl10Ctl.IChemDrawSelection)
   'Verifies what has been selected
    If  Selection.Objects.Count < 1 Then
        Exit Sub 'exits if there is nothing selected 
    End If

   'Works with two objects (reads bounds from one, and position from the other one)
    Dim i As Integer
    i = 0 
    For Each myObject In Selection.Objects
    If  myObject.Selected = True Then
            Set vObject = myObject
            If  i = 0 Then
                Set vObject1 = ChemDrawControl10Ctl.ActiveDocument.Selection.Objects.Item(1) 
            End If
            If  i = 1 Then
                Set vObject2 = ChemDrawControl10Ctl.ActiveDocument.Selection.Objects.Item(2)
            End If
            i = i + 1
        End If
    Next
End Sub

Private Sub cmdPtInRect_Click()   
   'Example of Rect.PtInRect
    Set myRect = vObject1.Bounds 
    Set myPoint = vObject2.Position    
   'Checks if the position point of Object2 is within the rectangle bounding Object1
    Text1.text = Rect1.PtInRect(myPoint)
End Sub 
            

See Also