Quote Originally Posted by zx81sp View Post
Hi Gilman

I've modded your code so it works with lines as in my previous post an also works with subforms embedded under controls. May be not a common use, but I have some apps that work in that way.

I've added a new propertie to oAnchor so you no can set form and container (optional):

Code:
        oAnchor.Form = Me
        oAnchor.container = frmMain.Contenedor
In this case all the controls of "Me" are referenced to frmMain.Contenedor size instead the size of "Me". I've attached your example plus two forms working in that way and also with a line.

The code probably could be optimized, may be I'll take a look later.

Anchor.V1.1.2 plus container.zip

EDITED: I've found more bugs in the original code so don't use this version, tomorrow I'll post a update.
You are free to modify the class as you wish, but in this case it would not be necessary, since all you need to do is resize the frmcargado after the call to the anchor method:
Code:
    
Private Sub Form_Resize()
    Static oAnchor As clsAnchor
    If Not oAnchor Is Nothing Then
    Else
        Set oAnchor = New clsAnchor
        oAnchor.Form = Me
    End If
    
    oAnchor.Anchor
    'If you need to resize something that is not correctly resized by the anchor class you can resize now.
    'In this case frmcargado is not a control, so resize it
    frmcargado.Move 0, 0, contenedor.Width, contenedor.Height
End Sub
However, it is necessary that the container has at least the same size as the form to be loaded, since otherwise, when reducing the initial form to its minimum size, the contained form would not be resized and a strange result would result.