欢迎来到天天文库
浏览记录
ID:40533219
大小:420.50 KB
页数:15页
时间:2019-08-04
《C#制作ActiveX控件在网页上使用》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、C#制作ActiveX控件并在Web中使用C#制作ActiveX控件,一般来说并不推荐这样做。因为还要为客户安装对应的.NetFramework版本。现在一个示例实现将手写板的签字图片复制到剪贴板,从剪贴板的图片中对图片进行按比例缩放,并保存为C:oaSignDpi.jpg。★★★1.在VisualStudio2010中,新建项目Windows窗体控件库。命名为SaveClipImage★★★2.在SaveClipImage项目中新建一个接口IObjectSafety.这个接口内容最好不要变更。接口IObjectSafety具体代码如下:usingSystem;
2、usingSystem.Collections.Generic;usingSystem.Runtime.InteropServices;usingSystem.Text;namespaceSaveClipImage{[ComImport,GuidAttribute("CB5BDC81-93C1-11CF-8F20-00805F2CD064")][InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)]publicinterfaceIObjectSafety{[PreserveSig]intGetIn
3、terfaceSafetyOptions(refGuidriid,[MarshalAs(UnmanagedType.U4)]refintpdwSupportedOptions,[MarshalAs(UnmanagedType.U4)]refintpdwEnabledOptions);[PreserveSig()]intSetInterfaceSafetyOptions(refGuidriid,[MarshalAs(UnmanagedType.U4)]intdwOptionSetMask,[MarshalAs(UnmanagedType.U4)]intdwEnabl
4、edOptions);}}★★★3.在默认的UserControl1控件上增加一个PictureBox,设置可见性级别为Public.详细代码如下:usingSystem;usingSystem.Collections.Generic;usingSystem.ComponentModel;usingSystem.Drawing;usingSystem.Data;usingSystem.Runtime.InteropServices;usingSystem.Text;usingSystem.Windows.Forms;usingSystem.Management;n
5、amespaceSaveClipImage{[Guid("6F151B97-B972-4112-BEB1-754173BAA80C"),//(这个Guid必须要和制作安装文件时的Guid号码一样)ProgId("_20131017.UserControl1"),ComVisible(true)]//(控件必须添加的内容)publicpartialclassUserControl1:UserControl,IObjectSafety{publicstringfileName="";[System.Runtime.InteropServices.DllImport("
6、user32")]privatestaticexternIntPtrSetClipboardViewer(IntPtrhwnd);[System.Runtime.InteropServices.DllImport("user32")]privatestaticexternIntPtrChangeClipboardChain(IntPtrhwnd,IntPtrhWndNext);[System.Runtime.InteropServices.DllImport("user32")]privatestaticexternintSendMessage(IntPtrhwn
7、d,intwMsg,IntPtrwParam,IntPtrlParam);constintWM_DRAWCLIPBOARD=0x308;constintWM_CHANGECBCHAIN=0x30D;publicIntPtrNextClipHwnd;//下一个句柄publicUserControl1(){InitializeComponent();pictureBox1.SizeMode=PictureBoxSizeMode.AutoSize;Clipboard.Clear();//获得观察链中下一个窗口句柄NextClipHwnd=SetClipboardView
8、er(th
此文档下载收益归作者所有