InputLanguage Class
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Provides methods and fields to manage the input language. This class cannot be inherited.
public ref class InputLanguage sealed
public sealed class InputLanguage
type InputLanguage = class
Public NotInheritable Class InputLanguage
- Inheritance
-
InputLanguage
Examples
The following code example gets a list of installed languages. The example requires that textBox1
has been instantiated and that textBox1.MultiLine
has been set to true
.
public:
void GetLanguages()
{
// Gets the list of installed languages.
for each ( InputLanguage^ lang in InputLanguage::InstalledInputLanguages )
{
textBox1->Text = String::Concat( textBox1->Text, lang->Culture->EnglishName, "\n" );
}
}
public void GetLanguages() {
// Gets the list of installed languages.
foreach(InputLanguage lang in InputLanguage.InstalledInputLanguages) {
textBox1.Text += lang.Culture.EnglishName + '\n';
}
}
Public Sub GetLanguages()
' Gets the list of installed languages.
Dim lang As InputLanguage
For Each lang In InputLanguage.InstalledInputLanguages
textBox1.Text &= lang.Culture.EnglishName & ControlChars.Cr
Next lang
End Sub
The next example sets the default input language as the current input language. The example requires that textBox1
has been instantiated and that textBox1.MultiLine
has been set to true
.
public:
void SetNewCurrentLanguage()
{
// Gets the default, and current languages.
InputLanguage^ myDefaultLanguage = InputLanguage::DefaultInputLanguage;
InputLanguage^ myCurrentLanguage = InputLanguage::CurrentInputLanguage;
textBox1->Text = String::Format( "Current input language is: {0}\nDefault input language is: {1}\n",
myCurrentLanguage->Culture->EnglishName, myDefaultLanguage->Culture->EnglishName );
// Changes the current input language to the default, and prints the new current language.
InputLanguage::CurrentInputLanguage = myDefaultLanguage;
textBox1->Text = String::Format( "{0}Current input language is now: {1}",
textBox1->Text, myDefaultLanguage->Culture->EnglishName );
}
public void SetNewCurrentLanguage() {
// Gets the default, and current languages.
InputLanguage myDefaultLanguage = InputLanguage.DefaultInputLanguage;
InputLanguage myCurrentLanguage = InputLanguage.CurrentInputLanguage;
textBox1.Text = "Current input language is: " + myCurrentLanguage.Culture.EnglishName + '\n';
textBox1.Text += "Default input language is: " + myDefaultLanguage.Culture.EnglishName + '\n';
// Changes the current input language to the default, and prints the new current language.
InputLanguage.CurrentInputLanguage = myDefaultLanguage;
textBox1.Text += "Current input language is now: " + myDefaultLanguage.Culture.EnglishName;
}
Public Sub SetNewCurrentLanguage()
' Gets the default, and current languages.
Dim myDefaultLanguage As InputLanguage = InputLanguage.DefaultInputLanguage
Dim myCurrentLanguage As InputLanguage = InputLanguage.CurrentInputLanguage
textBox1.Text = "Current input language is: " & _
myCurrentLanguage.Culture.EnglishName & ControlChars.Cr
textBox1.Text &= "Default input language is: " & _
myDefaultLanguage.Culture.EnglishName & ControlChars.Cr
' Changes the current input language to the default, and prints the new current language.
InputLanguage.CurrentInputLanguage = myDefaultLanguage
textBox1.Text &= "Current input language is now: " & _
myDefaultLanguage.Culture.EnglishName
End Sub
Remarks
An input language is a culture/keyboard layout pair that determines how the physical keys on a keyboard map or plot to characters in a language. The input language is based on a Windows input locale identifier, such as that returned by the Platform SDK function, GetKeyboardLayout
. The input locale identifier is also called a handle to a keyboard layout (HKL) value.
Use the static
methods provided to find all installed mappings of the system and to change the input language for a thread or process. Call CurrentInputLanguage to get the current input language. Call DefaultInputLanguage for the default input language. Call InstalledInputLanguages to get all the installed languages in this system. After you have a list of all the installed languages, use CurrentInputLanguage to change the current input language to a different language.
Properties
Culture |
Gets the culture of the current input language. |
CurrentInputLanguage |
Gets or sets the input language for the current thread. |
DefaultInputLanguage |
Gets the default input language for the system. |
Handle |
Gets the handle for the input language. |
InstalledInputLanguages |
Gets a list of all installed input languages. |
LayoutName |
Gets the name of the current keyboard layout as it appears in the regional settings of the operating system on the computer. |
Methods
Equals(Object) |
Specifies whether two input languages are equal. |
FromCulture(CultureInfo) |
Returns the input language associated with the specified culture. |
GetHashCode() |
Returns the hash code for this input language. |
GetType() |
Gets the Type of the current instance. (Inherited from Object) |
MemberwiseClone() |
Creates a shallow copy of the current Object. (Inherited from Object) |
ToString() |
Returns a string that represents the current object. (Inherited from Object) |
Applies to
.NET