private void SwitchToLayout(IntPtr hwnd, IntPtr layout, string rule) { NativeMethods.SwitchKeyboardLayout(hwnd, layout); try { mNotifyIcon.SetText(String.Format(Resources.SwitchTooltip, layout.GetKeyboardLayoutName(), rule)); } catch { // Ignore setting the text, it's entirely optional } }