BaseForm.cs 1001 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. using System.ComponentModel;
  2. using System.Windows.Forms;
  3. using Microsoft.Windows.Forms;
  4. namespace Update.Controls
  5. {
  6. /// <summary>
  7. /// 屏蔽 Alt + F4 窗口
  8. /// </summary>
  9. public class BaseForm : UIForm
  10. {
  11. private bool m_UserClosing;
  12. /// <summary>
  13. /// 显示窗口
  14. /// </summary>
  15. /// <param name="owner">父窗口</param>
  16. public virtual void ShowCore(IWin32Window owner)
  17. {
  18. this.Show(owner);
  19. }
  20. /// <summary>
  21. /// 关闭窗口
  22. /// </summary>
  23. public virtual void CloseCore()
  24. {
  25. this.m_UserClosing = true;
  26. this.Close();
  27. }
  28. /// <summary>
  29. /// 关闭
  30. /// </summary>
  31. /// <param name="e">数据</param>
  32. protected override void OnClosing(CancelEventArgs e)
  33. {
  34. base.OnClosing(e);
  35. e.Cancel = !this.m_UserClosing;
  36. this.m_UserClosing = false;
  37. }
  38. }
  39. }