|
-
Aug 17th, 2007, 12:41 PM
#1
Thread Starter
Addicted Member
[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
-
Aug 17th, 2007, 12:44 PM
#2
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.
-
Aug 17th, 2007, 12:59 PM
#3
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
-
Aug 20th, 2007, 03:19 AM
#4
Thread Starter
Addicted Member
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
 Originally Posted by techgnome
put the line on a picture box..... move the picture box.
-tg
-
Aug 21st, 2007, 07:38 AM
#5
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.
-
Aug 21st, 2007, 07:47 AM
#6
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.
-
Aug 21st, 2007, 11:50 AM
#7
Thread Starter
Addicted Member
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
 Originally Posted by Hack
How did this work out? I'm curious.
 Originally Posted by TheBigB
I understand you can move it in 4 directions, but I don't think changing the angle is possible
-
Aug 21st, 2007, 12:20 PM
#8
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
-
Aug 21st, 2007, 12:33 PM
#9
Thread Starter
Addicted Member
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
-
Aug 21st, 2007, 02:28 PM
#10
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
Last edited by RhinoBull; Aug 21st, 2007 at 02:32 PM.
-
Aug 22nd, 2007, 06:52 AM
#11
Thread Starter
Addicted Member
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
-
Aug 22nd, 2007, 08:12 AM
#12
Re: could any one say,"how to drag and drop a line in v.b 6.0"
 Originally Posted by raghunadhs
Hi RhinoBull,
Thanks for your response... i will see u r sample application.. and will let u know the feed back...
OK, no problem.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|