Page 1 of 1

2 Forms Advanced

Posted: Sat Aug 14, 2010 5:12 pm
by frozerlaxegon
Hi, this is a problem encountered, this problem is not the same as asked by NowAyiN(Click)
The method doesn't work for me.
My ingredients :
1 Menu Item (Check on click = True)
7 Forms to dock
1 Snap-Window (A custom control that has a stronger magnetic force)
1 Master Form

Differences with CNS code :
I used Snap-Window instead of h-w-n-d
I used a custom code to determine where the form is
I have 7 forms to dock

My Snap-Window method works perfectly.
Now, my custom code to determine where the form is :
Code: Select all
Public Function IsLeftTo(ByVal you As Form, ByVal him As Form)
        If you.Left = him.Location.X - 214 Then
            If you.Top = him.Top Then
                Return True
            Else
                Return False
            End If
        End If
    End Function
    Public Function IsRightTo(ByVal you As Form, ByVal him As Form)
        If you.Left = him.Location.X + 218 Then
            If you.Top = him.Top Then
                Return True
            Else
                Return False
            End If
        End If
    End Function
    Public Function IsTopTo(ByVal you As Form, ByVal him As Form)
        If you.Top = him.Location.Y - 133 Then
            If you.Width = him.Width Then
                If you.Left = him.Left Then
                    Return True
                Else
                    Return False
                End If
            End If
        End If
    End Function
    Public Function IsBottomTo(ByVal you As Form, ByVal him As Form)
        If you.Top = him.Top + him.Height Then
            If you.Left = him.Left Then
                If you.Width = him.Width Then
                    Return True
                Else
                    Return False
                End If
            End If
        End If
    End Function
  Public Sub SetTop(ByVal you As Form, ByVal him As Form)
        you.Top = him.Location.Y - 133
        you.Width = him.Width
        you.Left = him.Left
    End Sub
    Public Sub SetBottom(ByVal you As Form, ByVal him As Form)
        you.Top = him.Top + him.Height
        you.Left = him.Left
        you.Width = him.Width
    End Sub
    Public Sub SetRight(ByVal you As Form, ByVal him As Form)
        you.Left = him.Location.X + 218
        you.Top = him.Top
    End Sub
    Public Sub setLeft(ByVal you As Form, ByVal him As Form)
        you.Left = him.Location.X - 214
        you.Top = him.Top
    End Sub
And my code to detect the form is docked :
Code: Select all
 Private Sub musicbox_Move(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Move
        If cs.IsTopTo(Playlist, Me) Then
            cs.SetTop(Playlist, Me)
        End If
    End Sub
Hypothesis : if first form is moved, second form that is docked will follow.
Status : Rejected

Someone please help me!

Re: 2 Forms Advanced

Posted: Mon Aug 16, 2010 5:50 pm
by Harlem9191
For starters you could clean it up a bit:

Public Function IsTopTo(ByVal you As Form, ByVal him As Form)
If you.Top = him.Location.Y - 133 And you.Width = him.Width And you.Left = him.Left Then
Return True
Else
Return False
End If
End Function

Second.. I think it might be this line that may be causing your problem: you.Top = him.Location.Y - 133

Re: 2 Forms Advanced

Posted: Tue Aug 17, 2010 11:46 am
by frozerlaxegon
K