how can i make my own control fro text and can be s

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • haytham2008
    New Member
    • Jun 2008
    • 14

    how can i make my own control fro text and can be s

    hi everybody
    i need help to make special control that will contain text
    and can be resizable and move by mouse

    like the how we do in visual studio when we are programing
    :$



    how can i do one like it,
    or if there is exist one

    thanx in advanced
  • OuTCasT
    Contributor
    • Jan 2008
    • 374

    #2
    This is how you move the control around on the form. just changed the btnMove to the name of the control that you want to be able to move.

    Code:
    Inherits System.Windows.Forms.Form
        Public Dragging As Boolean
        Public mousex, mousey As Integer
    
    Private Sub btnMove_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles btnMove.MouseDown
            If e.Button = MouseButtons.Left Then
                Dragging = True
                mousex = -e.X
                mousey = -e.Y
                Dim clipleft As Integer = Me.PointToClient(MousePosition).X - btnMove.Location.X
                Dim cliptop As Integer = Me.PointToClient(MousePosition).Y - btnMove.Location.Y
                Dim clipwidth As Integer = Me.ClientSize.Width - (btnMove.Width - clipleft)
                Dim clipheight As Integer = Me.ClientSize.Height - (btnMove.Height - cliptop)
                Cursor.Clip = Me.RectangleToScreen(New Rectangle(clipleft, cliptop, clipwidth, clipheight))
                btnMove.Invalidate()
            End If
        End Sub
    
        Private Sub btnMove_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles btnMove.MouseMove
            If Dragging Then
                'move control to new position
                Dim MPosition As New Point()
                MPosition = Me.PointToClient(MousePosition)
                MPosition.Offset(mousex, mousey)
                'ensure control cannot leave container
                btnMove.Location = MPosition
            End If
        End Sub
    
        Private Sub btnMove_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles btnMove.MouseUp
            If Dragging Then
                'end the dragging
                Dragging = False
                'Me.Capture = False
                Cursor.Clip = Nothing
                btnMove.Invalidate()
            End If
        End Sub

    Comment

    • haytham2008
      New Member
      • Jun 2008
      • 14

      #3
      Originally posted by OuTCasT
      This is how you move the control around on the form. just changed the btnMove to the name of the control that you want to be able to move.

      Code:
      Inherits System.Windows.Forms.Form
          Public Dragging As Boolean
          Public mousex, mousey As Integer
      
      Private Sub btnMove_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles btnMove.MouseDown
              If e.Button = MouseButtons.Left Then
                  Dragging = True
                  mousex = -e.X
                  mousey = -e.Y
                  Dim clipleft As Integer = Me.PointToClient(MousePosition).X - btnMove.Location.X
                  Dim cliptop As Integer = Me.PointToClient(MousePosition).Y - btnMove.Location.Y
                  Dim clipwidth As Integer = Me.ClientSize.Width - (btnMove.Width - clipleft)
                  Dim clipheight As Integer = Me.ClientSize.Height - (btnMove.Height - cliptop)
                  Cursor.Clip = Me.RectangleToScreen(New Rectangle(clipleft, cliptop, clipwidth, clipheight))
                  btnMove.Invalidate()
              End If
          End Sub
      
          Private Sub btnMove_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles btnMove.MouseMove
              If Dragging Then
                  'move control to new position
                  Dim MPosition As New Point()
                  MPosition = Me.PointToClient(MousePosition)
                  MPosition.Offset(mousex, mousey)
                  'ensure control cannot leave container
                  btnMove.Location = MPosition
              End If
          End Sub
      
          Private Sub btnMove_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles btnMove.MouseUp
              If Dragging Then
                  'end the dragging
                  Dragging = False
                  'Me.Capture = False
                  Cursor.Clip = Nothing
                  btnMove.Invalidate()
              End If
          End Sub
      i dont mean to move element i can do it using drag and drop
      but i need special kind of control to use it as text box to insert text inside it and that box can be moved and resize :$

      thank u for ur answer i appreciate that :)

      Comment

      • joedeene
        Contributor
        • Jul 2008
        • 579

        #4
        i believe user controls are resizable in the designer view on visual studio?

        joedeene

        Comment

        • haytham2008
          New Member
          • Jun 2008
          • 14

          #5
          Originally posted by joedeene
          i believe user controls are resizable in the designer view on visual studio?

          joedeene
          u are right
          i need control to be resizable also when my program running :$
          not only in the designer view :)

          thank u joedeene
          :)

          plz help me :$

          Comment

          • Curtis Rutland
            Recognized Expert Specialist
            • Apr 2008
            • 3264

            #6
            Well, build on what you know. Now that you know how to move a control, instead of changing the position, change the size.

            Comment

            • haytham2008
              New Member
              • Jun 2008
              • 14

              #7
              Originally posted by insertAlias
              Well, build on what you know. Now that you know how to move a control, instead of changing the position, change the size.
              mmmm
              i know how can i resize it using code
              but i need to do using mouse ...

              i hope what i mean is clear
              :$

              thank u nsertAlias :)

              Comment

              • joedeene
                Contributor
                • Jul 2008
                • 579

                #8
                Originally posted by haytham2008
                mmmm
                i know how can i resize it using code
                but i need to do using mouse ...

                i hope what i mean is clear
                :$

                thank u nsertAlias :)
                ok bud, now that, i think, i get what you're trying to accomplish perhaps a link like THIS ONE, and just a simple google search such as "how to make resizable controls at runtime", thats how i found the link. well ok.. let me know if thats what you were looking for...

                joedeene

                Comment

                • Curtis Rutland
                  Recognized Expert Specialist
                  • Apr 2008
                  • 3264

                  #9
                  You will have to use code to do the resizing. But you can adapt the code for dragging a control into code for resizing. You have to change size instead of location.

                  Comment

                  • haytham2008
                    New Member
                    • Jun 2008
                    • 14

                    #10
                    Originally posted by joedeene
                    ok bud, now that, i think, i get what you're trying to accomplish perhaps a link like THIS ONE, and just a simple google search such as "how to make resizable controls at runtime", thats how i found the link. well ok.. let me know if thats what you were looking for...

                    joedeene

                    yes
                    .....that what i want :)
                    but instead of picture i need text-box...and i need it in c#

                    than u very much

                    Comment

                    • joedeene
                      Contributor
                      • Jul 2008
                      • 579

                      #11
                      Originally posted by haytham2008
                      yes
                      .....that what i want :)
                      but instead of picture i need text-box...and i need it in c#

                      than u very much
                      well, they say that code works for any code

                      picturebox named pbDemo in this example, but it could be any control),
                      And well, make an attempt to convert the code yourself, and when you run into stumbles, post the part you cannot convert and we will help you...

                      joedeene

                      Comment

                      Working...