Basically I want to write an application which would display the current language as a tray icon. Mainly I can code C++ and C#. Guess Google would help me out but I would like to ask it here first, since the community, the knowledge here is something I trust.
(Never wrangled with such parts of the system so far. So that's why I would like to ask the community.)
Okay thanks to your help, I managed to discover two ways. Using the DllImport
in C# (importing the user32.dll
) and the InputLanguage
.
Found a snippet:
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;
}
I applied this like the following:
InputLanguage myCurrentLanguage = InputLanguage.CurrentInputLanguage;
notifyIcon.Text = myCurrentLanguage.LayoutName + '\n' + myCurrentLanguage.Culture.DisplayName;
This displays it if you hover it above the icon. However, it won't update on switch, nor show the layout as text in the tray area. For that, I found a "Drawing in VB.NET" article, maybe this will help me working out this issue. About the switch detect, that's a good question.