Responding to Moving or Sizing the Container

The OLE container control has the ObjectMove event, which is triggered when the object associated with the OLE container control is moved or resized. The arguments to ObjectMove represent the coordinates of the object (excluding its border) within the object's container. If the object is moved off the form, the arguments have values representing the position relative to the upper-left corner of the form. These can be positive or negative. If the Width or Height of the ActiveX component is changed, the OLE container control is notified.

The ObjectMove event is the only way the OLE container control can determine if the object has been moved or resized. An ObjectMove event occurs when the user moves or resizes the object contained in the OLE container control. For example:

Private Sub oleObj1_ObjectMove(Left As Single, Top As _
   Single, Width As Single, Height As Single)
   ' This method resizes the OLE container control to
   ' the new object size.
   oleObj1.Move oleObj1.Left, oleObj1.Top, _
      Width, Height
   ' This method moves the OLE container control
   ' to the new object position.
   oleObj1.Move Left, Top, _
      oleObj1.Width, oleObj1.Height
' Repaints the form.
   Me.Refresh
End Sub