using System; using System.Windows.Forms; namespace ForestPadDesktop { /// <summary> /// Summary description for ForestPadDesktopMainForm. /// </summary> public class ForestPadDesktopBaseForm : System.Windows.Forms.Form { //protected System.Windows.Forms.TextBox textBoxSearch; public ForestPadDesktopBaseForm() { } protected override bool ProcessCmdKey(ref Message msg, Keys keyData) { const int WM_KEYDOWN = 0x100; const int WM_SYSKEYDOWN = 0x104; if ((msg.Msg == WM_KEYDOWN) || (msg.Msg == WM_SYSKEYDOWN)) { switch(keyData) { case Keys.Control | Keys.K : foreach(Control control in this.Controls) { if(control.GetType() == typeof(TextBox)) { if(control.Name == "textBoxSearch") { TextBox tb = (TextBox)control; tb.SelectionStart = 0; tb.SelectionLength = tb.Text.Length; tb.Focus(); } } } break; //tried to capture ctrl-a to select textbox -- doesn't work? // // case Keys.Control | Keys.A : // foreach(Control control in this.Controls) // { // if(control.GetType() == typeof(TextBox)) // { // if(control.Name == "textBox") // { // TextBox tb = (TextBox)control; // tb.SelectionStart = 0; // tb.SelectionLength = tb.Text.Length; // tb.Focus(); // } // } // } // break; } } return base.ProcessCmdKey(ref msg,keyData); } } }
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.
This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)