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 控件以及相关的注意事项 ...
随机推荐
- C#(委托a)
C#(委托a) public delegate double TheOperator(double x, double y); public class Operators { static publ ...
- 几种经典排序算法的R语言描述
1.数据准备 # 测试数组 vector = c(,,,,,,,,,,,,,,) vector ## [] 2.R语言内置排序函数 在R中和排序相关的函数主要有三个:sort(),rank(),ord ...
- Spring3:AOP
AOP AOP(Aspect Oriented Programming),即面向切面编程,可以说是OOP(Object Oriented Programming,面向对象编程)的补充和完善.OOP引入 ...
- 操作jQuery
==================================== $('img').each(function(){ this.alt='This is image['+n+'] with a ...
- SpringMVC中使用Interceptor拦截器
SpringMVC 中的Interceptor 拦截器也是相当重要和相当有用的,它的主要作用是拦截用户的请求并进行相应的处理.比如通过它来进行权限验证,或者是来判断用户是否登陆,或者是像12306 那 ...
- 有了门面,程序会更加体面!- pos软件基于三层架构 -09
续上篇) 大鸟说道:“实际上没有学过设计模式去理解三层架构会有失偏颇的,毕竟分层是更高一级别的模式,所谓的架构模式.不过在程序中,有意识的遵循设计原则,却也可以有效的做出好的设计.” ...
- 【Raspberry Pi】新入手的Raspberry Pi3拼装日志
一.概述 2016年暑假某宝入手Raspberry Pi 3,装机清单: 树莓派主板 亚克力外壳 小风扇 散热片 30G SD card 螺丝若干颗 因机型问题,可能与你的机器有微小差异 二.装机过程 ...
- javascript平时小例子⑧(导航置顶效果)
<!DOCTYPE html><html> <head> <meta charset="utf-8" /> <title> ...
- JavaScript、全选反选-课堂笔记
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- 如何在Eclipse中查看JDK的源代码
设置: 1.点 "Window"-> "Preferences" -> "Java" -> "Installed ...