C#利用AxImp工具在WPF中使用OCX控件
一、注册OCX并利用工具生成dll
@echo off
color a
::Failed
REGSVR32 /S /I "MSCOMCTL.OCX"
if exist %windir%\SysWOW64 (
.\AxImp.exe "C:\Windows\SysWOW64\MSCOMCTL.ocx" /out:.\MSCOMCTL64.dll
) else (
.\AxImp.exe "C:\Windows\System32\MSCOMCTL.ocx" /out:.\MSCOMCTL32.dll
) pause
二、添加引用(OCX生成的dll)并编码使用
项目引用:WindowsFormsIntegration.dll,System.Windows.Forms.dll
xaml代码使用
<Window x:Class="wpf_ocx2dll.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
添加命名空间
xmlns:ms="clr-namespace:MSComctlLib;assembly=MSComctlLib"
Title="MainWindow" Height="350" Width="525">
<Grid>
<WindowsFormsHost x:Name="host">
<ElementHost>
<!--<ms:Button Caption="test" />-->
</ElementHost>
</WindowsFormsHost>
</Grid>
</Window>
或cs代码使用
MSComctlLib.IButton btn = new MSComctlLib.Button();
public MainWindow()
{
InitializeComponent();
try
{
((System.ComponentModel.ISupportInitialize)btn).BeginInit();
//host.Child =btn;
((System.ComponentModel.ISupportInitialize)btn).EndInit(); }
catch (Exception ex)
{
}
}
所用工具:http://pan.baidu.com/s/1i4AIBxr
C#利用AxImp工具在WPF中使用OCX控件的更多相关文章
- 在WPF中使用WinForm控件方法
1. 首先添加对如下两个dll文件的引用:WindowsFormsIntegration.dll,System.Windows.Forms.dll. 2. 在要使用WinForm控 ...
- WPF中的image控件的Source赋值
WPF中的Image控件Source的设置 1.XAML中 简单的方式(Source="haha.png"); image控件的Source设置为相对路径后(Source=&quo ...
- 在WPF中调用Winform控件
最近在项目中用到了人脸识别和指纹识别,需要调用外部设备和接口,这里就用到了在WPF中调用Winform控件. 第一步,添加程序集引用.System.Windows.Forms和WindowsForms ...
- WPF中的ControlTemplate(控件模板)(转)
原文地址 http://www.cnblogs.com/zhouyinhui/archive/2007/03/28/690993.html WPF中的ControlTemplate(控件模板) ...
- [转]在WPF中使用WinForm控件方法
本文转自:http://blog.csdn.net/lianchangshuai/article/details/6415241 下面以在Wpf中添加ZedGraph(用于创建任意数据的二维线型.条型 ...
- WPF中的ControlTemplate(控件模板)
原文:WPF中的ControlTemplate(控件模板) WPF中的ControlTemplate(控件模板) ...
- [转]WPF中的ControlTemplate(控件模板)
WPF中的ControlTemplate(控件模板) ...
- Html页中使用OCX控件
原文:http://blog.csdn.net/mouse8166/article/details/5515657 最近准备开发一个b/s架构的应用程序需要用到activeX控件,web服务器尚未进入 ...
- WindowsXamlHost:在 WPF 中使用 UWP 控件库中的控件
在 WindowsXamlHost:在 WPF 中使用 UWP 的控件(Windows Community Toolkit) 一文中,我们说到了在 WPF 中引入简单的 UWP 控件以及相关的注意事项 ...
随机推荐
- [工作中的设计模式]中介模式模式Mediator
一.模式解析 用一个中介者对象封装一系列的对象交互,中介者使各对象不需要显示地相互作用,从而使耦合松散,而且可以独立地改变它们之间的交互. 中介模式又叫调停者模式,他有如下特点: 1.有多个系统或者对 ...
- Android入门(一):创建Android工程
开发Android应用过程一般分为三步: 1.创建一个Android工程: 2.在xml布局文件中定义应用所包含的控件: 3.在Java代码中实现业务逻辑. 此文就介绍第一部分,创建一个Android ...
- Rotate Image
You are given an n x n 2D matrix representing an image. Rotate the image by 90 degrees (clockwise). ...
- JS:event对象下的target属性和取消冒泡事件
1.target 通过获取DOM元素 var box = document.getElementById("box"); document.box.onclick = functi ...
- mongodb用子文档做为查询条件的两种方法
{ "_id": ObjectId("52fc6617e97feebe05000000"), "age": 28, "level& ...
- arcmap配置的mxd慢的问题
http://www.360doc.com/content/13/0220/09/3046928_266688511.shtml
- 【noip 2016】 组合数问题(problem)
杨辉三角形求组合数问题 原题点这里 #include <iostream> #include <cmath> using namespace std; long long a[ ...
- WPF整理--动态绑定到Logical Resource
“What happens if we replace aspecific resource? Would that be reflected in all objects using the res ...
- 【iCore3 双核心板】例程三十六:DAC实验——输出直流电压
实验指导书及代码包下载: http://pan.baidu.com/s/1bRVnzS iCore3 购买链接: https://item.taobao.com/item.htm?id=5242294 ...
- 将bean转换成键值列表
日常开发中在进行接口对接的数据传输时,有一种场景是将bean转成jsonString,这里可以将bean转换成Map再转成jsonString. 工具类如下: public static String ...