//雙擊退出多窗體
private DateTime m_LastClick = System.DateTime.Now;
private void xtraTabbedMdiManager1_MouseDown(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
DateTime dt = DateTime.Now;
TimeSpan span = dt.Subtract(m_LastClick);
if (span.TotalMilliseconds < 300) //如果兩次點擊的時間間隔小於300毫秒,則認為是雙擊
{
if (this.MdiChildren.Length > 0)
{
if ((xtraTabbedMdiManager.SelectedPage != null) && (xtraTabbedMdiManager.SelectedPage.MdiChild != null))
{//不加下面的判斷的話將會出現只要在控件任意地方雙擊都會關閉當前選中頁,
if (xtraTabbedMdiManager.SelectedPage == xtraTabbedMdiManager.CalcHitInfo(new Point(e.X, e.Y)).Page as DevExpress.XtraTabbedMdi.XtraMdiTabPage)
{
if (this.ActiveMdiChild == xtraTabbedMdiManager.SelectedPage.MdiChild)
{
this.ActiveMdiChild.Close();
}
}
}
}
m_LastClick = dt.AddMinutes(-1);//這一行代碼的作用是,表示雙擊完成,避免點擊三次認為是雙擊了兩次。
}
else
m_LastClick = dt;
}
}