CodeWalker/CodeWalker.WinForms/TextBoxFix.cs
2017-09-21 20:33:05 +10:00

39 lines
1.0 KiB
C#

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace CodeWalker.WinForms
{
public partial class TextBoxFix : TextBox
{
public TextBoxFix()
{
InitializeComponent();
}
protected override void OnPaint(PaintEventArgs pe)
{
base.OnPaint(pe);
}
protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
{
//Fix for Ctrl-A not working in multiline textboxes.
const int WM_KEYDOWN = 0x100;
var keyCode = (Keys)(msg.WParam.ToInt32() & Convert.ToInt32(Keys.KeyCode));
if ((msg.Msg == WM_KEYDOWN && keyCode == Keys.A) && (ModifierKeys == Keys.Control) && Focused)
{
SelectAll();
return true;
}
return base.ProcessCmdKey(ref msg, keyData);
}
}
}