473,657 Members | 2,513 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Mouse position?

I want one end of a line to follow the mouse?
Jul 17 '05 #1
2 7326
> 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(Bu tton 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.tampaba y.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
5540
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 = (how)?100:110;
4
14712
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 coordinates of mouse position. based on left of the top of my image is 0 0 (X Y coordinates) otherwise, I need to find out position of my image so I can calculate.
2
4395
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 position on the screen, to tell where the mouse is in relation to the form and so that I can know which part of a panel someone clicked on. thanks in advance --rob
2
24728
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
5927
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 the page but I find that the iframes interfere with the getting the mouse coords from the screen which is essential in moving the scroll bar around. My test html is given below. With the iframe hidden the mouse coords are obtainable. With the...
1
5371
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: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dv_vstechart/html/vbtchimpdragdrop.asp It works fine, but I have another problem. I want to create functionality like a Windows Explorer. This means, if I select some items from list view No 1 and drag&drop this to the list view No 2, then I want to mark automatically
4
26483
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
4491
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 them to click on a custom control of mine, drag a line to another custom control, and when they let go draw a connection. With Drag and Drop I am able to get the start and end controls, and draw the final connection line, but I cannot for the life...
5
4844
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 users mouse leaves the button, or the buttons in the list I want the list to disappear. I originally tried to place all of the drop down buttons into a single user control, and to then have them appear when users enter some button and disappear when...
0
8324
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8842
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8617
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7352
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6176
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5642
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
2742
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1970
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1733
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.