[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.
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.
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
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
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.
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
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
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
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
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
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
Re: could any one say,"how to drag and drop a line in v.b 6.0"
Quote:
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.