Previous Document Next Document
ShapeRange.SetBoundingBox

Sub SetBoundingBox(x As Double, y As Double, Width As Double, Height As Double, [KeepAspect As Boolean = False], [ReferencePoint As cdrReferencePoint = cdrCenter])

Member of ShapeRange

The SetBoundingBox method moves and resizes the range so that it fits the specified bounding box.

See also the PositionX, PositionY, SizeWidth, and SizeHeight properties, as well as the GetPosition, SetPosition, GetSize, SetSize, SetSizeEx, and Move methods.

Parameters
Description
x
Sets the horizontal position of the center of the bounding box, in document units
y
Sets the vertical position of the center of the bounding box, in document units
Width
Sets the width of the bounding box, in document units
Height
Sets the height of the bounding box, in document units
KeepAspect
Maintains the proportions of the bounding box relative to its contents
This parameter is optional, and its default value is False.
ReferencePoint
Sets the reference point
This parameter is optional, and its default value is cdrCenter (9).

The following code example imports a specified file and places it inside the selected shape (or shapes), while maintaining proportions:

Sub Test() 
 Dim x As Double, y As Double, sx As Double, sy As Double 
 Dim FileName As String, sr As ShapeRange 
 If Documents.Count = 0 Then 
  MsgBox "No document is open", vbCritical 
  Exit Sub 
 End If 
 Set sr = ActiveSelectionRange 
 If sr.Count = 0 Then 
  MsgBox "No shapes selected", vbCritical 
  Exit Sub 
 End If 
 sr.GetBoundingBox x, y, sx, sy 
 FileName = CorelScriptTools.GetFileBox("All Files(*.*)|*.*", 
"Select a file to import") 
 If FileName <> "" Then 
  ActiveLayer.Import FileName 
  Set sr = ActiveSelectionRange 
  If sr.Count > 0 Then 
   sr.SetBoundingBox x, y, sx, sy, True 
  End If 
 End If 
End Sub 

Previous Document Next Document Back to Top

Copyright 2007 Corel Corporation. All rights reserved.