The PointToScreen() method worked pretty fine!! Thanks!!!
On Sat, Feb 7, 2009 at 11:41 AM, AstroDrabb <[email protected]> wrote: > > On Wed, Feb 4, 2009 at 8:46 AM, Ramon Lopes <[email protected]> wrote: > > Hello everybody, > > > > > > I've faced some problems using DragEventArgs. The matter is just that > > according to the library the X and Y properties of DragEventArgs return > > "coordinate of the mouse pointer, in screen coordinates." > > ( > http://msdn.microsoft.com/en-us/library/system.windows.forms.drageventargs_members.aspx > ). > > I would like to get the coordinate of the mouse during the generating > mouse > > event, like the MouseEventArgs.X property does. > > > > Could someone help me? > > > > Thanks! > > Do you want to get the mouse coordinates outside of your window? Or do you > want > to convert the screen coordinates to client coordinates? If so, controls > have > PointToScreen() and PointToClient() methods. > > If the later, you can use: > > [DllImport("user32.dll")] > static extern bool GetCursorPos(ref Point lpPoint); > > Point defPnt = new Point(); > > // Call the function and pass the Point, defPnt > GetCursorPos(ref defPnt); > > // Now after calling the function, defPnt contains the coordinates > which we can read > string x = defPnt.X.ToString(); > string y = defPnt.Y.ToString(); > -- Ramon Pereira Lopes
