Windows Develop Bookmark and Share   
 index > Windows Forms General > Trouble with points and windows
 

Trouble with points and windows

Hi guys/gals:

I build a simple test program in VC# 2005 that's just a window that tells me my mouse position and the window size, the thing is that if I move my mouse to the edge of the window the window size and the mouse position are different in this example case I have mouse pos 426 and window height 423. Is this something to do with different coordinate systems or something? ...

To get the mouse position on the mouse move event I do:

[source]

private void Graficador_MouseMove(object sender, MouseEventArgs e)
{
x = e.X.ToString();
y = label2.Text = e.Y.ToString();
}
[/source]

to get the window size I do:
[source]

private void Graficador_Load(object sender, EventArgs e)
{
h = this.Height;
w = this.Width;
}
[/source]

Thanks in advance,

G
Gabzuka  Saturday, March 24, 2007 7:29 PM
The Width and Height properties include the non-client area of the window. Border and caption. You should check the mouse position against the value of the ClientSize property.
nobugz  Saturday, March 24, 2007 8:23 PM
The Width and Height properties include the non-client area of the window. Border and caption. You should check the mouse position against the value of the ClientSize property.
nobugz  Saturday, March 24, 2007 8:23 PM
there are also differences between client area and form area ( the border and title/menu are not part of the client area). Coordiantes (mainly where 0 is) is different for each of these, and they are even different from the coordinate of the point in screen area.

What is your goal with displaying/using the location of the cursor in your program? Or is this part of expanding your skills with C#?
IsshouFuuraibou  Sunday, March 25, 2007 5:55 AM
I solved it!! thanks both of you guys ... I used the clientsize property and got what I wanted ... I got what I needed, to display the mouse position on the form ...

Thanks a lot again!
Gabzuka  Wednesday, March 28, 2007 1:28 AM

You can use google to search for other answers

Custom Search

More Threads

• How to get the column index in the EditingControlShowing Event ?
• An enhanced TreeView
• How to save full path of Cerain file into XML file
• Creating PictureBox events at Runtime (C++)
• Problem with listview having checkbox
• localizable UserControl best way to do it.
• Regarding opening a application inside the Form
• Detect Password Fields in a Windows Form
• Implementing Cut, Copy, Paste, in a Menu
• How to generate X and Y axis with numerical values on C#.net Windows Form?