簡體   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