Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Moving ControlHost (Read 1641 times)
jmcnair@esc
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 4
Joined: Sep 25th, 2006
Moving ControlHost
Sep 25th, 2006 at 5:47pm
Print Post  
Is there a way that a ControlHost can be moved by doing a click inside the ControlHost (rather than on the handle around it) and dragging to the desired location?

I've figured out a way to make the control inside the host respond to the click and move the ControlHost that contains it based on the MouseDown and MouseUp events.  So I can move it by clicking inside on the control, but this doesn't pull the ControlHost along to track the movement, it just makes it appear wherever you do your MouseUp.  Is there a way that I could accomplish this by tapping into the handle selection event, or by some other method?
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Moving ControlHost
Reply #1 - Sep 25th, 2006 at 6:24pm
Print Post  
That's possible, as long as the control raises the MouseDown event and does not capture the mouse. Setup the flowchart and the host node like this:

Code
Select All
fc.ModificationStart = ModificationStyle.AutoHandles;
fc.DefaultControlType = typeof(Button);

ControlHost ch = fc.CreateControlHost(0, 0, 50, 50);
ch.HandlesStyle = HandlesStyle.Custom;
ch.CtrlMouseAction = HostMouseAction.IgnoreControl;
 



and handle the hit-test event as follows:
Code
Select All
private void fc_HitTestSelHandles(object sender, MindFusion.FlowChartX.HitTestEventArgs e)
{
  if (e.Item is ControlHost)
  {
    ControlHost ch = e.Item as ControlHost;
    if (ch.BoundingRect.Contains(e.MousePosition))
     e.HitResult = 8;// = move
  }
}
 



Flowchart.NET subscribes to the MouseDown event of the top-most window of a hosted control. So if yours is a composite control, you might wish to make the top-most window raise MouseDown even when a child control is clicked.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
jmcnair@esc
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 4
Joined: Sep 25th, 2006
Re: Moving ControlHost
Reply #2 - Sep 27th, 2006 at 11:45am
Print Post  
Good work.  Thanks!
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint