Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic MouseDown and MessageBox (Read 1562 times)
Cornel
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 23
Joined: Dec 17th, 2008
MouseDown and MessageBox
Mar 10th, 2010 at 7:38am
Print Post  
Hi,
I have a diagram and some other controls on the form.
The focus is in other control than the diagram and when I press the left mouse button on the diagram a message box appears from the business. Now I release the mouse button and click on the OK button from the message box. Then I press down again on the diagram and the interaction starts from the previous location where I pressed the mouse button, not from the current location.
What to do (version 5.3.3)?
Thanks,
Cornel
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: MouseDown and MessageBox
Reply #1 - Mar 10th, 2010 at 12:17pm
Print Post  
Hi,

It happens because the MessageBox is shown in the context of DiagramView.OnMouseDown, and once the message box is dismissed, the mouse is at a different position than the coordinates reported in the EventArgs. We have some code that guards against this by handling the OnLostFocus event, but only for situations when a MessageBox is shown from a DiagramView.OnMouseDown handler. As a work-around you could trick the control into doing that check as shown below:

Code
Select All
private bool msgbox = false;
private void tbQuery_Leave(object sender, EventArgs e)
{
	if (new Random().Next(2) == 1)
	{
		MessageBox.Show(@"1");
		msgbox = true;
	}
}

private void diagramView_MouseDown(object sender, MouseEventArgs e)
{
	if (msgbox)
		tbQuery.Focus();
	msgbox = false;
	... 



I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
Cornel
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 23
Joined: Dec 17th, 2008
Re: MouseDown and MessageBox
Reply #2 - Mar 11th, 2010 at 7:34am
Print Post  
Hi Stoyan,
The problem is I don't know when and from where message box is shown so I can't set the flag to true ...
I solved it this way:
[code]
class MyDiagramView : DiagramView
{
protected override void OnMouseDown(System.Windows.Forms.MouseEventArgs e)
{
if (!this.Focus())
{
return;
}

base.OnMouseDown(e);
}
...
[/code]
It seems to work ok at first glance.
Thanks,
Cornel
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint