Mouse Click and Drag

Trips

Well-known member
Joined
Aug 7, 2010
Messages
2,788
Hi there:
I have a question regarding my click-and-drag feature. Ill start from the piece of code below.


<div style="color:Black;background-color:White; <pre>
        <span style="color:Blue; private <span style="color:Blue; void glControl1_MouseDown(<span style="color:Blue; object sender, System.Windows.Forms.MouseEventArgs e)
        {            
            newMouseDelta = e.Location;

            <span style="color:Blue; if (e.Button == MouseButtons.Middle)
            {
                oldMouseDelta = e.Location; <span style="color:Green; // Get the position where the roller is clicked

                facing += (oldMouseDelta.X - newMouseDelta.X) * 0.005f;
                pitch += (newMouseDelta.Y - oldMouseDelta.Y) * 0.005f;
            }             

            glControl1.Invalidate();
        }
[/code]
My idea is to get the current location, and as soon as the middle button (roller) of the mouse is clicked, the properties of my view (facing and pitch) will change.
I first developed this in a Console App and seemed to work fine. Now, I move to Windows App and this algorithm no longer works.
My questions are:
1. Is this the correct method for click-and-drag? It seems that this is only for the click, but not the drag.
2. If this is the correct method for click-and-dragging, do you see any mistake in my code?
Thank you for your help!
Aditya



View the full article
 
Back
Top