Click here to Skip to main content
15,888,968 members
Home / Discussions / C#
   

C#

 
AnswerRe: Set cursor position without firing MouseMove event Pin
Shameel10-May-11 3:00
professionalShameel10-May-11 3:00 
GeneralRe: Set cursor position without firing MouseMove event Pin
BHillam10-May-11 3:06
BHillam10-May-11 3:06 
AnswerRe: Set cursor position without firing MouseMove event Pin
Luc Pattyn10-May-11 3:29
sitebuilderLuc Pattyn10-May-11 3:29 
GeneralRe: Set cursor position without firing MouseMove event Pin
BHillam10-May-11 3:58
BHillam10-May-11 3:58 
AnswerRe: Set cursor position without firing MouseMove event Pin
Luc Pattyn10-May-11 4:37
sitebuilderLuc Pattyn10-May-11 4:37 
AnswerRe: Set cursor position without firing MouseMove event [modified] Pin
BHillam10-May-11 5:30
BHillam10-May-11 5:30 
GeneralRe: Set cursor position without firing MouseMove event Pin
Mark Salsbery10-May-11 9:59
Mark Salsbery10-May-11 9:59 
GeneralRe: Set cursor position without firing MouseMove event [modified] Pin
BHillam10-May-11 15:06
BHillam10-May-11 15:06 
In part, yes - I won't receive events when the mouse leaves the panel. That's the theory at least. I've done testing and it seems I still receive events even when the cursor is outside my panel, but when the mouse reaches the edge of the monitor, I will stop receiving MouseMove events, because the cursor will have nowhere further to go. At the moment, the user has to perform multiple click + drag operations to keep the camera rotating over long distances.

The other reason I want this behaviour is that when the right button is released, the mouse will appear in the same place the user initiated the operation, rather than some unexpected location across the screen.

As for IInputElement, I'm no C# expert, but my understanding is that Panel and PictureBox are Winforms controls, whereas IInputElement is a WPF interface. WPF has an Image control (similar to PictureBox, but with different behaviour) that would work well for me, but I can't figure out how to enable WPF controls in my project. All the WPF controls are greyed out. I've added the appropriate references but no luck.

Either way, I'm no longer certain that Mouse.Capture() is what I'm after anyway. Everything I've set out to accomplish here is working, with the exception of unsubscribing the event handler + resubscribing after changing the cursor position.

EDIT: Now I simply do this instead:

private Boolean ignoreMouseMove = false;

private void onMouseMove(object sender, MouseEventArgs e)
{
    if (e.Button == MouseButtons.Right)
    {
        if (!ignoreMouseMove)
        {
            currMousePos = e.Location;

            Point delta = currMousePos - prevMousePos;

            //Do stuff with delta...

            Cursor.Position = this.panel_RenderWindow.PointToScreen(prevMousePos);
            ignoreMouseMove = true;
        }
        else
        {
            ignoreMouseMove = false;
        }
    }
}


This feels kinda dirty but at least it works. I'd still like to know why unsubscribing the handler wasn't working, if anybody knows the answer.

modified on Tuesday, May 10, 2011 10:19 PM

GeneralRe: Set cursor position without firing MouseMove event Pin
Mark Salsbery10-May-11 16:39
Mark Salsbery10-May-11 16:39 
QuestionWhat is the best way(s) to send strings from java app to .net app? Pin
CodeGust10-May-11 2:21
CodeGust10-May-11 2:21 
AnswerRe: What is the best way(s) to send strings from java app to .net app? Pin
Groulien10-May-11 2:35
Groulien10-May-11 2:35 
GeneralRe: What is the best way(s) to send strings from java app to .net app? Pin
CodeGust10-May-11 3:39
CodeGust10-May-11 3:39 
AnswerRe: What is the best way(s) to send strings from java app to .net app? Pin
Wayne Gaylard10-May-11 2:44
professionalWayne Gaylard10-May-11 2:44 
GeneralRe: What is the best way(s) to send strings from java app to .net app? Pin
CodeGust10-May-11 3:41
CodeGust10-May-11 3:41 
AnswerRe: What is the best way(s) to send strings from java app to .net app? Pin
jschell10-May-11 12:14
jschell10-May-11 12:14 
GeneralRe: What is the best way(s) to send strings from java app to .net app? Pin
CodeGust10-May-11 12:31
CodeGust10-May-11 12:31 
GeneralRe: What is the best way(s) to send strings from java app to .net app? Pin
jschell11-May-11 8:04
jschell11-May-11 8:04 
QuestionWinform validation Pin
arkiboys10-May-11 2:10
arkiboys10-May-11 2:10 
AnswerRe: Winform validation Pin
Rhuros10-May-11 2:50
professionalRhuros10-May-11 2:50 
GeneralRe: Winform validation Pin
arkiboys10-May-11 3:00
arkiboys10-May-11 3:00 
QuestionRe: Winform validation Pin
Pete O'Hanlon10-May-11 3:13
mvePete O'Hanlon10-May-11 3:13 
AnswerRe: Winform validation Pin
arkiboys10-May-11 5:38
arkiboys10-May-11 5:38 
AnswerRe: Winform validation Pin
Shameel10-May-11 2:56
professionalShameel10-May-11 2:56 
GeneralRe: Winform validation Pin
arkiboys10-May-11 3:00
arkiboys10-May-11 3:00 
GeneralRe: Winform validation Pin
Dave Kreskowiak10-May-11 3:45
mveDave Kreskowiak10-May-11 3:45 

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.