Focus not being set to Form Window

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
 
C

ClayB

Try setting th eTopMost property on your form to see if that affects
this.

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

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

splat007

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
 

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