public void HitMouseDown(MouseEventArgs e, WinApi.HitTest hit) { if (e.Button == MouseButtons.Left) { HitMouseDown(hit); } }
protected override void WndProc(ref Message m) { if (DesignMode) { base.WndProc(ref m); return; } switch (m.Msg) { case (int)WinApi.Messages.WM_SYSCOMMAND: int sc = m.WParam.ToInt32() & 0xFFF0; switch (sc) { case (int)WinApi.Messages.SC_MOVE: if (!Movable) { return; } break; case (int)WinApi.Messages.SC_MAXIMIZE: break; case (int)WinApi.Messages.SC_RESTORE: break; } break; case (int)WinApi.Messages.WM_NCLBUTTONDBLCLK: case (int)WinApi.Messages.WM_LBUTTONDBLCLK: if (!MaximizeBox) { return; } break; case (int)WinApi.Messages.WM_NCHITTEST: WinApi.HitTest ht = HitTestNCA(m.HWnd, m.WParam, m.LParam); if (ht != WinApi.HitTest.HTCLIENT) { m.Result = (IntPtr)ht; return; } break; case (int)WinApi.Messages.WM_DWMCOMPOSITIONCHANGED: break; } base.WndProc(ref m); switch (m.Msg) { case (int)WinApi.Messages.WM_GETMINMAXINFO: OnGetMinMaxInfo(m.HWnd, m.LParam); break; } }
protected override void WndProc(ref Message m) { switch (m.Msg) { case (int)WinApi.Messages.WM_NCHITTEST: WinApi.HitTest ht = HitTestNCA(m.HWnd, m.WParam, m.LParam); if (ht != WinApi.HitTest.HTCLIENT) { m.Result = (IntPtr)ht; return; } break; case (int)WinApi.Messages.WM_NCLBUTTONUP: TargetForm.Activate(); break; } base.WndProc(ref m); }
// Token: 0x060003D1 RID: 977 RVA: 0x0000CD68 File Offset: 0x0000AF68 protected override void WndProc(ref Message m) { if (base.DesignMode) { base.WndProc(ref m); return; } int msg = m.Msg; if (msg <= 163) { if (msg != 132) { if (msg != 163) { goto IL_B8; } } else { WinApi.HitTest hitTest = this.HitTestNCA(m.HWnd, m.WParam, m.LParam); if (hitTest != WinApi.HitTest.HTCLIENT) { m.Result = (IntPtr)((long)hitTest); return; } goto IL_B8; } } else if (msg != 274) { if (msg != 515) { goto IL_B8; } } else { int num = m.WParam.ToInt32() & 65520; int num2 = num; if (num2 != 61456) { if (num2 != 61488 && num2 != 61728) { goto IL_B8; } goto IL_B8; } else { if (!this.Movable) { return; } goto IL_B8; } } if (!base.MaximizeBox) { return; } IL_B8: base.WndProc(ref m); int msg2 = m.Msg; if (msg2 != 36) { return; } this.OnGetMinMaxInfo(m.HWnd, m.LParam); }
private WinApi.HitTest HitTestNCA(IntPtr hwnd, IntPtr wparam, IntPtr lparam) { if (DesignMode) { return(WinApi.HitTest.HTCLIENT); } Rectangle windowRect = new Rectangle(); Point cursorPoint = new Point(); WinApi.GetCursorPos(out cursorPoint); WinApi.GetWindowRect(this.Handle, ref windowRect); cursorPoint.X -= windowRect.Left; cursorPoint.Y -= windowRect.Top; int width = windowRect.Right - windowRect.Left; int height = windowRect.Bottom - windowRect.Top; bool bUpdate = false; WinApi.HitTest ht = WinApi.HitTest.HTNOWHERE; if (MostraBarraTitolo) { if (MetroWindowButtons.ContainsKey(MetroWindowButton.TipoMetroWindowButton.Close)) { if (MetroWindowButtons[MetroWindowButton.TipoMetroWindowButton.Close].ClientRectangle.Contains(cursorPoint)) { if (MetroWindowButtons[MetroWindowButton.TipoMetroWindowButton.Close].IsHover == false) { MetroWindowButtons[MetroWindowButton.TipoMetroWindowButton.Close].IsHover = true; bUpdate = true; } ht = WinApi.HitTest.HTCLOSE; } else { if (MetroWindowButtons[MetroWindowButton.TipoMetroWindowButton.Close].IsHover == true) { MetroWindowButtons[MetroWindowButton.TipoMetroWindowButton.Close].IsHover = false; bUpdate = true; } if (MetroWindowButtons[MetroWindowButton.TipoMetroWindowButton.Close].IsClick == true) { MetroWindowButtons[MetroWindowButton.TipoMetroWindowButton.Close].IsClick = false; MetroWindowButtons[MetroWindowButton.TipoMetroWindowButton.Close].IsHover = true; bUpdate = true; } } } if (MetroWindowButtons.ContainsKey(MetroWindowButton.TipoMetroWindowButton.Maximize)) { if (MetroWindowButtons[MetroWindowButton.TipoMetroWindowButton.Maximize].ClientRectangle.Contains(cursorPoint)) { if (MetroWindowButtons[MetroWindowButton.TipoMetroWindowButton.Maximize].IsHover == false) { MetroWindowButtons[MetroWindowButton.TipoMetroWindowButton.Maximize].IsHover = true; bUpdate = true; } ht = WinApi.HitTest.HTMAXBUTTON; } else { if (MetroWindowButtons[MetroWindowButton.TipoMetroWindowButton.Maximize].IsHover == true) { MetroWindowButtons[MetroWindowButton.TipoMetroWindowButton.Maximize].IsHover = false; bUpdate = true; } if (MetroWindowButtons[MetroWindowButton.TipoMetroWindowButton.Maximize].IsClick == true) { MetroWindowButtons[MetroWindowButton.TipoMetroWindowButton.Maximize].IsClick = false; MetroWindowButtons[MetroWindowButton.TipoMetroWindowButton.Maximize].IsHover = true; bUpdate = true; } } } if (MetroWindowButtons.ContainsKey(MetroWindowButton.TipoMetroWindowButton.Minimize)) { if (MetroWindowButtons[MetroWindowButton.TipoMetroWindowButton.Minimize].ClientRectangle.Contains(cursorPoint)) { if (MetroWindowButtons[MetroWindowButton.TipoMetroWindowButton.Minimize].IsHover == false) { MetroWindowButtons[MetroWindowButton.TipoMetroWindowButton.Minimize].IsHover = true; bUpdate = true; } ht = WinApi.HitTest.HTMINBUTTON; } else { if (MetroWindowButtons[MetroWindowButton.TipoMetroWindowButton.Minimize].IsHover == true) { MetroWindowButtons[MetroWindowButton.TipoMetroWindowButton.Minimize].IsHover = false; bUpdate = true; } if (MetroWindowButtons[MetroWindowButton.TipoMetroWindowButton.Minimize].IsClick == true) { MetroWindowButtons[MetroWindowButton.TipoMetroWindowButton.Minimize].IsClick = false; MetroWindowButtons[MetroWindowButton.TipoMetroWindowButton.Minimize].IsHover = true; bUpdate = true; } } } } if (StileBordo == MetroWindowBorderStyle.Fisso) { return(WinApi.HitTest.HTCLIENT); } if (bUpdate) { UpdateDisplay(); } if (ht != WinApi.HitTest.HTNOWHERE) { return(ht); } if (new Rectangle(1, 1, WindowRectangle.Width - 2, AltezzaBarraTitolo - 1).Contains(cursorPoint)) { return(WinApi.HitTest.HTCAPTION); } else { ResetWindowButtons(); } return(WinApi.HitTest.HTCLIENT); }
protected override void WndProc(ref Message m) { if (DesignMode) { base.WndProc(ref m); return; } switch (m.Msg) { case WinApi.Messages.WM_NCHITTEST: WinApi.HitTest ht = HitTestNCA(m.HWnd, m.WParam, m.LParam); if (ht != WinApi.HitTest.HTCLIENT) { m.Result = (IntPtr)ht; return; } break; case WinApi.Messages.WM_SYSCOMMAND: int sc = m.WParam.ToInt32() & 0xFFF0; switch (sc) { case WinApi.Messages.SC_MOVE: if (!Movable) { return; } break; case WinApi.Messages.SC_MAXIMIZE: break; case WinApi.Messages.SC_RESTORE: break; } break; case WinApi.Messages.WM_NCLBUTTONDBLCLK: case WinApi.Messages.WM_LBUTTONDBLCLK: // I think this one can be removed... if (!MaximizeBox) { return; } break; case WinApi.Messages.WM_SIZING: OnWmSizing(m.WParam, m.LParam); break; case WinApi.Messages.WM_DWMCOMPOSITIONCHANGED: // Vista API only - but we should never receive the message on XP SessionSwitch("WM_DWMCOMPOSITIONCHANGED"); //UpdateSessionState(); break; case WinApi.Messages.WM_DISPLAYCHANGE: SessionSwitch("WM_DISPLAYCHANGE"); break; } base.WndProc(ref m); // some messages are better post-processed ... switch (m.Msg) { case WinApi.Messages.WM_GETMINMAXINFO: OnGetMinMaxInfo(m.HWnd, m.LParam); //m.Result = IntPtr.Zero; break; } }
protected override void WndProc(ref Message m) { if (DesignMode) { base.WndProc(ref m); return; } switch (m.Msg) { case (int)WinApi.Messages.WM_SYSCOMMAND: int sc = m.WParam.ToInt32() & 0xFFF0; switch (sc) { case (int)WinApi.Messages.SC_MOVE: if (!Movable) { return; } break; case (int)WinApi.Messages.SC_MAXIMIZE: break; case (int)WinApi.Messages.SC_RESTORE: break; } break; case (int)WinApi.Messages.WM_NCLBUTTONDBLCLK: case (int)WinApi.Messages.WM_LBUTTONDBLCLK: if (!MaximizeBox) { return; } break; case (int)WinApi.Messages.WM_NCHITTEST: WinApi.HitTest ht = HitTestNCA(m.HWnd, m.WParam, m.LParam); if (ht != WinApi.HitTest.HTCLIENT) { m.Result = (IntPtr)ht; return; } break; case (int)WinApi.Messages.WM_DWMCOMPOSITIONCHANGED: break; } base.WndProc(ref m); switch (m.Msg) { case (int)WinApi.Messages.WM_GETMINMAXINFO: OnGetMinMaxInfo(m.HWnd, m.LParam); break; case (int)WinApi.Messages.WM_SIZE: if (windowButtonList != null) { MetroFormButton btn; windowButtonList.TryGetValue(WindowButtons.Maximize, out btn); if (WindowState == FormWindowState.Normal) { if (btn != null) { btn.Text = "1"; } if (shadowForm != null) { shadowForm.Visible = true; } } if (WindowState == FormWindowState.Maximized) { if (btn != null) { btn.Text = "2"; } } } break; } }
protected override void WndProc(ref Message m) { switch (m.Msg) { case (int)WinApi.Messages.WM_SYSCOMMAND: if (m.WParam.ToInt32() == (int)WinApi.Messages.SC_RESTORE) { this.Height = _iStoreHeight; } else if (m.WParam.ToInt32() == (int)WinApi.Messages.SC_MAXIMIZE) { _iStoreHeight = this.Height; } break; case (int)WinApi.Messages.WM_NCLBUTTONDBLCLK: case (int)WinApi.Messages.WM_LBUTTONDBLCLK: if (!MaximizeBox) { return; } break; case (int)WinApi.Messages.WM_NCHITTEST: WinApi.HitTest ht = HitTestNCA(m.HWnd, m.WParam, m.LParam); if (ht != WinApi.HitTest.HTCLIENT) { m.Result = (IntPtr)ht; return; } break; case (int)WinApi.Messages.WM_NCCALCSIZE: NCCalcSize(ref m); return; case (int)WinApi.Messages.WM_NCPAINT: NCPaint(ref m); return; case (int)WinApi.Messages.WM_NCLBUTTONDOWN: if (NCMouseLButtonDown(ref m)) { return; } break; case (int)WinApi.Messages.WM_NCMOUSELEAVE: ResetWindowButtons(); UpdateDisplay(); break; case (int)WinApi.Messages.WM_NCLBUTTONUP: if (NCMouseLButtonUp(ref m)) { return; } break; case (int)WinApi.Messages.WM_SETTEXT: base.WndProc(ref m); NCPaint(ref m); return; case (int)WinApi.Messages.WM_ACTIVATE: bool active = (m.WParam != IntPtr.Zero); if (WindowState == FormWindowState.Minimized) { base.WndProc(ref m); return; } else { base.WndProc(ref m); NCPaint(ref m); m.Result = new IntPtr(1); return; } } base.WndProc(ref m); if (m.Msg == (int)WinApi.Messages.WM_NCLBUTTONDBLCLK || m.Msg == (int)WinApi.Messages.WM_LBUTTONDBLCLK) { MetroWindowButton button = new MetroWindowButton(); if (MetroWindowButtons.TryGetValue(MetroWindowButton.TipoMetroWindowButton.Maximize, out button)) { button.MetroWindowButtonType = MetroWindowButton.TipoMetroWindowButton.Maximize; UpdateDisplay(); } } }
public void HitMouseDown(WinApi.HitTest hit) { WinApi.ReleaseCapture(); WinApi.SendMessage(Handle, (int)WinApi.Messages.WM_NCLBUTTONDOWN, (int)hit, 0); }
protected override void WndProc(ref Message m) { if (DesignMode) { base.WndProc(ref m); return; } switch (m.Msg) { case (int)WinApi.Messages.WM_SYSCOMMAND: int sc = m.WParam.ToInt32() & 0xFFF0; switch (sc) { case (int)WinApi.Messages.SC_MOVE: if (!Movable) { return; } break; case (int)WinApi.Messages.SC_MAXIMIZE: break; case (int)WinApi.Messages.SC_RESTORE: break; } break; case (int)WinApi.Messages.WM_NCLBUTTONDBLCLK: case (int)WinApi.Messages.WM_LBUTTONDBLCLK: if (!MaximizeBox) { return; } break; case (int)WinApi.Messages.WM_NCHITTEST: WinApi.HitTest ht = HitTestNCA(m.HWnd, m.WParam, m.LParam); if (ht != WinApi.HitTest.HTCLIENT) { m.Result = (IntPtr)ht; return; } break; case (int)WinApi.Messages.WM_DWMCOMPOSITIONCHANGED: break; } base.WndProc(ref m); if (Resizable) { switch (m.Msg) { case (int)WinApi.Messages.WM_GETMINMAXINFO: OnGetMinMaxInfo(m.HWnd, m.LParam); break; case (int)WinApi.Messages.WM_NCHITTEST: Point vPoint = new Point((int)m.LParam & 0xFFFF, (int)m.LParam >> 16 & 0xFFFF); vPoint = PointToClient(vPoint); if (vPoint.X <= 5) { m.Result = (IntPtr)HTLEFT; } else if (vPoint.X >= ClientSize.Width - 5) { m.Result = (IntPtr)HTRIGHT; } else if (vPoint.Y <= 5) { m.Result = (IntPtr)HTTOP; } else if (vPoint.Y >= ClientSize.Height - 5) { m.Result = (IntPtr)HTBOTTOM; } break; } } }