Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hosted .NET runtime and window focus, problem and inconsistencies

Tags:

.net

focus

winapi

We have a Win32 application that hosts the .NET runtime and opens up .NET managed forms from the Win32 portion of the application.

These windows are always opened as modal windows.

On some machines, when these windows are closed, the Win32 window that lies behind does not get focus, but gets sent behind Word, Outlook, or whatever else you might have open.

Also, sometimes, if we open such a .NET form, then alt-tab to Word or some other application, and then click on the taskbar icon for our app, the Win32 window appear. This is of course still waiting for the modal .NET window to close, so it is of course unusable. If we alt-tab to something else and just minimize that other thing, then our .NET window reappears.

The inconsistent part is that this occurs on only some machines, and not all. On many machines, mine included, it works exactly as expected. Focus to the right window works every time.

I don't doubt we have done something wrong, but I can't figure out what the problem is.

Does anyone have any idea what I should be looking for? We've looked at the .NET runtimes installed, and since two such machines where it works on one but not the other are both developer machines, they contain the same service packs for .NET and so on.


Edit: Well, @sam, you were right in that we had some different setups in this lane. Both machines run Windows XP SP3, but mine was running classic windows theme, and the other was running the new XP theme. Changing theme on that other computer to classic removed the problem, but changing it back to the XP theme did not make it reappear.

So now we have two machines where it work, and the customer still has the problem, even though the customer apparently runs classic theme.

like image 829
Lasse V. Karlsen Avatar asked Dec 04 '25 20:12

Lasse V. Karlsen


1 Answers

Lately I noticed that window focus is set differently on windows vista Aero as it used to be on XP. Instead of the last activated window of an app receiving the focus, the main window will receive focus on re-activation.
Funny thing is, changing vista to the old style windows theme (classic or basic), the focus will be set to the child window which last had it, just like it is on XP.

Your problem might be very different, but maybe you got different OS versions?

like image 81
Sam Avatar answered Dec 06 '25 15:12

Sam



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!