Sets the specified input language as the input language for the current thread.
[Visual Basic] Public Shared Function SetCurrentInputLanguage( _ ByVal inputLanguage As InputLanguage, _ ByVal flags As Integer _ ) As InputLanguage [C#] public static InputLanguage SetCurrentInputLanguage( InputLanguage inputLanguage, int flags ); [C++] public: static InputLanguage* SetCurrentInputLanguage( InputLanguage* inputLanguage, int flags ); [JScript] public static function SetCurrentInputLanguage( inputLanguage : InputLanguage, flags : int ) : InputLanguage;
An InputLanguage that represents the previously selected input language.
Exception Type | Condition |
---|---|
Exception | Could not change to the specified input language. |
The following table shows possible values for the flags parameter. The flags can be combined.
Flag | Description |
---|---|
SET_FOR_PROCESS | Sets the new input language for the process, not just for the current thread. |
MOVE_TO_FRONT | Moves the new input language to the front of the language list. |
The following example sets the default input language as the current input language.
First GetDefaultInputLanguage is called to get the system default language. Then GetCurrentInputLanguage is called to get the current input language. The results are printed in a text box. Then the current input language is changed to the default by calling SetCurrentInputLanguage with the default input language. The new current input language is displayed in a text box.
This code assumes Button1 and TextBox1 have been instantiated.
[C#]
public void SetNewCurrentLanguage() { //Get the default and current languages. InputLanguage myDefaultLanguage = InputLanguage.GetDefaultInputLanguage(); InputLanguage myCurrentLanguage = InputLanguage.GetCurrentInputLanguage(); textBox1.Text = "Current input language is: " + myCurrentLanguage.GetCulture().EnglishName + '\n'; textBox1.Text += "Default input language is: " + myDefaultLanguage.GetCulture().EnglishName + '\n'; //Change the current input language to the default and print the new current language. InputLanguage.SetCurrentInputLanguage(myDefaultLanguage, 0); textBox1.Text += "Current input language is now: " + myCurrentLanguage.GetCulture().EnglishName; }
InputLanguage Class | InputLanguage Members | System.WinForms Namespace | GetDefaultInputLanguage | GetCurrentInputLanguage | Equals