Click here to Skip to main content
15,920,576 members
Home / Discussions / C#
   

C#

 
QuestionPassing Cursor Coordinates as Parameters Pin
ASPnoob20-May-13 21:52
ASPnoob20-May-13 21:52 
AnswerRe: Passing Cursor Coordinates as Parameters Pin
Pete O'Hanlon20-May-13 22:01
mvePete O'Hanlon20-May-13 22:01 
GeneralRe: Passing Cursor Coordinates as Parameters Pin
ASPnoob20-May-13 22:05
ASPnoob20-May-13 22:05 
AnswerRe: Passing Cursor Coordinates as Parameters Pin
OriginalGriff20-May-13 22:52
mveOriginalGriff20-May-13 22:52 
This is pretty easy to do, but I think you are trying to do it the wrong way. You don't say what your environment is, but I'll assume WinForms.
First off, you probably don't need to use Cursor at all for this, a simple Point is enough.
Try doing this by adding a few class level variables, and handling a few events:
C#
private Point pointStart;
private Point pointEnd;
private bool drawing = false;

C#
private void frmMain_MouseDown(object sender, MouseEventArgs e)
    {
    pointStart = e.Location;
    pointEnd = pointStart;
    drawing = true;
    Invalidate();
    }

private void frmMain_MouseUp(object sender, MouseEventArgs e)
    {
    drawing = false;
    }

private void frmMain_MouseMove(object sender, MouseEventArgs e)
    {
    if (drawing)
        {
        pointEnd = e.Location;
        Invalidate();
        }
    }

private void frmMain_Paint(object sender, PaintEventArgs e)
    {
    e.Graphics.DrawLine(Pens.Blue, pointStart, pointEnd);
    }

The universe is composed of electrons, neutrons, protons and......morons. (ThePhantomUpvoter)

GeneralRe: Passing Cursor Coordinates as Parameters Pin
ASPnoob21-May-13 16:38
ASPnoob21-May-13 16:38 
GeneralRe: Passing Cursor Coordinates as Parameters Pin
lukeer21-May-13 21:47
lukeer21-May-13 21:47 
GeneralRe: Passing Cursor Coordinates as Parameters Pin
OriginalGriff21-May-13 22:21
mveOriginalGriff21-May-13 22:21 
QuestionPropertyGrid Multiple Objects Selection Pin
vvino202020-May-13 20:48
professionalvvino202020-May-13 20:48 
AnswerRe: PropertyGrid Multiple Objects Selection Pin
Eddy Vluggen20-May-13 22:32
professionalEddy Vluggen20-May-13 22:32 
AnswerRe: PropertyGrid Multiple Objects Selection Pin
Simon_Whale20-May-13 22:52
Simon_Whale20-May-13 22:52 
AnswerRe: PropertyGrid Multiple Objects Selection Pin
lukeer21-May-13 21:58
lukeer21-May-13 21:58 
QuestionNot able to use Modern UI Charts for Windows 8 Pin
Raghavendra Reddy C20-May-13 18:40
professionalRaghavendra Reddy C20-May-13 18:40 
AnswerRe: Not able to use Modern UI Charts for Windows 8 Pin
Abhinav S20-May-13 18:49
Abhinav S20-May-13 18:49 
GeneralRe: Not able to use Modern UI Charts for Windows 8 Pin
Raghavendra Reddy C20-May-13 20:30
professionalRaghavendra Reddy C20-May-13 20:30 
AnswerRe: Not able to use Modern UI Charts for Windows 8 Pin
Pete O'Hanlon20-May-13 21:40
mvePete O'Hanlon20-May-13 21:40 
GeneralRe: Not able to use Modern UI Charts for Windows 8 Pin
Raghavendra Reddy C20-May-13 22:35
professionalRaghavendra Reddy C20-May-13 22:35 
GeneralRe: Not able to use Modern UI Charts for Windows 8 Pin
Pete O'Hanlon20-May-13 22:54
mvePete O'Hanlon20-May-13 22:54 
AnswerRe: Not able to use Modern UI Charts for Windows 8 Pin
Raghavendra Reddy C20-May-13 22:53
professionalRaghavendra Reddy C20-May-13 22:53 
AnswerRe: Not able to use Modern UI Charts for Windows 8 Pin
Richard MacCutchan20-May-13 22:54
mveRichard MacCutchan20-May-13 22:54 
QuestionPROBLEM with SEND DATA to LOCAL PORT C# Pin
Andrew Nguyen20-May-13 17:18
Andrew Nguyen20-May-13 17:18 
AnswerRe: PROBLEM with SEND DATA to LOCAL PORT C# Pin
Ron Beyer20-May-13 17:56
professionalRon Beyer20-May-13 17:56 
QuestionUsage of IDataErrorInfo Pin
radkrish20-May-13 8:11
radkrish20-May-13 8:11 
AnswerRe: Usage of IDataErrorInfo Pin
Ron Beyer20-May-13 14:55
professionalRon Beyer20-May-13 14:55 
GeneralUnderstanding Jagged Arrays Pin
N8tiv20-May-13 3:29
N8tiv20-May-13 3:29 
GeneralRe: Understanding Jagged Arrays Pin
Richard Deeming20-May-13 3:44
mveRichard Deeming20-May-13 3:44 

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.