Modal Dialog in child WPF window

673 Views Asked by At

I have the following scenario in a multi-process C# WPF application:

MainApplication has a placeholder to contain child processes' HWNDs.

Using SetParent and some more windows functions (P/Invoke, Windows API) I can set child applications to live inside main application without letting the user know they are 2 processes. Until now everything works good.

The problem is that every time I open a Modal Dialog from the child process, the modal dialog is actually not modal. Instead If I run the child application (same exe) standalone, the modal dialog works correctly.

Using Spy++ I realized that the owner of the modal dialog is the Desktop if running as a child process (not working as intended), or the correct application window, if running standalone (working as intended).

I also tried to use ::SetParent on the dialog, but nothing change, It seems that when the dialog is created from a hosted process, WPF can't set it's parent correctly.

Am I doing something wrong?

EDIT: of course I tried to set dialog's owner using wpf methods (also WindowInteropHelper)

0

There are 0 best solutions below