2 Forms Advanced

Do you need something made? then ask in here.
Forum rules
Please LOCK your topics once you have found the solution to your question so we know you no longer require help with your query.
3 posts Page 1 of 1
Contributors
User avatar
frozerlaxegon
Top Poster
Top Poster
Posts: 84
Joined: Thu May 13, 2010 4:38 pm

2 Forms Advanced
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!
Last edited by frozerlaxegon on Wed Aug 18, 2010 10:41 am, edited 1 time in total.
You've been RICKROLL'D
User avatar
Harlem9191
Top Poster
Top Poster
Posts: 87
Joined: Mon Jan 18, 2010 8:45 pm

Re: 2 Forms Advanced
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
User avatar
frozerlaxegon
Top Poster
Top Poster
Posts: 84
Joined: Thu May 13, 2010 4:38 pm

Re: 2 Forms Advanced
frozerlaxegon
K
You've been RICKROLL'D
3 posts Page 1 of 1
Return to “Tutorial Requests”