[英]WPF windows is hidden when call win32
I have a win32 application (written in Delphi), that calls some WPF windows. 我有一个Win32应用程序(用Delphi编写),它调用了一些WPF窗口。 These WPF windows calls other windows in win32 Delphi projects (to reuse some code).
这些WPF窗口调用win32 Delphi项目中的其他窗口(以重用某些代码)。 When I do this, it hides (send to background) the WPF windows.
当我这样做时,它将隐藏(发送到后台)WPF窗口。
These win32 windows are in COM dlls. 这些win32窗口位于COM dll中。
There is a way to avoid this behavior? 有办法避免这种行为吗?
I need something like this: 我需要这样的东西:
+--------------------------------------------------
| win32
|
|
|
| +-------------------------------------+
| | wpf |
| | |
| | |
| | |
| | +--------------------+ |
| | | win32 | |
| +--| |-------------+
| | |
| +--------------------+
|
|
but I get: 但我得到:
+--------------------------------------------------
| win32
|
|
|
|
|
|
|
|
| +--------------------+
| | win32 |
| | |
| | |
| +--------------------+
|
|
In delphi main project I have used "CreateOleObject" to get access to wpf code. 在delphi主项目中,我使用“ CreateOleObject”来访问wpf代码。 In WPF, the windows is opened using "ShowDialog()" command.
在WPF中,使用“ ShowDialog()”命令打开窗口。 Again, in WPF I call delphi, using interop references to my win32 dlls.
同样,在WPF中,我使用对Win32 dll的互操作引用来调用delphi。
Ok, the code used is bellow: 好的,下面的代码如下:
Delphi main application: Delphi主要应用:
var dll : OleVariant;
begin
dll := CreateOleObject("MyDllinCSharp.ClassName");
dll.DoSomething(...);
at this point, wpf windows comes to front: 在这一点上,WPF Windows来到了前面:
wpf code: WPF代码:
var form = new MyForm();
form.ShowDialog();
In xaml, nothing important, only a basic window: 在xaml中,没有什么重要的,只有一个基本窗口:
<Window x:Class="MyForm"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Reverter" Height="432" Width="500" WindowStartupLocation="CenterScreen">
now in c#, I will call a delphi DLL, after I reference the COM dll in c# project: 现在在c#中,在c#项目中引用COM dll之后,我将调用delphi DLL:
var dll = Delphi.CreateInstance("delphidll", "Interfacename") as IMyProcess;
dll.DoSomethingInDelphi(....);
I got this to work, hosting the Win32 window inside WPF element, like this walkthrough: 我通过在WPF元素中托管Win32窗口来完成此工作,如以下演练:
http://msdn.microsoft.com/en-us/library/ms752055.aspx http://msdn.microsoft.com/en-us/library/ms752055.aspx
Now I havesomething like this: 现在我有这样的东西:
+--------------------------------------------------
| win32
|
|
|
| +-------------------------------------+
| | wpf |
| | |
| | |
| | -wpf------------------ |
| | |+--------------------+| |
| | || win32 || |
| +-|| ||------------+
| || ||
| |+--------------------+|
| ----------------------
|
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.