Starnge problem with Focus() and LostFocus()

G

Guest

Hi,

i have a textBox that when it get focused i'm sending ALT+SHIFT (to change
the current language) i compare the current language to the one i need (using
InputLanguage.CurrentInputLanguage), and when it loses focus i compare the
current language to the default language and if are different i'm sending
alt+shift again to change back to the default language.
My problem is that if i move from one TextBox to the Second and they both
have these events, only one ALT+SHIFT sending instead of two (one time it
suppose to return to the defualt language and on the second to change back to
the language i need). if i move from one TextBox that has these events to one
that doesn't have and then to TextBox that has this event it works fine. I
think that these two event (Focus and LostFocus) are too fast for the
ALT+SHIFT sending (the Current Language is not updated so quickly), i thought
maybe to send a Wait or Sleep before i'm sending ALT+SHIFT but i couldn't do
it (Sleep works only on Threads), Does anyone have an idea?
Thanks,
 
I

Ignacio Machin \( .NET/ C# MVP \)

Hi,

You can use Sleep in the UI thread too:
Thread.CurrentThread.Sleep( );

It not a good idea though.

You do not need to send an ALT+SHIFT CurrentInputLanguage is a set/get
property, so you can set it from the code.

I think that will solve your problem


cheers,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top