求高手:WPF窗体中加载ActiveX控件总是显示在最前的问题!!!!!

mrisw 2011-05-26 02:24:29
没有WPF板块?发SilverLight里也行吧?

求助:(求实例代码,100分只给实例代码。)

WPF窗体中通过WinFormHost加载的ActiveX控件(VC6开发)总是显示在WPF控件的前面,ZIndex对这个不起作用。
原因是WPF Window通过DirectX,OpenGL绘制,WinFormHost以及WinFrom通过GDI绘制,且是在另一个hWnd,且总是先绘制WPF的Control,再绘制WinFormHost的控件。

有没有办法把WPF控件放在WinFormHost控件之前呢?
(可否通过SetWindowPos这类的API来强行把WPF控件设置到TOP?怎样获得WPF控件的hWnd呢?)


例子程序如下:
<Window x:Class="AxOrderTest.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="600" Width="1000" Loaded="Window_Loaded">
<Grid Name="LayoutRoot">
<TextBlock Name="m_Info" TextWrapping="Wrap" Height="193" HorizontalAlignment="Left" Margin="794,190,0,0" Text="" VerticalAlignment="Top" Width="184" FontSize="14" />
<Button Content="this is a WPF control" Height="67" HorizontalAlignment="Left" Margin="681,87,0,0" Name="button1" VerticalAlignment="Top" Width="297" Click="button1_Click" />
</Grid>
</Window>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Windows.Forms.Integration;
using AxTest;

namespace AxOrderTest
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();

}

private void Window_Loaded(object sender, RoutedEventArgs e)
{
WindowsFormsHost wfh = new WindowsFormsHost();
AcroPDFReader thePDFReader = new AcroPDFReader();
wfh.Child = thePDFReader;
wfh.VerticalAlignment = VerticalAlignment.Top;
wfh.HorizontalAlignment = HorizontalAlignment.Left;
wfh.Width = 780;
wfh.Height = 550;
wfh.Opacity = 0.7;

thePDFReader.OpenPDFFile("C:\\CRF.pdf");

LayoutRoot.Children.Add(wfh);


}

private void button1_Click(object sender, RoutedEventArgs e)
{
m_Info.Text = "问题是:\n";
m_Info.Text += "怎样把 button1 放到 thePDFReader 的前面?";
}

}



using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace AxTest
{
public partial class AcroPDFReader : UserControl
{
public AcroPDFReader()
{
InitializeComponent();
}

public void OpenPDFFile(string strFileName)
{
m_axAcroPDF.LoadFile(strFileName);
}
}
}
...全文
625 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
cwolf2008 2011-11-24
  • 打赏
  • 举报
回复
...怎么解决的啊 LZ
people80911 2011-10-27
  • 打赏
  • 举报
回复
说下怎么解决的啊。不然这种帖子发来干啥。
uubuge 2011-10-18
  • 打赏
  • 举报
回复
靠。。。。
就不能说下怎么解决的?
mytudousi 2011-08-25
  • 打赏
  • 举报
回复
靠。。。。
people80911 2011-08-22
  • 打赏
  • 举报
回复
就不能说下怎么解决的?
people80911 2011-08-22
  • 打赏
  • 举报
回复
就不能说下怎么解决的?
yeyishun01 2011-08-10
  • 打赏
  • 举报
回复
怎么解决的?我也求相同的问题
flat_boys 2011-05-31
  • 打赏
  • 举报
回复
真的解决了..恭喜
我姓区不姓区 2011-05-31
  • 打赏
  • 举报
回复
恭喜楼主
mrisw 2011-05-31
  • 打赏
  • 举报
回复
自己解决了。

anyone来顶一下领分吧。

110,561

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧