Lost Events after Selection changed activated (VisOcx 2007)

B

BrentW

After some days of head banging I've narrowed a question down to :
InitializeComponent();
vPage = axDrawingControl1.Window.Application.ActivePage;
rect1 = vPage.DrawRectangle(1, 1, 3, 2);
SetProperty(rect1, "NoObjHandles", "=true");
SetProperty(rect1, "LockSelect", "=1");

rect2 = vPage.DrawRectangle(3, 3, 4, 4.5);
SetProperty(rect2, "NoObjHandles", "=true");
SetProperty(rect2, "LockSelect", "=1");
moveshape = false;
axDrawingControl1.Window.DeselectAll();
}

private void button1_Click(object sender, EventArgs e)
{
this.Close();

}

private void axDrawingControl1_MouseDownEvent(object sender,
AxMicrosoft.Office.Interop.VisOcx.EVisOcx_MouseDownEvent e)
{
if (moveshape)
{
MessageBox.Show("How have we missed the MouseUp? Is it
because the SelectionChanged has swallowed it ?"
+ " Look at the Debug output to see what has happened");
Application.Exit() ;
}
moveshape = true;
Debug.Print("Mouse ***DOWN*** at x:" + e.x + " and y:" + e.y);

}
/* TRY
private void axDrawingControl1_MouseMoveEvent(object sender,
AxMicrosoft.Office.Interop.VisOcx.EVisOcx_MouseMoveEvent e)
{
if (moveshape)
{
Debug.Print("Mouse moving at x:" + e.x + " and y:" + e.y);
}

}
* */

private void axDrawingControl1_MouseUpEvent(object sender,
AxMicrosoft.Office.Interop.VisOcx.EVisOcx_MouseUpEvent e)
{

Debug.Print("Mouse ***UP*** at x:" + e.x + " and y:" + e.y);
moveshape = false;


}

private void axDrawingControl1_SelectionChanged(object sender,
AxMicrosoft.Office.Interop.VisOcx.EVisOcx_SelectionChangedEvent e)
{
Debug.Print("Selection changed" ) ;

}

Whether I include or exclude the MouseMove event seems not to matter the
issue is :

I can select a rectangle and move it, getting the MouseDown on the select
and the mouse up at the end of the drag.

If I try to move the other, it will move, but I am most likely to not get
the MouseUp event.

Whenever I don't get the MouseUp event, a SelectionChanged event has
happened during the drag.

Of course, this has been condensed from a very much larger application, but
if anyone feels interested enough to take my titchy VS2008 test, then I'd be
full of respect, not to mention gratitude!
 
B

BrentW

Yep. It's certainly an issue of event sequence.

After some more work I now think the problem is:

1. I identify the shape on the MouseDown.

2. I try to drag the shape

3. If I stay within the original enclosing rectangle, all is OK

4. If I move outside this rectangle, then the SelectionChanged Event gets
fired. This seems to lose the MouseUp associated with the original MouseDown.

So, it seems to me that there are two possibilities. Either suppress the
SelectionChanged Event on the Ocx control or catch it and schedule another
immediate MouseDown Event which would carry us through till we moved out of
the new range.

Unfortunately, I don't know how to do either of these, so I'd still be
massively grateful of any help.

Brent
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top