473,326 Members | 2,099 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

Mouse position?

I want one end of a line to follow the mouse?
Jul 17 '05 #1
2 7316
> I want one end of a line to follow the mouse?

Start a new project and put a Line control on the Form. Set the AutoDraw
property of the Form to True and the Visible property of the Line control to
False. Paste the following code into the Form's code window. Run the
program. Click and Drag a line with the mouse button down. When you release
the mouse button, the Line will "stick" and you can then draw a new line
anywhere else that you want.

Rick - MVP

Dim Drawing As Boolean

Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single,
Y As Single)
With Line1
.Visible = True
.X1 = X
.Y1 = Y
.X2 = X
.Y2 = Y
Drawing = True
End With
End Sub

Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single,
Y As Single)
If Drawing Then
With Line1
.X2 = X
.Y2 = Y
End With
End If

End Sub

Private Sub Form_MouseUp(Button As Integer, Shift As Integer, X As Single, Y
As Single)
Drawing = False
With Line1
Me.Line (.X1, .Y1)-(.X2, .Y2)
.Visible = False
End With
End Sub
Jul 17 '05 #2

"Smiley" <no@never.com> wrote in message
news:ao**********************@twister.tampabay.rr. com...
I want one end of a line to follow the mouse?


Get your mouse position like this...

Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single,
Y As Single)
' X= horizontal mouse position
' Y=vertical mouse position
End Sub

I'm sure you can figure out how to draw a line
from StartX,StartY to X,Y right?
Jul 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: DJ WIce | last post by:
Hi, I have a function on my page to zoom in (for people who have not very good eyes for example): var zoom_factor=100; function zoom(how) { var bodyStyle = document.body.style; zoom_factor...
4
by: Jay | last post by:
Hi, How can I capture mouse position on Image? I found number of script capturing mouse position of the page. But I could not find anything based on image. What I want to find out is X Y...
2
by: Robert Chan | last post by:
I have a form that is 2000x700 it is meant to be run across two monitors I want to get the mouse position relative to the form not to the screen is there any kind of way to reference the forms...
2
by: Mojtaba Faridzad | last post by:
Hi, by Control.MousePosition we can find the mouse position. but how we can set the mouse position? thanks
19
by: wmanzo | last post by:
I have a really professional conspiracy movie site and I use tons of layers and an external scroll bar assembly. I would like to put the various sections into MS Iframes and in order to clean up...
1
by: Sim | last post by:
Hello NG, I try to use drag and drop function between two list views. For this I found following code: ...
4
by: vunet.us | last post by:
I have a DIV element. How can I find mouse position (top and left) inside of this DIV? <div onMouseMove="getPositions();" style="width:200px;height:100px"></div> function getPositions(ev){...
1
by: Emanuel | last post by:
I am trying to make a little diagramming app in C# with the 1.1 Framework (currently our standard here at work, will be upgrading to 2005 sometime in the next couple of months). I want to allow...
5
by: Zaxxon21 | last post by:
I'm basically trying to implement a simple drop down menu list for a button that I have. When the user hovers over the button, I want a list of button options to appear below the button. If the...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.