Sub OnBeforeObjectChange(Sender: Object; Args: ITabObjectChangeEventArgs);
Begin
// Set of operators
End Sub OnBeforeObjectChange;
Sender. The component that generated an event.
Args. Parameters of the object, in which an event occurred.
The OnBeforeObjectChange event occurs before changing an object.
Object parameters can be cast to various interfaces depending on the type of change on an object. To do this, use value of the ITabObjectChangeEventArgs.Type property returned by the Args parameter:
TabObjectChangeType.Angle. An object is rotated. To get rotation parameters, cast value of the Args parameter to the ITabBeforeObjectAngleChangeEventArgs interface.
TabObjectChangeType.Rect. An object is moved or resized. To get move or resize parameters, cast value of the Args parameter to the ITabBeforeObjectRectChangeEventArgs interface.
After an object is changed, the OnAfterObjectChange event occurs.
Executing the example requires a form containing the components:
TabSheetBox with the TabSheetBox1 identifier.
UiReport with the UiReport1 identifier that is a data source for TabSheetBox1. UiReport1 must also be active and contain a loaded regular report with shapes on an active sheet.
The specified procedure must be assigned by handler of the OnAfterObjectChange event for the TabSheetBox1 component.
Sub TabSheetBox1OnBeforeObjectChange(Sender: Object; Args: ITabObjectChangeEventArgs);
Var
Rect: ITabBeforeObjectRectChangeEventArgs;
Angle: ITabBeforeObjectAngleChangeEventArgs;
RectPos: IGxRectF;
Begin
Select Case Args.Type
// If object is rotated more than 90 degrees, cancel rotation
Case TabObjectChangeType.Angle:
Angle := Args As ITabBeforeObjectAngleChangeEventArgs;
If Angle.NewValue > 90 Then
Angle.Cancel := True;
End If;
// If object's bottom border is moved lower than 100 pixels, cancel moving
Case TabObjectChangeType.Rect:
Rect := Args As ITabBeforeObjectRectChangeEventArgs;
RectPos := Rect.NewValue;
If RectPos.Bottom > 100 Then
Rect.Cancel := True;
End If;
End Select;
End Sub TabSheetBox1OnBeforeObjectChange;
After executing the example rotation more than 90 degrees and moving of the bottom border lower than 100 pixels is canceled for all the shapes on the sheet .
See also: