private void m_MHook_MHookEvent(object sender, MHookEventArgs e) { //如果窗体禁用 调用控件的方法设置信息显示位置 if (!this.Enabled) //貌似Hook不能精确坐标(Hook最先执行执 执行完后的坐标可能与执行时传入的坐标发生了变化 猜测是这样) 所以放置了一个timer检测 { imageProcessBox1.SetInfoPoint(MousePosition.X, MousePosition.Y); } //鼠标点下恢复窗体禁用 if (e.MButton == ButtonStatus.LeftDown || e.MButton == ButtonStatus.RightDown) { this.Enabled = true; imageProcessBox1.IsDrawOperationDot = true; } #region 右键抬起 if (e.MButton == ButtonStatus.RightUp) { if (!imageProcessBox1.IsDrawed) //没有绘制那么退出(直接this.Close右键将传递到下面) { this.BeginInvoke(new MethodInvoker(() => this.Close())); } } #endregion #region 找寻窗体 if (!this.Enabled) { this.FoundAndDrawWindowRect(); } #endregion }
private void m_MHook_MHookEvent(object sender, MHookEventArgs e) { if (!this.Enabled) { this.imageProcessBox1.SetInfoPoint(Control.MousePosition.X, Control.MousePosition.Y); } if (e.MButton == ButtonStatus.LeftDown || e.MButton == ButtonStatus.RightDown) { this.Enabled = true; this.imageProcessBox1.IsDrawOperationDot = true; } if (e.MButton == ButtonStatus.RightUp && !this.imageProcessBox1.IsDrawed) { //this.BeginInvoke((Delegate)(() => this.Close())); ControlHandler handler = delegate() { this.Close(); }; base.BeginInvoke(handler); } if (this.Enabled) { return; } this.FoundAndDrawWindowRect(); }
private void m_MHook_MHookEvent(object sender, MHookEventArgs e) { //如果窗体禁用 调用控件的方法设置信息显示位置 if (!this.Enabled) //貌似Hook不能精确坐标(Hook最先执行执 执行完后的坐标可能与执行时传入的坐标发生了变化 猜测是这样) 所以放置了一个timer检测 { imageProcessBox1.SetInfoPoint(MousePosition.X, MousePosition.Y); } //鼠标点下恢复窗体禁用 if (e.MButton == ButtonStatus.LeftDown || e.MButton == ButtonStatus.RightDown) { this.Enabled = true; imageProcessBox1.IsDrawOperationDot = true; } #region 在imageProcessBox_MouseUp中完成了 //if (e.MButton == ButtonStatus.LeftUp) { // //if (imageProcessBox1.SelectedRectangle.Width < 5 // // || imageProcessBox1.SelectedRectangle.Height < 5) { // // //如果选取区域不符要求 向控件模拟鼠标抬起 然后禁用窗体 // // //(Hook事件先于控件事件 禁用控件时模拟一个鼠标抬起) // // Win32.SendMessage(imageProcessBox1.Handle, Win32.WM_LBUTTONUP, // // IntPtr.Zero, (IntPtr)(MousePosition.Y << 16 | MousePosition.X)); // // this.Enabled = false; // // imageProcessBox1.IsDrawOperationDot = false; // //} else // // this.SetToolBarLocation(); //重置工具条位置 //} #endregion #region 右键抬起 if (e.MButton == ButtonStatus.RightUp) { if (!imageProcessBox1.IsDrawed) //没有绘制那么退出(直接this.Close右键将传递到下面) { this.BeginInvoke(new MethodInvoker(() => this.Close())); } //有绘制的情况 情况继续禁用窗体 this.Enabled = false; imageProcessBox1.ClearDraw(); imageProcessBox1.CanReset = true; imageProcessBox1.IsDrawOperationDot = false; m_layer.Clear(); //清空历史记录 m_bmpLayerCurrent = null; m_bmpLayerShow = null; //ClearToolBarBtnSelected(); panel1.Visible = false; //panel2.Visible = false; } #endregion #region 找寻窗体 if (!this.Enabled) { this.FoundAndDrawWindowRect(); } #endregion }