473,398 Members | 2,212 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,398 software developers and data experts.

Mouse coordinate

MAY
hi,

How to get the current mouse position on the screen??
I tried Control.MousePosition.X and Control.MousePosition.Y but fail.

Thanks!

MAY
Nov 16 '05 #1
4 9714
Cursor.Position

-vJ

"MAY" <pa****@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
hi,

How to get the current mouse position on the screen??
I tried Control.MousePosition.X and Control.MousePosition.Y but fail.

Thanks!

MAY

Nov 16 '05 #2
MAY
Thx for reply :)

If there have form and a button on it, i want the button move with mouse
cursor when mouse down, and the button stop moving when mouse up. How can i
do that?

thx a lots.

MAY
"MAY" <pa****@hotmail.com> ¦b¶l¥ó
news:%2****************@TK2MSFTNGP11.phx.gbl ¤¤¼¶¼g...
hi,

How to get the current mouse position on the screen??
I tried Control.MousePosition.X and Control.MousePosition.Y but fail.

Thanks!

MAY

Nov 16 '05 #3
What you're trying to do is basically a design-time editor.

Override the OnMouseDown method on the Form and based on the X & Y
co-ordinates that come, find out if you hit the button. If you hit the
button, set a boolean flag and keep a local copy of the X & Y co-ordinates.

Now, override the OnMouseMove method. Check if the boolean flag is set. If
set, get the current X & Y co-ordinates and compute the delta between the
old and new co-ordinates. Now, you can move the button delta distance.

Over-ride the OnMouseUp method. Reset the flag.

HTH

-vJ

"MAY" <pa****@hotmail.com> wrote in message
news:er**************@TK2MSFTNGP09.phx.gbl...
Thx for reply :)

If there have form and a button on it, i want the button move with mouse
cursor when mouse down, and the button stop moving when mouse up. How can
i
do that?

thx a lots.

MAY
"MAY" <pa****@hotmail.com> ¦b¶l¥ó
news:%2****************@TK2MSFTNGP11.phx.gbl ¤¤¼¶¼g...
hi,

How to get the current mouse position on the screen??
I tried Control.MousePosition.X and Control.MousePosition.Y but fail.

Thanks!

MAY


Nov 16 '05 #4
MAY
Hi Vijaye Raji,

Thanks for valuable reply. My problem now is how to make the button move
with mouse cursor. Is that in the OnMouseMove:

lastPoint=curPoint;
curPoint=new Point(e.X , e.Y );
if(this.drag)
{
Point pts=new Point(Control.MousePosition.X+ (lastPoint.X -curPoint.X ),
Control.MousePosition.Y+ (lastPoint.Y -curPoint.Y ) );
this.LocationSensor=pts;
}
MAY

"Vijaye Raji" <no*************@hotmail.com> ¦b¶l¥ó
news:eq**************@TK2MSFTNGP09.phx.gbl ¤¤¼¶¼g...
What you're trying to do is basically a design-time editor.

Override the OnMouseDown method on the Form and based on the X & Y
co-ordinates that come, find out if you hit the button. If you hit the
button, set a boolean flag and keep a local copy of the X & Y co-ordinates.
Now, override the OnMouseMove method. Check if the boolean flag is set. If set, get the current X & Y co-ordinates and compute the delta between the
old and new co-ordinates. Now, you can move the button delta distance.

Over-ride the OnMouseUp method. Reset the flag.

HTH

-vJ

"MAY" <pa****@hotmail.com> wrote in message
news:er**************@TK2MSFTNGP09.phx.gbl...
Thx for reply :)

If there have form and a button on it, i want the button move with mouse
cursor when mouse down, and the button stop moving when mouse up. How can i
do that?

thx a lots.

MAY
"MAY" <pa****@hotmail.com> ¦b¶l¥ó
news:%2****************@TK2MSFTNGP11.phx.gbl ¤¤¼¶¼g...
hi,

How to get the current mouse position on the screen??
I tried Control.MousePosition.X and Control.MousePosition.Y but fail.

Thanks!

MAY



Nov 16 '05 #5

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

Similar topics

10
by: Danny | last post by:
How can I get the coordinates of the mouse cursor in Mozilla browsers as well as Opera and IE6? I'm struggling to understand how to capture mouse movement events with Mozilla/Netscape/Firefox and...
0
by: Henry C. Wu | last post by:
Hi, I have a form that has a video "inserted" at the form's Handle. Like so: '//Create Capture Window capGetDriverDescriptionA(0, lpszName, 100, lpszVer, 100) '// Retrieves driver info lwndC =...
2
by: wickedw | last post by:
Hello all, Could anyone possibly tell me how to cause a mouse click at a certain screen coordinate (say 100, 100). For example, if I press 1 on the keyboard I want the mouse pointer to...
2
by: quickcur | last post by:
Hi, I have html like this: <div id="myCanvas" style="border:10px, black;position:relative;height:250px;width:100%;"> <img id="p" src="p.jpg"> </div> When user click the mosue, I would like ...
0
by: ck.kislay | last post by:
When I passed bounding area ( Location,height ,width )of a Window control to the ClipCursor API it restrict the mouse in screen coordinate ,Its fine because ClipCursor works on Screen coordinate....
0
by: peradino | last post by:
Hi I have a problem when I want to know how far my cursor is from the top of pictureBox. I can get mouse coordinate but it is screen coordinate. I can get the top position of my pictureBox...
18
by: eliss.carmine | last post by:
Is it possible to simulate a mouse click in the window I made (it's a Form), but not give it focus? I tried using WinAPI's mouseevent and SendMessage of WM_LBUTTONDOWN/WM_LBUTTONUP as suggested...
1
by: Dave | last post by:
I'm running the below script to open a popup window. Works great! How Can I get "Mouse Coordinates" (X,Y) to include them as Left and Top parameters so that the popup window opens "where the...
4
by: =?Utf-8?B?Unlhbg==?= | last post by:
I have a winform containing a scrollable panel and a groupbox inside the panel. There is a button inside the groupbox. When that button is clicked; how do I capture and display the X and Y...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
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...
0
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...

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.