求高手:WPF窗体中加载ActiveX控件总是显示在最前的问题!!!!!
没有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);
}
}
}
求助:(求实例代码,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);
}
}
}
...全文
相关推荐
camsAssist_WPF_高拍仪_activex_websock_activeX控件_
这通常涉及创建一个Host窗体,该窗体可以承载ActiveX控件,然后将这个Host窗体嵌入到WPF用户界面中。
WPF 透明窗体内的 Webbrowser
然而,当我们将`AllowTransparency`属性设置为`true`时,会遇到一个问题:内嵌的`WebBrowser`控件无法正常显示。
C#显示PDF内容
更简单且直观的方法是使用第三方控件,例如Adobe的ActiveX控件或者Telerik的RadPdfViewer。通过在C#窗体中嵌入这些控件,可以直接加载并显示PDF文件。
WPF中webBrowser控件与脚本交互(调用托管代码)
一、WebBrowser控件基础WebBrowser控件是WPF中的一个组件,它基于Internet Explorer的ActiveX控件,可以显示HTML页面,执行JavaScript,并与.NET
C#调用activeX控件方法步骤 (2).docx
**使用Aximp.exe**: `Aximp.exe`是.NET框架自带的工具,用于将ActiveX控件的COM类型库转换为可以在Windows窗体上使用的包装类。


