/// <summary> /// ¬ызывает событие PreviewMouseDown. /// </summary> /// <param name="args"></param> protected void OnPreviewMouseDown(SimMouseEventArgs args) { if(PreviewMouseDown != null) PreviewMouseDown(this, args); }
//------------------------------------------------------------------------------------- void fdgv_PreviewMouseDown(object sender, SimMouseEventArgs args) { try { if(args.Button != MouseButtons.Right) return; DataGridView.HitTestInfo hti = fdgv.HitTest(args.X, args.Y); if(hti.Type == DataGridViewHitTestType.ColumnHeader) { menuItemFrozen.Checked = fdgv.Columns[hti.ColumnIndex].Frozen; finistContextMenu1.Tag = fdgv.Columns[hti.ColumnIndex]; finistContextMenu1.Show(fdgv, args.Location); args.Handled = true; } } catch(Exception Err) { ErrorBox.Show(Err); } }
//------------------------------------------------------------------------------------- /// <summary> /// /// </summary> /// <param name="m"></param> protected override void WndProc(ref Message m) { if(m.Msg == WM.LBUTTONDOWN || m.Msg == WM.LBUTTONDBLCLK) { #region SimMouseEventArgs arg = new SimMouseEventArgs(MouseButtons.Left, m.Msg == WM.LBUTTONDOWN ? 1 : 2, (short)((int)((long)m.LParam) & 0xffff), (short)((int)((long)m.LParam) >> 0x10) & 0xffff, 0); OnPreviewMouseDown(arg); if(arg.Handled) return; base.WndProc(ref m); if((Form.MouseButtons & MouseButtons.Left) != MouseButtons.Left) base.OnMouseUp(arg); #endregion } else if(m.Msg == WM.RBUTTONDOWN || m.Msg == WM.RBUTTONDBLCLK) { #region SimMouseEventArgs arg = new SimMouseEventArgs(MouseButtons.Right, m.Msg == WM.RBUTTONDOWN ? 1 : 2, (short)((int)((long)m.LParam) & 0xffff), (short)((int)((long)m.LParam) >> 0x10) & 0xffff, 0); OnPreviewMouseDown(arg); if(arg.Handled) return; if(m.Msg == WM.RBUTTONDOWN && RightClickChangeCurrent) { m.Msg = (int)WM.LBUTTONDOWN; m.WParam = (IntPtr)((int)m.WParam ^ 2); m.WParam = (IntPtr)((int)m.WParam | 1); } base.WndProc(ref m); #endregion } else if(m.Msg == WM.NCCALCSIZE) { #region //if(m.WParam == IntPtr.Zero) // return; m.Result = new IntPtr(0x0400); if(borderStyle == BorderStyle.FixedSingle) { NCCALCSIZE_PARAMS p = (NCCALCSIZE_PARAMS)m.GetLParam(typeof(NCCALCSIZE_PARAMS)); p.rgc[0].left += borderWidth.Left; p.rgc[0].right -= borderWidth.Right; p.rgc[0].top += borderWidth.Top; p.rgc[0].bottom -= borderWidth.Bottom; Marshal.StructureToPtr(p, m.LParam, true); } else if(borderStyle == BorderStyle.Fixed3D) { int w = 2; NCCALCSIZE_PARAMS p = (NCCALCSIZE_PARAMS)m.GetLParam(typeof(NCCALCSIZE_PARAMS)); p.rgc[0].left += w; p.rgc[0].right -= w; p.rgc[0].top += w; p.rgc[0].bottom -= w; Marshal.StructureToPtr(p, m.LParam, true); } base.WndProc(ref m); #endregion } else if(m.Msg == WM.NCPAINT) { #region if(borderStyle != BorderStyle.None) { base.WndProc(ref m); IntPtr hdc = IntPtr.Zero; try { //hdc = APIWrappers.GetDCEx(this.Handle, (IntPtr)m.WParam, // (int)(GetDCExFlags.DCX_WINDOW | GetDCExFlags.DCX_PARENTCLIP )); hdc = APIWrappers.GetWindowDC(this.Handle); if(hdc != IntPtr.Zero) using(Graphics g = Graphics.FromHdc(hdc)) OnNonClientPaint(g); } catch(Exception ex) { throw ex; } finally { if(hdc != IntPtr.Zero) APIWrappers.ReleaseDC(this.Handle, hdc); } return; } base.WndProc(ref m); #endregion } else base.WndProc(ref m); }