Text Box Dragging-VBForums
Results 1 to 12 of 12

Thread: Text Box Dragging

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Dec 2011
    Posts
    346

    Text Box Dragging

    Ihave this code so when you press a button it generates a text box
    Code:
       Dim txt As New TextBox
            txt.AllowDrop = True
            txt.Multiline = True
            Me.Controls.Add(txt)
    But i wanted to ad vb script to the text box what property would i do that with?
    Last edited by sherlockturtle; Mar 2nd, 2012 at 06:14 PM.

  2. #2
    vb Coda .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    19,070

    Re: Text Box Dragging

    i don't understand the question...
    can you explain exactly what you're trying to do?

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Dec 2011
    Posts
    346

    Re: Text Box Dragging

    I have a button that creates a text box but i want it to create a drag gable text box. How would id do that?

  4. #4

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Dec 2011
    Posts
    346

    Re: Text Box Dragging

    My visual basic 2010 was not abel to open it.

  6. #6
    vb Coda .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    19,070

    Re: Text Box Dragging

    why not? what was the error?

  7. #7

    Thread Starter
    Hyperactive Member
    Join Date
    Dec 2011
    Posts
    346

    Re: Text Box Dragging

    It just said it was not abel to read it.

  8. #8
    vb Coda .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    19,070

    Re: Text Box Dragging

    the 3 different versions have been downloaded 435 times in total + you're the first who can't open it

  9. #9
    vb Coda .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    19,070

    Re: Text Box Dragging

    ok. different method:

    vb Code:
    1. Public Class Form1
    2.  
    3.     Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    4.         Dim tb As New TextBox
    5.         Me.Controls.Add(tb)
    6.         AddHandler tb.MouseMove, AddressOf tb_MouseMove
    7.     End Sub
    8.  
    9.     Private Const WM_NCLBUTTONDOWN As Integer = &HA1
    10.     Private Const HTCAPTION As Integer = 2
    11.  
    12.     Private Sub tb_MouseMove(ByVal sender As System.Object, ByVal e As MouseEventArgs)
    13.         Dim tb As TextBox = DirectCast(sender, TextBox)
    14.         tb.Capture = False
    15.         Dim m As Message = Message.Create(tb.Handle, WM_NCLBUTTONDOWN, New IntPtr(HTCAPTION), IntPtr.Zero)
    16.         MyBase.DefWndProc(m)
    17.     End Sub
    18.  
    19. End Class

  10. #10

    Thread Starter
    Hyperactive Member
    Join Date
    Dec 2011
    Posts
    346

    Re: Text Box Dragging

    Quote Originally Posted by .paul. View Post
    ok. different method:

    vb Code:
    1. Public Class Form1
    2.  
    3.     Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    4.         Dim tb As New TextBox
    5.         Me.Controls.Add(tb)
    6.         AddHandler tb.MouseMove, AddressOf tb_MouseMove
    7.     End Sub
    8.  
    9.     Private Const WM_NCLBUTTONDOWN As Integer = &HA1
    10.     Private Const HTCAPTION As Integer = 2
    11.  
    12.     Private Sub tb_MouseMove(ByVal sender As System.Object, ByVal e As MouseEventArgs)
    13.         Dim tb As TextBox = DirectCast(sender, TextBox)
    14.         tb.Capture = False
    15.         Dim m As Message = Message.Create(tb.Handle, WM_NCLBUTTONDOWN, New IntPtr(HTCAPTION), IntPtr.Zero)
    16.         MyBase.DefWndProc(m)
    17.     End Sub
    18.  
    19. End Class
    Thanks Dude

  11. #11

    Thread Starter
    Hyperactive Member
    Join Date
    Dec 2011
    Posts
    346

    Re: Text Box Dragging

    I also tried doing it with a rich text box but it is not moving
    Code:
          Private Sub ToolStripButton3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton3.Click
            Dim tb1 As New RichTextBox
            Me.Controls.Add(tb1)
            AddHandler tb1.MouseMove, AddressOf tb1_MouseMove
        End Sub
    
        Private Const WM_NCLBUTTONDOWN1 As Integer = &HA1
        Private Const HTCAPTION1 As Integer = 21
    
        Private Sub tb1_MouseMove(ByVal sender As System.Object, ByVal e As MouseEventArgs)
            Dim tb1 As RichTextBox = DirectCast(sender, RichTextBox)
            tb1.Capture = False
            Dim m1 As Message = Message.Create(tb1.Handle, WM_NCLBUTTONDOWN1, New IntPtr(HTCAPTION1), IntPtr.Zero)
            MyBase.DefWndProc(m1)
    
    
    
    
        End Sub

  12. #12
    vb Coda .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    19,070

    Re: Text Box Dragging

    HTCAPTION1 should be 2, not 21

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width

Survey posted by VBForums.