Control Position

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Nathan Carroll

    Control Position

    I would like to know how to prevent a control from entering the space
    occupied of another control. I've got my mousedown,up and move procedure
    working correctly.


  • EricJ

    #2
    Re: Control Position

    are you talking about drag and drop or about resizing a form?

    "Nathan Carroll" <thelosthorizon @Bhutan.com> wrote in message
    news:OAlOmQwnDH A.1408@TK2MSFTN GP11.phx.gbl...[color=blue]
    > I would like to know how to prevent a control from entering the space
    > occupied of another control. I've got my mousedown,up and move procedure
    > working correctly.
    >
    >[/color]


    Comment

    • Herfried K. Wagner [MVP]

      #3
      Re: Control Position

      * "Nathan Carroll" <thelosthorizon @Bhutan.com> scripsit:[color=blue]
      > I would like to know how to prevent a control from entering the space
      > occupied of another control. I've got my mousedown,up and move procedure
      > working correctly.[/color]

      Do you move controls? How does a control enter space occupied by an
      other control?

      --
      Herfried K. Wagner
      MVP · VB Classic, VB.NET
      <http://www.mvps.org/dotnet>

      Improve your quoting style:
      <http://learn.to/quote>
      <http://www.plig.net/nnq/nquote.html>

      Comment

      • Armin Zingler

        #4
        Re: Control Position

        "Nathan Carroll" <thelosthorizon @Bhutan.com> schrieb[color=blue]
        > I would like to know how to prevent a control from entering the
        > space occupied of another control. I've got my mousedown,up and move
        > procedure working correctly.[/color]

        Sorry, I don't understand the question. How does a control "enter" the
        space? What do you do in these events?


        --
        Armin

        Dieser Text beschreibt allgemeine Zitiergewohnheiten im Usenet. Die dabei gemachten Aeusserungen und Erlaeuterungen basieren dabei auf Erfahrungen des Autors. Wie zitiert man im Usenet? Zitieren lernen!



        Comment

        • Nathan Carroll

          #5
          Re: Control Position

          button1 is dragged across screen comes into contact with a button2. I want
          to prevent button1 from entering space occuped by button2.


          "Herfried K. Wagner [MVP]" <hirf-spam-me-here@gmx.at> wrote in message
          news:bnrfhu$150 c26$6@ID-208219.news.uni-berlin.de...[color=blue]
          > * "Nathan Carroll" <thelosthorizon @Bhutan.com> scripsit:[color=green]
          > > I would like to know how to prevent a control from entering the space
          > > occupied of another control. I've got my mousedown,up and move[/color][/color]
          procedure[color=blue][color=green]
          > > working correctly.[/color]
          >
          > Do you move controls? How does a control enter space occupied by an
          > other control?
          >
          > --
          > Herfried K. Wagner
          > MVP · VB Classic, VB.NET
          > <http://www.mvps.org/dotnet>
          >
          > Improve your quoting style:
          > <http://learn.to/quote>
          > <http://www.plig.net/nnq/nquote.html>[/color]


          Comment

          • Armin Zingler

            #6
            Re: Control Position

            "Nathan Carroll" <thelosthorizon @Bhutan.com> schrieb[color=blue]
            > button1 is dragged across screen comes into contact with a button2.
            > I want to prevent button1 from entering space occuped by button2.[/color]

            Where? In the Forms designer?


            --
            Armin

            Dieser Text beschreibt allgemeine Zitiergewohnheiten im Usenet. Die dabei gemachten Aeusserungen und Erlaeuterungen basieren dabei auf Erfahrungen des Autors. Wie zitiert man im Usenet? Zitieren lernen!



            Comment

            • Fergus Cooney

              #7
              Re: Control Position

              Hi Nathan,

              You'll have to check the Location of the Control that you are dragging
              against the Locations of all the other Controls on the Form.

              Do you have Controls within other Controls, such as inside a Panel or
              TabbedPages?

              Regards,
              Fergus


              Comment

              • Fergus Cooney

                #8
                Re: Control Position

                Hi Nathan,

                The following code was posted a while back. It does collision detection on
                Controls.

                To use it simply call it with a pair of Controls:

                If ControlsOverlap (picBullet, picTarget) Then
                MsgBox ("Target Destroyed!!")
                End If

                Regards,
                Fergus

                <code>
                '--------------------------------------------------------------
                'The Controls given as parameters are assumed to occupy rectangles
                'as determined by .Top, .Left, .Height, and .Width properties.
                'Returns True if, and only if, the rectangles occupied by the
                'Controls overlap.
                '
                Function ControlsOverlap (c1 As Control, c2 As Control) As Boolean
                Return IntervalsOverla p (c1.Top, c1.Top + c1.Height, _
                c2.Top, c2.Top + c2.Height) _
                And IntervalsOverla p (c1.Left, c1.Left + c1.Width, _
                c2.Left, c2.Left + c2.Width)
                End Function

                '--------------------------------------------------------------
                'An interval is a straight line. This function returns
                'True if, and only if, intervals [a, b] and [x, y] intersect
                '
                Function IntervalsOverla p (a As Single, b As Single, _
                x as Single, y As Single) As Boolean
                Return WithinInterval (a, x, y) _
                Or WithinInterval (b, x, y) _
                Or WithinInterval (x, a, b) _
                Or WithinInterval (y, a, b)
                End Function

                '--------------------------------------------------------------
                'True if, and only if, x is within the interval [a, b]
                '
                Function WithinInterval (x As Single, _
                a As Single, b As Single) As Boolean
                Return (a <= x) And (x <= b)
                End Function
                </code>


                Comment

                • Nathan Carroll

                  #9
                  Re: Control Position

                  Exactly thanks Fergus.


                  "Fergus Cooney" <filter1@post.c om> wrote in message
                  news:ecLQHfxnDH A.2080@TK2MSFTN GP10.phx.gbl...[color=blue]
                  > Hi Nathan,
                  >
                  > The following code was posted a while back. It does collision[/color]
                  detection on[color=blue]
                  > Controls.
                  >
                  > To use it simply call it with a pair of Controls:
                  >
                  > If ControlsOverlap (picBullet, picTarget) Then
                  > MsgBox ("Target Destroyed!!")
                  > End If
                  >
                  > Regards,
                  > Fergus
                  >
                  > <code>
                  > '--------------------------------------------------------------
                  > 'The Controls given as parameters are assumed to occupy rectangles
                  > 'as determined by .Top, .Left, .Height, and .Width properties.
                  > 'Returns True if, and only if, the rectangles occupied by the
                  > 'Controls overlap.
                  > '
                  > Function ControlsOverlap (c1 As Control, c2 As Control) As Boolean
                  > Return IntervalsOverla p (c1.Top, c1.Top + c1.Height, _
                  > c2.Top, c2.Top + c2.Height) _
                  > And IntervalsOverla p (c1.Left, c1.Left + c1.Width, _
                  > c2.Left, c2.Left + c2.Width)
                  > End Function
                  >
                  > '--------------------------------------------------------------
                  > 'An interval is a straight line. This function returns
                  > 'True if, and only if, intervals [a, b] and [x, y] intersect
                  > '
                  > Function IntervalsOverla p (a As Single, b As Single, _
                  > x as Single, y As Single) As Boolean
                  > Return WithinInterval (a, x, y) _
                  > Or WithinInterval (b, x, y) _
                  > Or WithinInterval (x, a, b) _
                  > Or WithinInterval (y, a, b)
                  > End Function
                  >
                  > '--------------------------------------------------------------
                  > 'True if, and only if, x is within the interval [a, b]
                  > '
                  > Function WithinInterval (x As Single, _
                  > a As Single, b As Single) As Boolean
                  > Return (a <= x) And (x <= b)
                  > End Function
                  > </code>
                  >
                  >[/color]


                  Comment

                  Working...