Excel losing focus, but remains active !

N

Nandan

Hello,
I have written an excel add-in. The add-in has a C++ shim, and the UI
is in .NET.
In the add-in (C++ part) I use the ShowDialog method to display a
browser.
I pass the excel handle, as an argument to the ShowDialog method.


When i close the browser, Excel should regain focus and then for a
brief moment, it appears to do so..(i.e. the window title bar becomes
dark blue) but then focus dissapears (to i don't know where).

However excel is still the active application!
If i start typing immediately I can type fine inside excel, I can
access all of the menus, use the row keys to go up and down the
worksheet!
But the title bar is still a lighter shade of blue (as if it is not
the active application).

How is this even possible ? If i am typing in excel shouldnt this
window be the active window?

The window becomes "active" if i resize a column, or if i switch to an
other window and come back. or minimize and restore. Deleting data
does not seem to do it.

I have tried various things, such as setforegroundwindow, setFocus
etc.
The problem is, that the part where the window loses focus, is in the
Excel code, and occurs after my code has run. Its not in my code. So i
don't know what excel is doing...

Can someone please shed light on what is going on? or at least some
hints..

I turned off speech recognition, as this can cause weird focus issues,
but it makes no difference to me.
http://support.microsoft.com/kb/313176/en-us
 
H

haiying

Not sure if this will of any help:

_Application objApp;
objApp.CreateDispatch(_T("Excel.Application"));
........
objApp.SetVisible(TRUE);
objApp.SetUserControl(TRUE);
objApp.ReleaseDispatch();
objApp.Quit();
 

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