コード例 #1
0
 private void mf_MouseDown()
 {
     if (this.Visible)
     {
         if (!this.RectangleToScreen(this.ClientRectangle).Contains(Cursor.Position))
         {
             this.Visible = false;
             Application.RemoveMessageFilter(mf);
             mf = null;
             this.DestroyHandle();
             this.Dispose();
         }
     }
 }
コード例 #2
0
        private void mf_KeyUp(IntPtr target)
        {
            if (!target.Equals(IntPtr.Zero))
            {
                if (this.Visible)
                {
                    if (!IsTargetMine(target))
                    {
                        this.Visible = false;

                        Application.RemoveMessageFilter(mf);
                        mf = null;
                        this.Dispose();
                    }
                }
            }
        }
コード例 #3
0
        /// <summary>
        /// Construction with mode current.
        /// </summary>
        /// <param name="_mode">Used to set focus button of this mode</param>
        public ChooseMode(Variables.Constants.Mode _mode)
        {
            InitializeComponent();
            // xem cách sử dụng user control và component nữa, còn nhiều cái
            // phải học đối với C# ở trong đó.....
            this.Return_Mode = _mode;
            SetFocusButton(_mode);

            if (mf == null)
            {
                mf = new MyFilter();
                Application.AddMessageFilter(mf);
            }

            mf.MouseDown += new MyFilter.LeftButtonDown(mf_MouseDown);
            mf.KeyUp     += new MyFilter.KeyPressUp(mf_KeyUp);
        }