LineShape Control MouseMove Problem at runtime like a control movement.
-
Hi CodeProject , The problem is I am drawing a LineShape control from Microsoft PowerPacks controls .dll , I am also moving the line when MouseDown,MouseMove,MouseUp, But i am not able to drag the line in the correct position like in VB.net 2005 MouseDown fdragging =true startx =0 starty =0 MouseMove m_control.StartPoint = New Point((m_control.StartPoint.X + e.X) - startx, (m_control.StartPoint.Y + e.Y) - starty) m_control.EndPoint = New Point((m_control.EndPoint.X + e.X - startx), (m_control.EndPoint.Y + e.Y - starty)) MouseUp fdragging = false & the things are i am not able to handle the MouseUp event also after mousemove the pointer is slipping from the line & not able move the line in the correct direction. Regards,
For1206
-
Hi CodeProject , The problem is I am drawing a LineShape control from Microsoft PowerPacks controls .dll , I am also moving the line when MouseDown,MouseMove,MouseUp, But i am not able to drag the line in the correct position like in VB.net 2005 MouseDown fdragging =true startx =0 starty =0 MouseMove m_control.StartPoint = New Point((m_control.StartPoint.X + e.X) - startx, (m_control.StartPoint.Y + e.Y) - starty) m_control.EndPoint = New Point((m_control.EndPoint.X + e.X - startx), (m_control.EndPoint.Y + e.Y - starty)) MouseUp fdragging = false & the things are i am not able to handle the MouseUp event also after mousemove the pointer is slipping from the line & not able move the line in the correct direction. Regards,
For1206
On the mouse down, does the startx, starty not have to be the point relative to the main form position? Then on the mouse move, you use the move offsets to relocate the line relative to startx and starty.
Dave Don't forget to rate messages!
Find Me On: Web|Facebook|Twitter|LinkedIn
Waving? dave.m.auld[at]googlewave.com -
On the mouse down, does the startx, starty not have to be the point relative to the main form position? Then on the mouse move, you use the move offsets to relocate the line relative to startx and starty.
Dave Don't forget to rate messages!
Find Me On: Web|Facebook|Twitter|LinkedIn
Waving? dave.m.auld[at]googlewave.comHi Dave , I m using a split container.On Panel1 i created a panel and on that i am drawing the line .& trying to move on the MouseDown ,Move,Up for LineShape Controls. But i am not able to drag the line while placing the cursor at any position on the line due to the logic problem exactly & loosing the grip of the line while placing the mousepointer & dragging the line not firing the MouseUp . Regards,
For1206
-
Hi Dave , I m using a split container.On Panel1 i created a panel and on that i am drawing the line .& trying to move on the MouseDown ,Move,Up for LineShape Controls. But i am not able to drag the line while placing the cursor at any position on the line due to the logic problem exactly & loosing the grip of the line while placing the mousepointer & dragging the line not firing the MouseUp . Regards,
For1206
See code below, i have just tried this and it is fine. Form, with SplitContainer, and A PowerPack Line in the right Panel
Private \_lineDrag As Boolean = False Private \_x As Integer = 0 Private \_y As Integer = 0 Private Sub LineShape1\_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles LineShape1.MouseDown If e.Button = Windows.Forms.MouseButtons.Left Then \_lineDrag = True \_x = e.X \_y = e.Y End If End Sub Private Sub LineShape1\_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles LineShape1.MouseMove If e.Button = Windows.Forms.MouseButtons.Left And \_lineDrag Then LineShape1.X1 = (LineShape1.StartPoint.X + e.X) - \_x LineShape1.X2 = (LineShape1.EndPoint.X + e.X) - \_x LineShape1.Y1 = (LineShape1.StartPoint.Y + e.Y) - \_y LineShape1.Y2 = (LineShape1.EndPoint.Y + e.Y) - \_y Me.Refresh() End If End Sub Private Sub LineShape1\_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles LineShape1.MouseUp If e.Button = Windows.Forms.MouseButtons.Left Then \_lineDrag = False End If End Sub
Dave Don't forget to rate messages!
Find Me On: Web|Facebook|Twitter|LinkedIn
Waving? dave.m.auld[at]googlewave.com -
See code below, i have just tried this and it is fine. Form, with SplitContainer, and A PowerPack Line in the right Panel
Private \_lineDrag As Boolean = False Private \_x As Integer = 0 Private \_y As Integer = 0 Private Sub LineShape1\_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles LineShape1.MouseDown If e.Button = Windows.Forms.MouseButtons.Left Then \_lineDrag = True \_x = e.X \_y = e.Y End If End Sub Private Sub LineShape1\_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles LineShape1.MouseMove If e.Button = Windows.Forms.MouseButtons.Left And \_lineDrag Then LineShape1.X1 = (LineShape1.StartPoint.X + e.X) - \_x LineShape1.X2 = (LineShape1.EndPoint.X + e.X) - \_x LineShape1.Y1 = (LineShape1.StartPoint.Y + e.Y) - \_y LineShape1.Y2 = (LineShape1.EndPoint.Y + e.Y) - \_y Me.Refresh() End If End Sub Private Sub LineShape1\_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles LineShape1.MouseUp If e.Button = Windows.Forms.MouseButtons.Left Then \_lineDrag = False End If End Sub
Dave Don't forget to rate messages!
Find Me On: Web|Facebook|Twitter|LinkedIn
Waving? dave.m.auld[at]googlewave.comHi Dave , Thanks its moving fine . 1) But my LineShape controls is slipping from the mouse pointer while moving . So not able to drag the line in a correct way ,Freely . 2) I am able to get the traces of line if resized on the Start point or End Point handles . & i have to refresh the Panel i.e., Parent of the Shapecontainer . My way of doing the things . SplitContainer -> Panel1 -> New Panel at runtime -- This Panel is parent for the shape controls . The Same problem also coming for RectangleShape & Oval Shape also. I have to press the mousebutton very forcefully & drag the control otherwise slipping from my mousepointer . What to do ??
For1206
modified on Friday, February 19, 2010 12:43 AM