none
请问谁看得懂这段代码,求指教 private bool TopLeft = false; private bool TopRight = false; private bool BottomRight = false;定义的这几个字段到底是什么用处 RRS feed

  • 问题

  •  #region 退出界面处理
            private bool TopLeft = false;
            private bool TopRight = false;
            private bool BottomRight = false;
            private void FrmMain_Click_1(object sender, EventArgs e)
            {
                Point p = Control.MousePosition;
                //           PointToClient(p) Computes the location of the specified screen point into client coordinates
                //计算指定屏幕点的位置到客户端坐标
                p = this.PointToClient(p);
                if (p.X < 300 && p.Y < 300)
                {
                    this.TopLeft = true;
                    this.TopRight = false;
                    this.BottomRight = false;
                }
                if (this.TopLeft && (p.X > 980 && p.Y < 300))
                {
                    this.TopLeft = false;
                    this.TopRight = true;
                    this.BottomRight = false;
                }
                if (this.TopRight && (p.X > 924 && p.Y > 724))
                {
                    this.TopLeft = false;
                    this.TopRight = false;
                    this.BottomRight = true;
                }
                if (this.BottomRight && (p.X < 300 && p.Y > 724))
                {
                    this.BottomRight = false;
                    //Form_Exit fe = new Form_Exit(this._mp);
                    //fe.StartPosition = FormStartPosition.CenterParent;
                    //fe.ShowDialog();
                    //fe.GetTextFocus();
                    if (FrmExitPwd.Show("请输入口令:", "身份验证"))
                    {
                        FrmConfig f = new FrmConfig();
                        f.ShowDialog();
                        f.Dispose();
                    }
                }
            }
            #endregion
    2018年3月12日 7:06

全部回复

  • 这是写在一个winform窗口里面的
    2018年3月12日 7:08
  • Hi,

    欢迎在MSDN论坛发帖。

    从这上面的代码来看,是在一个click事件中,根据p的值来设置这三个属性的值。

    感觉它的用途是想用这个三个属性值来确定PointToClient的位置范围。

    Best Regards,

    Hart


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    2018年3月12日 9:29
    版主
  • 定位新窗体的显示,需要满足条件

    if (this.BottomRight && (p.X < 300 && p.Y > 724)) 

    p是鼠标位置,BottomRight 是当前窗体的右下,只有这两个条伯满足,才会调用如下代码

      if (FrmExitPwd.Show("请输入口令:", "身份验证"))
                    {
                        FrmConfig f = new FrmConfig();
                        f.ShowDialog();
                        f.Dispose();
                    }


    专注于.NET ERP/CRM开发框架,C/S架构,SQL Server + ORM(LLBL Gen Pro) + Infragistics WinForms

    2018年3月13日 1:11