.NET runtime hosting and window focus, problems and inconsistencies

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

These windows always open as modal windows.

On some computers, when these windows are closed, the Win32 window that is behind does not receive focus, but goes for Word, Outlook, or something else that you could open.

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

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

I have no doubt that we did something wrong, but I can’t understand what the problem is.

Does anyone know what I should look for? We looked at the installed .NET runtimes, and since two such machines, where they work on one but not the other, are both machines for developers, they contain the same service packs for .NET, etc.


Edit: Ok, @sam , you were right in that we had different settings on this strip. Both machines are running Windows XP SP3, but I had a classic Windows theme, and the other had a new XP theme. Changing the theme on this other computer in the classic style fixed the problem, but changing it to XP did not make it appear again.

So, now we have two machines where it works, and the client still has a problem, although the client apparently runs the classic theme.

+3
3

, - Windows Vista Aero, XP. , , .
- Windows ( ), , , XP.

, , , ?

+2

, WPF .

, 2.0 .NET , .NET.

control Windows ( ), IWin32Window, Win32 .

, NativeWindow WM_ACTIVATEAPP , , .NET, .

- , .net, .

, , ++\CLI, . , .

+1

, ( , .net 2.0 3.5)

,

Form2 form2 = new Form2();
form2.ShowDialog();

To display a modal popup, it now seems that the ShowDialog method does not use the form that calls ShowDialog as the default handler, so you need to do

form2.ShowDialog(this);

thus, the application to my knowledge knows which descriptor to return to, and thus always returns to your main one.

Additional information about ShowDialog form msdn: http://msdn.microsoft.com/en-us/library/w61zzfwe.aspx

0
source

Source: https://habr.com/ru/post/1698394/


All Articles