InputLanguage InputLanguage InputLanguage InputLanguage Class

定义

提供方法和字段以管理输入语言。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
继承
InputLanguageInputLanguageInputLanguageInputLanguage

示例

下面的代码示例获取已安装语言的列表。The following code example gets a list of installed languages. 该示例需要textBox1已经实例化且已设置textBox1.MultiLinetrue的。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. 该示例需要textBox1已经实例化且已设置textBox1.MultiLinetrue的。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

注解

输入语言是一种区域性/键盘布局对, 用于确定键盘上的物理键映射到语言中的字符的方式。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. 输入语言基于 Windows 输入法区域设置标识符, 如平台 SDK 函数GetKeyboardLayout返回的。The input language is based on a Windows input locale identifier, such as that returned by the Platform SDK function, GetKeyboardLayout. 输入区域设置标识符也称为键盘布局 (HKL) 值的句柄。The input locale identifier is also called a handle to a keyboard layout (HKL) value.

使用提供static的方法可以查找系统的所有已安装的映射, 并更改线程或进程的输入语言。Use the static methods provided to find all installed mappings of the system and to change the input language for a thread or process. 调用CurrentInputLanguage以获取当前输入语言。Call CurrentInputLanguage to get the current input language. 调用DefaultInputLanguage默认输入语言。Call DefaultInputLanguage for the default input language. 调用InstalledInputLanguages以获取此系统中所有已安装的语言。Call InstalledInputLanguages to get all the installed languages in this system. 列出了所有已安装的语言后, 请使用CurrentInputLanguage将当前输入语言更改为另一种语言。After you have a list of all the installed languages, use CurrentInputLanguage to change the current input language to a different language.

属性

Culture Culture Culture Culture

获取当前输入语言的区域性。Gets the culture of the current input language.

CurrentInputLanguage CurrentInputLanguage CurrentInputLanguage CurrentInputLanguage

获取或设置当前线程的输入语言。Gets or sets the input language for the current thread.

DefaultInputLanguage DefaultInputLanguage DefaultInputLanguage DefaultInputLanguage

获取系统的默认输入语言。Gets the default input language for the system.

Handle Handle Handle Handle

获取输入语言的句柄。Gets the handle for the input language.

InstalledInputLanguages InstalledInputLanguages InstalledInputLanguages InstalledInputLanguages

获取所有已安装输入语言的列表。Gets a list of all installed input languages.

LayoutName LayoutName LayoutName LayoutName

在当前键盘布局名称出现在计算机操作系统的区域设置中时获取该名称。Gets the name of the current keyboard layout as it appears in the regional settings of the operating system on the computer.

方法

Equals(Object) Equals(Object) Equals(Object) Equals(Object)

指定两个输入语言是否相同。Specifies whether two input languages are equal.

FromCulture(CultureInfo) FromCulture(CultureInfo) FromCulture(CultureInfo) FromCulture(CultureInfo)

返回与指定区域性关联的输入语言。Returns the input language associated with the specified culture.

GetHashCode() GetHashCode() GetHashCode() GetHashCode()

返回此输入语言的哈希代码。Returns the hash code for this input language.

GetType() GetType() GetType() GetType()

获取当前实例的 TypeGets the Type of the current instance.

(Inherited from Object)
MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

创建当前 Object 的浅表副本。Creates a shallow copy of the current Object.

(Inherited from Object)
ToString() ToString() ToString() ToString()

返回表示当前对象的字符串。Returns a string that represents the current object.

(Inherited from Object)

适用于