Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic GetObjectAtPos (Read 2477 times)
Johan
Guest


GetObjectAtPos
Oct 24th, 2005 at 9:39am
Print Post  
Hi have trouble getting the Box object when dropping something on it. I use a laptop with external screen (They have different resolutions)
What i do is i create a box and then just drag and drop on it. But the coordinates dont seam to respond.

Box click X:58 Y:54

Drop: Screen X:415 Y:463 X:109,8021 Y:122,5021

Any idea what can cause the error?
[code]


private void flowChart1_DragDrop(object sender, System.Windows.Forms.DragEventArgs e)


{
PointF mousePos = flowChart1.ClientToDoc(new Point(e.X,e.Y));

System.Diagnostics.Trace.WriteLine(string.Format("Screen X:{0} Y:{1} X:{2} Y:{3}",e.X, e.Y, mousePos.X, mousePos.Y));

Box b = flowChart1.GetNodeObjectAt(mousePos, true, true) as Box;

if (b != null)
    b.Text = (string)e.Data.GetData(typeof(string));

}



private void flowChart1_BoxClicked(object sender, MindFusion.FlowChartX.BoxMouseArgs e)

{

e.Box.Text = string.Format("X:{0} Y:{1}",e.Box.BoundingRect.Left, e.Box.BoundingRect.Top);

}
[/code]
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: GetObjectAtPos
Reply #1 - Oct 24th, 2005 at 10:32am
Print Post  
Hi,

It seems that problem is not coming from the external monitor but from the e.X and e.Y coordinates. While coordinates of most mouse events raised from the Control class are given in client coordinates, the drag-and-drop coordinates are specified in screen pixels. So you can use the Control.PointToClient method to convert from screen to client coordinates, then FlowChart.ClientToDoc to get the document coordinates. E.g. :


PointF docPos = fc.ClientToDoc(fc.PointToClient(new Point(e.X,e.Y)));
  
Back to top
 
IP Logged
 
Johan
Guest


Re: GetObjectAtPos
Reply #2 - Oct 24th, 2005 at 11:09am
Print Post  
Thanks for the fast response  Cheesy Helped!

I also noted that I had choosed to ignore selected and locked nodes while seaching which made me miss some nodes...

Cheers
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint