Results 1 to 12 of 12

Thread: [RESOLVED] could any one say,"how to drag and drop a line in v.b 6.0"

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    May 2007
    Posts
    167

    Resolved [RESOLVED] could any one say,"how to drag and drop a line in v.b 6.0"

    Hi All,

    in my application i am able to drag and drop few controls successfully at run time,..except "Line".

    I have created a control array (Line1(o)) for line. and in form's dragdrop event i am loading the new line(Line1(1)) and setting it's co-ordinated y1,y2 to form's x,y co-ordinates.

    but here i am uable to drag and drop it.since the form's dragdrop event is not working for line. and there is no such event to line. how can i achieve it? there is no drag mode property to LIne1....

    If u know this. please let me know how to do it.

    Thanks:
    regards:
    raghunadhs.
    Last edited by raghunadhs; Aug 17th, 2007 at 12:43 PM. Reason: for more clarity

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: could any one say,"how to drag and drop a line in v.b 6.0"

    I don't believe you can. It doesn't even have a Move method.

  3. #3
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    Re: could any one say,"how to drag and drop a line in v.b 6.0"

    put the line on a picture box..... move the picture box.

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    May 2007
    Posts
    167

    Re: could any one say,"how to drag and drop a line in v.b 6.0"

    Thanks Hack AND techgnome,
    I will follow your suggestion....
    regards:
    raghunahds
    Quote Originally Posted by techgnome
    put the line on a picture box..... move the picture box.

    -tg

  5. #5
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: could any one say,"how to drag and drop a line in v.b 6.0"

    How did this work out? I'm curious.

  6. #6
    Frenzied Member TheBigB's Avatar
    Join Date
    Mar 2006
    Location
    *Stack Trace*
    Posts
    1,511

    Re: could any one say,"how to drag and drop a line in v.b 6.0"

    I understand you can move it in 4 directions, but I don't think changing the angle is possible
    Delete it. They just clutter threads anyway.

  7. #7

    Thread Starter
    Addicted Member
    Join Date
    May 2007
    Posts
    167

    Re: could any one say,"how to drag and drop a line in v.b 6.0"

    Hi BigB,
    Hi hack, i am happy, that u r interested to see my result....


    sorry for the delay, as per our friends' suggesion, i put that on a image.. (since, suppose if want to resize the image, it will be possible). And by using form's drag drop, and image's drag over method, i am making it stretch.but now i am able to stretch it in one direction only... for another direction it is not possible...and another thing, streching is possible(i did it in form's drag over) but decreasing its length is in quite rude method(here suppose if i am decreasing its length, by putting the mouse pointer at the head of image, and try to decrease its length, it is coming under image's drag over method, and the co-ordinates are not so comfortable that fit on the form)
    if u would like to see my code and provide any suggestions, it will be pleaseure for me.
    Thanks:
    regards:
    raghunahds

    Quote Originally Posted by Hack
    How did this work out? I'm curious.


    Quote Originally Posted by TheBigB
    I understand you can move it in 4 directions, but I don't think changing the angle is possible

  8. #8
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    Re: could any one say,"how to drag and drop a line in v.b 6.0"

    Maybe you can explain what it is you are trying to accomplish..... bad form on my part, but I thought maybe you were trying to implement a splitter bar, similar to the split that's between the treeview and listview in File Explorer....

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  9. #9

    Thread Starter
    Addicted Member
    Join Date
    May 2007
    Posts
    167

    Re: could any one say,"how to drag and drop a line in v.b 6.0"

    Hi tech,
    sorry to say, that i could not get your point..
    Thanks:
    regards:
    raghunadhs
    Last edited by raghunadhs; Aug 21st, 2007 at 12:40 PM. Reason: thread redundantly posted

  10. #10
    PowerPoster RhinoBull's Avatar
    Join Date
    Mar 2004
    Location
    New Amsterdam
    Posts
    24,132

    Re: could any one say,"how to drag and drop a line in v.b 6.0"

    Here is a quick sample that I came up with - it's not perfect so if anyone is upto the challenge then go ahead and make it better.

    To run this sample you will need a Timer control and Line control.
    Code:
    Option Explicit
    
    Private Type RECT
        Left As Long
        Top As Long
        Right As Long
        Bottom As Long
    End Type
    
    Private Type POINTAPI
        X As Long
        Y As Long
    End Type
    
    Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
    
    Dim blnDragBegin As Boolean
    Dim OffsetX As Single
    Dim OffsetY As Single
    
    Private Sub Form_Load()
        Line1.BorderWidth = 5 'so you can see it better :)
        Timer1.Interval = 100
        Timer1.Enabled = True
    End Sub
    
    Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
        blnDragBegin = False
        If Screen.MousePointer = VBRUN.MousePointerConstants.vbSizeAll Then
            OffsetX = X
            OffsetY = Y
            blnDragBegin = True
        End If
    End Sub
    
    Private Sub Form_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
        If blnDragBegin Then
            With Line1
                
                'variations of (X - OffsetX) and (OffsetX - X) as well as Ys
                'for X1/2 and/or Y1/2 will give you very interesting results
                
                .X1 = .X1 + (X - OffsetX)
                .X2 = .X2 + (X - OffsetX)
                .Y1 = .Y1 + (Y - OffsetY)
                .Y2 = .Y2 + (Y - OffsetY)
            End With
            blnDragBegin = False
        End If
    End Sub
    
    Private Sub Timer1_Timer()
    Dim rct As RECT
    Dim pt As POINTAPI
    
        If blnDragBegin Then Exit Sub
        Screen.MousePointer = VBRUN.MousePointerConstants.vbDefault
        
        rct = GetLineRect(Me, Line1)
        
        GetCursorPos pt
        
        If (pt.X >= rct.Left And pt.X <= rct.Right) And (pt.Y >= rct.Top And pt.Y <= rct.Bottom) Then
            Screen.MousePointer = VBRUN.MousePointerConstants.vbSizeAll
        End If
    
    End Sub
    
    Private Function GetLineRect(frm As Form, myLine As Line) As RECT
    Dim rct As RECT
    Dim leftOffset As Long
    Dim topOffset As Long
    
        leftOffset = (frm.Left + Me.ScaleLeft) / Screen.TwipsPerPixelX
        topOffset = (frm.Top + Me.ScaleTop) / Screen.TwipsPerPixelY
        
        If myLine.X1 <= myLine.X2 Then
            rct.Left = leftOffset + myLine.X1 / Screen.TwipsPerPixelX
            rct.Right = leftOffset + myLine.X2 / Screen.TwipsPerPixelX
        Else
            rct.Left = leftOffset + myLine.X2 / Screen.TwipsPerPixelX
            rct.Right = leftOffset + myLine.X1 / Screen.TwipsPerPixelX
        End If
        
        If myLine.Y1 <= myLine.Y2 Then
            rct.Top = topOffset + Line1.Y1 / Screen.TwipsPerPixelY
            rct.Bottom = topOffset + Line1.Y2 / Screen.TwipsPerPixelY
        Else
            rct.Top = topOffset + Line1.Y2 / Screen.TwipsPerPixelY
            rct.Bottom = topOffset + Line1.Y1 / Screen.TwipsPerPixelY
        End If
        
        GetLineRect = rct
    
    End Function

  11. #11

    Thread Starter
    Addicted Member
    Join Date
    May 2007
    Posts
    167

    Re: could any one say,"how to drag and drop a line in v.b 6.0"

    Hi RhinoBull,
    Thanks for your response... i will see u r sample application.. and will let u know the feed back...
    Thanks:
    regards:
    raghunadhs
    [QUOTE=RhinoBull]Here is a quick sample that I came up with - it's not perfect so if anyone is upto the challenge then go ahead and make it better.

    To run this sample you will need a Timer control and Line control.
    [code]
    Option Explicit

  12. #12

Posting Permissions

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



Click Here to Expand Forum to Full Width