private void CaptureClicks() { Application.AddMessageFilter(MessageFilterTool.Create(m => capturedMessages.Contains((WM)m.Msg), m => { if ((WM)m.Msg == WM.LBUTTONDOWN) { StartDrag(); } else if ((WM)m.Msg == WM.RBUTTONDOWN) { StartClose(); } })); }
public MessageForm(string title = null, string content = null) { InitializeComponent(); padding = richTextBox1.Location.X; MinClientSize = new Size(200, GuiTool.CalculateTextSize(Content, TextFont).Height + padding * 2); MaxClientSize = new Size(1600, 1000); MinimumSize = this.ClientToFull(MinClientSize); MaximumSize = this.ClientToFull(MaxClientSize); richTextBox1.TextChanged += (o, e) => richTextBox1.ScrollToBottom(); richTextBox1.MouseWheel += (o, e) => richTextBox1.Scroll(e.Delta, false); richTextBox1.MouseDown += (o, e) => WinAPI.HideCaret(richTextBox1.Handle); richTextBox1.GotFocus += (o, e) => WinAPI.HideCaret(richTextBox1.Handle); richTextBox1.MouseWheel += (o, e) => WinAPI.HideCaret(richTextBox1.Handle); SetTitle(title); SetContent(content); Location = new Area(size: Size).CenterOn(Monitor.Primary.WorkArea); Application.AddMessageFilter(MessageFilterTool.Create(m => (WM)m.Msg == WM.CHAR && !KeyHandler.IsDown(Key.LCtrl), m => Close())); }