473,320 Members | 1,817 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,320 software developers and data experts.

Mouse position

I want to make a tool to design (like paint).
So, I want to know the position of the mouse.

Cursor.Position.X gives me that information. But, when I draw a picture, it
is not at the good place
e.Graphics.DrawImage(newImage, new Rectangle(x, y, 32, 32));

I think it is because Cursor.Position.X is an absolute coordonate, and
DrawImage takes a relative coordonate.

So, how can I get the true position on the screen ?
Nov 16 '05 #1
3 24721
You have to convert to client co-ordinates using cusor position

testControl.PointToClient(Point (Cursor.Position.X ,Cursor.Position.Y));

Shak.
"Mathieu Chavoutier" <no****@no.spam> wrote in message
news:Oa**************@TK2MSFTNGP11.phx.gbl...
I want to make a tool to design (like paint).
So, I want to know the position of the mouse.

Cursor.Position.X gives me that information. But, when I draw a picture, it is not at the good place
e.Graphics.DrawImage(newImage, new Rectangle(x, y, 32, 32));

I think it is because Cursor.Position.X is an absolute coordonate, and
DrawImage takes a relative coordonate.

So, how can I get the true position on the screen ?

Nov 16 '05 #2
In article <Oa**************@TK2MSFTNGP11.phx.gbl>, no****@no.spam
says...
I want to make a tool to design (like paint).
So, I want to know the position of the mouse.

Cursor.Position.X gives me that information. But, when I draw a picture, it
is not at the good place
e.Graphics.DrawImage(newImage, new Rectangle(x, y, 32, 32));

I think it is because Cursor.Position.X is an absolute coordonate, and
DrawImage takes a relative coordonate.

So, how can I get the true position on the screen ?


See the Control.PointToClient method.

--
Patrick Steele
Microsoft .NET MVP
http://weblogs.asp.net/psteele
Nov 16 '05 #3
PointToClient works, thanks for both.
Nov 16 '05 #4

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

Similar topics

9
by: punkin | last post by:
I am trying to catch mouse position on the entire screen by dynamically generating mouse click event at every 100 ms. My code only works for IEs but not any Netscape or Gecko-based browsers. The...
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...
5
by: gsb | last post by:
I track the mouse location like this code: function mousePos(e) { var p = new Object(); if(e) { p.x = e.pageX; p.y = e.pageY; } else { p.x = event.x; p.y = event.y; } ... (show) }...
3
by: Emjay | last post by:
Newbie needs to know how to set the mouse position.
3
by: jcrouse | last post by:
I have created a form designer type application (with a lot of you peoples helpJ). It has label controls that are draggable at runtime. The user is also allowed to change some properties such as...
13
by: Lars Netzel | last post by:
Hi! I have a round area which I want to be able to move the mouse over and fire off events... how do I do that? I have drawn a FillPie Graphics and I feel that there has to be a way of...
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...
3
by: Morten Snedker | last post by:
If I have a number of random applications open, move the mouse cursor to a given position and do a click, the application gets the focus. That is what this simple code should illustrate: Dim...
2
by: markszlazak | last post by:
In the following script, a control displays (black box) in each table cell once you mouse over the cell. Mouse down on the control to change the mode of the table. Drag the mouse over cells in the...
4
by: mike | last post by:
I have the opportunity to rescue a project that uses a mouse to sense the relative position of a machine. The hardware is built...just needs to be programmed. Stop snickering!!! I didn't do it...I...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
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...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
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: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
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...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
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...

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.