Click here to Skip to main content
15,885,546 members
Home / Discussions / C#
   

C#

 
GeneralRe: Mouse and button position difference Pin
p3rson22-Sep-09 7:44
p3rson22-Sep-09 7:44 
GeneralRe: Mouse and button position difference Pin
EliottA22-Sep-09 7:56
EliottA22-Sep-09 7:56 
GeneralRe: Mouse and button position difference Pin
p3rson22-Sep-09 8:13
p3rson22-Sep-09 8:13 
GeneralRe: Mouse and button position difference Pin
EliottA22-Sep-09 8:21
EliottA22-Sep-09 8:21 
GeneralRe: Mouse and button position difference Pin
p3rson22-Sep-09 8:50
p3rson22-Sep-09 8:50 
GeneralRe: Mouse and button position difference Pin
EliottA22-Sep-09 8:53
EliottA22-Sep-09 8:53 
GeneralRe: Mouse and button position difference Pin
p3rson22-Sep-09 8:56
p3rson22-Sep-09 8:56 
GeneralRe: Mouse and button position difference Pin
Ian Shlasko22-Sep-09 9:27
Ian Shlasko22-Sep-09 9:27 
The MousePosition property is always given in relation to the desktop, and controls are always given in relation to their immediate parent... But WinForms controls have a PointToScreen() function and a PointToClient() function.

Control.PointToScreen(pt): Take a point in control coordinates (Measured in relation to the top-left corner of the control), and return them in screen coordinates

Control.PointToClient(pt): Take a point in screen coordinates, and return them in relation to the control.

If you want everything in the same scope, for example, in relation to your Form:

myForm.PointToClient(myButton.PointToScreen(new Point(0,0)))
(This will work regardless of how nested your controls are, so if the button is inside a panel which is inside another panel, this will still give you the right coordinates)

myForm.PointToClient(MousePosition)

Alternatively, instead of using MousePosition, you can use e.X and e.Y (From the MouseEventArgs in the event), which will always be in relation to the control raising the event.

Proud to have finally moved to the A-Ark. Which one are you in?
Developer, Author (Guardians of Xen)

GeneralRe: Mouse and button position difference Pin
p3rson22-Sep-09 9:41
p3rson22-Sep-09 9:41 
QuestionContent-Disposition Attachment not working in IE7 Pin
sudhirBirlapur22-Sep-09 6:14
sudhirBirlapur22-Sep-09 6:14 
AnswerRe: Content-Disposition Attachment not working in IE7 Pin
EliottA22-Sep-09 7:35
EliottA22-Sep-09 7:35 
AnswerRe: Content-Disposition Attachment not working in IE7 Pin
Manas Bhardwaj22-Sep-09 9:07
professionalManas Bhardwaj22-Sep-09 9:07 
GeneralRe: Content-Disposition Attachment not working in IE7 Pin
sudhirBirlapur22-Sep-09 18:59
sudhirBirlapur22-Sep-09 18:59 
Questionwriting usb driver in visual C#.Net.? Pin
Mir_As22-Sep-09 4:23
Mir_As22-Sep-09 4:23 
AnswerRe: writing usb driver in visual C#.Net.? Pin
Dave Kreskowiak22-Sep-09 4:36
mveDave Kreskowiak22-Sep-09 4:36 
GeneralRe: writing usb driver in visual C#.Net.? Pin
Mir_As22-Sep-09 5:04
Mir_As22-Sep-09 5:04 
GeneralRe: writing usb driver in visual C#.Net.? Pin
EliottA22-Sep-09 5:10
EliottA22-Sep-09 5:10 
GeneralRe: writing usb driver in visual C#.Net.? Pin
Dave Kreskowiak22-Sep-09 5:19
mveDave Kreskowiak22-Sep-09 5:19 
GeneralRe: writing usb driver in visual C#.Net.? Pin
Xmen Real 22-Sep-09 5:36
professional Xmen Real 22-Sep-09 5:36 
GeneralRe: writing usb driver in visual C#.Net.? Pin
Dave Kreskowiak22-Sep-09 6:26
mveDave Kreskowiak22-Sep-09 6:26 
GeneralRe: writing usb driver in visual C#.Net.? Pin
Richard MacCutchan22-Sep-09 6:27
mveRichard MacCutchan22-Sep-09 6:27 
GeneralRe: writing usb driver in visual C#.Net.? Pin
Xmen Real 22-Sep-09 6:36
professional Xmen Real 22-Sep-09 6:36 
AnswerRe: writing usb driver in visual C#.Net.? Pin
Luc Pattyn22-Sep-09 5:26
sitebuilderLuc Pattyn22-Sep-09 5:26 
GeneralRe: writing usb driver in visual C#.Net.? Pin
EliottA22-Sep-09 6:57
EliottA22-Sep-09 6:57 
GeneralRe: writing usb driver in visual C#.Net.? Pin
DaveyM6922-Sep-09 7:46
professionalDaveyM6922-Sep-09 7:46 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.