Software Developer's Kit - ChemDraw

Send comments on this topic
IsWithin Method
See Also 
newVal
newVal is a ChemDrawControl rectangle

Description

Member of ChemDraw Control.Rect.

Indicates whether the second rectangle is completely within the first rectangle or not.

Syntax

Visual Basic
Public Function IsWithin( _
   ByVal newVal As Rect _
) As Boolean

Parameters

newVal
newVal is a ChemDrawControl rectangle

Return Type

Boolean

Remarks

This method only returns True when the second rectangle is completely within the first rectangle.

Example

'Declares the variables
 Dim myObject As ChemDrawControl10Ctl.Object
 
Dim vObject1 As ChemDrawControl10Ctl.Object  
 Dim vObject2 As ChemDrawControl10Ctl.Object 
 Dim Rect1 As ChemDrawControl10Ctl.Rect 
 Dim Rect2 As ChemDrawControl10Ctl.Rect
'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
     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 cmdIsWithin_Click()   
   'Example of Rect.IsWithin
    Set Rect1 = vObject1.Bounds
    Set Rect2 = vObject2.Bounds

    Text1.text = Rect1.IsWithin(Rect2)
End Sub 
 

See Also