繁体   English   中英

调用win32时WPF窗口被隐藏

[英]WPF windows is hidden when call win32

我有一个Win32应用程序(用Delphi编写),它调用了一些WPF窗口。 这些WPF窗口调用win32 Delphi项目中的其他窗口(以重用某些代码)。 当我这样做时,它将隐藏(发送到后台)WPF窗口。

这些win32窗口位于COM dll中。

有办法避免这种行为吗?

我需要这样的东西:

+--------------------------------------------------
|  win32
|
|
|
|  +-------------------------------------+
|  |  wpf                                |
|  |                                     |
|  |                                     |
|  |                                     |
|  |  +--------------------+             |
|  |  |  win32             |             |
|  +--|                    |-------------+
|     |                    |             
|     +--------------------+             
|                                       
|  

但我得到:

+--------------------------------------------------
|  win32
|
|
|
|  
|  
|  
|  
|  
|     +--------------------+             
|     |  win32             |             
|     |                    |             
|     |                    |             
|     +--------------------+             
|                                       
|  

在delphi主项目中,我使用“ CreateOleObject”来访问wpf代码。 在WPF中,使用“ ShowDialog()”命令打开窗口。 同样,在WPF中,我使用对Win32 dll的互操作引用来调用delphi。

好的,下面的代码如下:

Delphi主要应用:

var dll : OleVariant;
begin
  dll := CreateOleObject("MyDllinCSharp.ClassName");
  dll.DoSomething(...);

在这一点上,WPF Windows来到了前面:

WPF代码:

var form = new MyForm();
form.ShowDialog();

在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">

现在在c#中,在c#项目中引用COM dll之后,我将调用delphi DLL:

var dll = Delphi.CreateInstance("delphidll", "Interfacename") as IMyProcess;

dll.DoSomethingInDelphi(....);

我通过在WPF元素中托管Win32窗口来完成此工作,如以下演练:

http://msdn.microsoft.com/en-us/library/ms752055.aspx

现在我有这样的东西:

+--------------------------------------------------
|  win32
|
|
|
|  +-------------------------------------+
|  |  wpf                                |
|  |                                     |
|  |                                     |
|  |  -wpf------------------             |
|  | |+--------------------+|            |
|  | ||  win32             ||            |
|  +-||                    ||------------+
|    ||                    ||             
|    |+--------------------+|             
|     ----------------------                                   
|  

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM