Focus not being set to Form Window

  • Thread starter Thread starter splat007
  • Start date Start date
S

splat007

Hi Everyone

I am developing a C# desktop application which has multiple forms
active at a given time.
The user wants the forms to be accessible by keyboard shortcuts even
when the application doesnt have focus.
I have written a keyboard hook which can capture shortcuts and then
activate the corresponding form.
By activate I mean the form becomes visible and focus is set on the
form.

Here is the code that I call when the form needs to be activated:
f.Show();
f.Activate();

Everything works fine when the focus is set on any of the application
windows. However if the focus is on some other application and I
activate the Form, the title bar blinks but the form doesn't get
activated.

Any ideas as to why I am not able set focus to my form, when the
user's focus is on another application?

Thanks in advance
Splat
 
Try setting th eTopMost property on your form to see if that affects
this.

f.TopMost = true;
f.Show();

=======================
Clay Burch
Syncfusion, Inc.
 
Try setting th eTopMost property on your form to see if that affects
this.

f.TopMost = true;
f.Show();

=======================
Clay Burch
Syncfusion, Inc.

Thanks Clay, I tried doing that it does bring the Form on front but
unfortunately it doesnt have the focus.
I tried doing f.Activate() and f.Focus() after f.Show() but it didnt
help.

The functionality I want is similar to Google Desktop. Where in when
you do ctrl-ctrl it opens the google search window no matter which
application you are focused on. If you have any more ideas do let me
know.

Regards
Splat
 
Back
Top