Page 1 of 1

Mousemove event and moving entity

Posted: 20 Apr 2011, 12:27
by Khyati
Hello,

i wrote following code for mousemove event:

Code: Select all

method MainForm.CadEditorCtrl_PictureBox_MouseMove(sender: System.Object; e: System.Windows.Forms.MouseEventArgs);
var
    Pos_CAD : CADImport.DPoint;
begin
      Pos_CAD := new CADImport.DPoint(e.X, e.Y, 0);
      Pos_CAD := cadEditorControl1.GetRealPoint(e.X, e.Y);
      entPt.Point := Pos_CAD;
    
      entPt.Loaded(cadEditorControl1.Image.Converter);
      cadEditorControl1.Invalidate();
end;
But my point is not moving with mouse move.. instead it moves, only after i do mouse click.
even if i change window, then also it moves the mouse as per i moved mouse.

What's missing in above code?

Re: Mousemove event and moving entity

Posted: 21 Apr 2011, 11:16
by Khyati
I hope you've some solution for above post!
As we are in very critical stage for our project design, i need your help!

Re: Mousemove event and moving entity

Posted: 22 Apr 2011, 14:35
by support
Hello Khyati.
Moving entity with mouse relates to visual functionality. Method that you use to change entity location not correct for such task. Demo applications provides moving selected entities when mouse left button is down. The functionality is common for CAD editing and implemented in CADEditorControl component. We're not sure why need another solution or that is the purpose of created method. Selected entities can be moved on MouseMove without mouse button down like this:

Code: Select all

public class MainForm : System.Windows.Forms.Form
{	
    private int cX, cY; 
    ....
    
    private void cadEditorControl_MouseMove(object sender, MouseEventArgs e)
    {
        if (cadEditorControl.Image == null)
            return;
        if (cadEditorControl.Image.SelectEntitiesCount > 0)
        {
            cadEditorControl.ChangeEntityOnMouseMove(new Point(e.X, e.Y));
            PointF imp = cadEditorControl.ImagePosition;
            PointF cr = new PointF(imp.X - (cX - e.X), imp.Y - (cY - e.Y));
            cadEditorControl.ImagePosition = cr;
            cadEditorControl.Invalidate();
            cX = e.X;
            cY = e.Y;
        }
    }	
If you're not like select entities by mouse then you can do it programmatically.

Alexander.