{"id":40,"date":"2008-02-09T19:32:51","date_gmt":"2008-02-09T19:32:51","guid":{"rendered":""},"modified":"2008-02-09T19:32:51","modified_gmt":"2008-02-09T19:32:51","slug":"40","status":"publish","type":"post","link":"https:\/\/www.poloo.org\/?p=40","title":{"rendered":"\u5982\u4f55\u7528c#\u6765\u5236\u4f5c\u4e00\u4e2aactiveX\u63a7\u4ef6\u6216\u7c7b\u4f3c\u7684\u4e1c\u897f"},"content":{"rendered":"<p>C# &#8211; ActiveX\u6280\u672f<\/p>\n<p>\uff31 cat: <br \/>&nbsp;&nbsp;&nbsp;&nbsp;\u64cd\u4f5c\u7cfb\u7edf: 2000\/xp <br \/>&nbsp;&nbsp;&nbsp;&nbsp;\u7f16\u7a0b\u5de5\u5177: vs.net 2003 \/c# <br \/>&nbsp;&nbsp;&nbsp;&nbsp;\u95ee\u9898: \u6211\u60f3\u5236\u4f5c\u4e00\u4e2aactiveX\u63a7\u4ef6\u6216\u7c7b\u4f3c\u7684\u4e1c\u897f\uff0c\u6709\u7528\u6237\u754c\u9762\u7684\uff0c\u7136\u540e\u60f3\u5728ie\u4e2d\u4f7f\u7528\uff0c\u901a\u8fc7Vbscript\u4e0e\u5176\u8fdb\u884c\u6570\u636e\u4ea4\u6362\uff0c\u5728\u4ee5\u524d\u597d\u50cf\u53ef\u4ee5\u4f7f\u7528vb\u5c31\u80fd\u505a\u5230\uff0c\u4f46\u662f\u73b0\u5728\u662fvs.net 2003\u4f01\u4e1a\u7248\uff0c\u597d\u50cf\u5df2\u7ecf\u8fdb\u5316\u4e86\uff0cactiveX\u6210\u4e86\u8001\u7684\u6280\u672f\uff0c\u90a3vs.net\u5982\u4f55\u89e3\u51b3\u8fd9\u79cd\u7c7b\u4f3c\u7684\u95ee\u9898\uff1f\u5982\u679c\u8981\u4f7f\u7528c#\u6765\u7f16\u7a0b\u7684\u8bdd\uff0c\u5177\u4f53\u5982\u4f55\u64cd\u4f5c\uff1f\u8fd8\u8981\u6709\u754c\u9762\u3002 <\/p>\n<p>\uff21\u56de\u7b54: <\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;\u5728C#\u4e2d\u548cActiveX\u63a7\u4ef6\u5bf9\u5e94\u7684\u662fWindows\u63a7\u4ef6\u5e93\uff08User Controls\uff09\u3002 <br \/>&nbsp;&nbsp;&nbsp;&nbsp;\u5728IE\u4e2d\u6fc0\u6d3bWindows Forms\u63a7\u4ef6\u53ef\u4ee5\u5206\u4e94\u6b65\u6765\u5b8c\u6210\uff1a <br \/>&nbsp;&nbsp;&nbsp;&nbsp;* \u521b\u5efaWindows Forms\u63a7\u4ef6\uff1b <br \/>&nbsp;&nbsp;&nbsp;&nbsp;* \u521b\u5efa\u4e00\u4e2a\u5305\u542b\u5bf9\u8c61\u6807\u7b7e\u7684HTML\u6587\u6863\uff1b <br \/>&nbsp;&nbsp;&nbsp;&nbsp;* \u521b\u5efa\u865a\u62df\u76ee\u5f55\uff0c\u590d\u5236\u5e76\u8bbe\u7f6e\u6743\u9650\uff1b <br \/>&nbsp;&nbsp;&nbsp;&nbsp;* \u914d\u7f6e\u4ee3\u7801\u8bbf\u95ee\u6743\u9650; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;* \u8fd0\u884c\u8be5\u63a7\u4ef6\u3002 <br \/>&nbsp;&nbsp;&nbsp;&nbsp;1. Windows Forms\u63a7\u4ef6\uff1aSimpleControl.dll <br \/>&nbsp;&nbsp;&nbsp;&nbsp;\u51e0\u4e4e\u6240\u6709\u7684Windows Forms\u63a7\u4ef6\u90fd\u53ef\u4ee5\u7528\uff0c\u4f46\u5728\u8fd9\u4e2a\u4f8b\u5b50\u91cc\uff0c\u6211\u4eec\u4f7f\u7528\u7684\u662f\u5305\u542b\u5728.NET Framework SDK QuickStart Tutorial Creating Controls\u4e2d\u7684SimpleControl\u63a7\u4ef6\u3002 <br \/>&nbsp;&nbsp;&nbsp;&nbsp;2. HTML\u6587\u6863: SimpleControl.html <br \/>&nbsp;&nbsp;&nbsp;&nbsp;\u63a5\u4e0b\u6765\u4e00\u6b65\u662f\u751f\u6210\u5185\u6709\u4e00\u4e2a\u5bf9\u8c61tag\u7684HTML\u6587\u6863\uff0c\u4ee5\u6fc0\u6d3bWindows Forms\u63a7\u4ef6\u3002\u6b64\u5916\uff0c\u8fd8\u8981\u52a0\u5165\u4e00\u4e9b\u811a\u672c\u548c\u8f93\u5165tag\uff08input tags\uff09\u5230\u8be5\u63a7\u4ef6\u7684\u793a\u8303\u7a0b\u5e8f\u5165\u53e3\u3002 <br \/><code><br \/>&lt;object id=\"simpleControl1\" <br \/>&nbsp;&nbsp;&nbsp;&nbsp; classid=\"http:SimpleControl.dll#Microsoft.Samples.WinForms.Cs.SimpleControl.SimpleControl\" <br \/>&nbsp;&nbsp;&nbsp;&nbsp; height=\"300\" <br \/>&nbsp;&nbsp;&nbsp;&nbsp; width=\"300\"&gt; <br \/>&nbsp;&nbsp;&nbsp;&nbsp; &lt;param name=\"Text\" value=\"Simple Control\"&gt; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&lt;\/object&gt; <br \/><\/code>&nbsp;&nbsp;&nbsp;&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;\u5bf9\u8c61tag\uff1a <br \/>&nbsp;&nbsp;&nbsp;&nbsp;classid\u5305\u542b\u4e24\u4e2a\u6709\u8da3\u7684\u90e8\u5206\uff1a\u5bfc\u5411\u63a7\u4ef6\u5e93\u7684\u8def\u5f84\u548c\u5168\u540d(fully qualified name)\uff0c\u4e2d\u95f4\u7528\u201c\uff03\u201d\u9694\u5f00\u3002\u5982\u679c\u60a8\u719f\u6089ActiveX\u5bf9\u8c61tag\u7684\u8bdd\uff0c\u60a8\u4f1a\u53d1\u73b0\u6211\u4eec\u6ca1\u6709\u4f7f\u7528GUID\u3002\u5728Windows \u8868\u5355\u4e2d\uff0c\u8def\u5f84\u548c\u5168\u540d(fully qualified name)\u5408\u5e76\u5728\u4e00\u8d77\u7684\u6574\u4f53\u88ab\u7528\u6765\u5f53\u4f5c\u552f\u4e00\u7684\u8bc6\u522b\u7b26\u3002 <br \/>&nbsp;&nbsp;&nbsp;&nbsp;\u53c2\u6570tag\u88ab\u7528\u6765\u8bbe\u7f6e\u63a7\u4ef6\u7684\u5c5e\u6027\uff1a\u201cname\u201d\u53c2\u6570\u662f\u5c5e\u6027\u540d\uff0c\u800c\u201cvalue\u201d\u53c2\u6570\u5219\u662f\u5c5e\u6027\u7684\u503c\u3002 <br \/>&nbsp;&nbsp;&nbsp;&nbsp;\u811a\u672c\uff1a <br \/><code><br \/>&nbsp;&nbsp;&nbsp;&nbsp;&lt;script&gt; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;function ChangeText() { <br \/>&nbsp;&nbsp;&nbsp;&nbsp; simpleControl1.Text = text1.value; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;} <br \/>&nbsp;&nbsp;&nbsp;&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&lt;\/script&gt; <br \/><\/code>&nbsp;&nbsp;&nbsp;&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211; <br \/><code><br \/>&nbsp;&nbsp;&nbsp;&nbsp;&lt;input type=\"text\" id=\"text1\"&gt; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&lt;input type=\"button\" value=\"Change Text\" onclick=\"ChangeText()\"&gt; <br \/><\/code>&nbsp;&nbsp;&nbsp;&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;\u60a8\u53ef\u4ee5\u5199\u4e00\u4e2a\u811a\u672c\u6765\u83b7\u5f97\u63a7\u4ef6\u7684\u7a0b\u5e8f\u5165\u53e3\uff0c\u9875\u9762\u4e0a\u7684\u6309\u94ae\u548c\u6587\u672c\u6846\u5df2\u5173\u8054\u5230\u4e00\u4e2a\u7b80\u5355\u7684\u51fd\u6570ChangeText\uff0c\u4ee5\u8bbe\u7f6e\u8be5\u63a7\u4ef6\u7684text\u5c5e\u6027\u3002\u4e3a\u4e86\u662f\u4fee\u6539\u7684\u7ed3\u679c\u4f53\u73b0\u51fa\u6765\uff0c\u63a7\u4ef6\u5fc5\u987b\u91cd\u7ed8\uff08\u8c03\u7528invalidated\uff08\uff09\u5b9e\u73b0\uff09\u3002 <br \/>&nbsp;&nbsp;&nbsp;&nbsp;\u5b8c\u6574\u4ee3\u7801 <br \/>&nbsp;&nbsp;&nbsp;&nbsp;\u4e0b\u9762\u662f\u8fd9\u4e2a\u4f8b\u5b50\u5b8c\u6574\u7684HTML\u4ee3\u7801\uff1a <br \/><code><br \/>&nbsp;&nbsp;&nbsp;&nbsp;&lt;html&gt; <br \/>&nbsp;&nbsp;&nbsp;&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&lt;script&gt; <br \/>&nbsp;&nbsp;&nbsp;&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;function ChangeText() { <br \/>&nbsp;&nbsp;&nbsp;&nbsp; simpleControl1.Text = text1.value; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;} <br \/>&nbsp;&nbsp;&nbsp;&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&lt;\/script&gt; <br \/>&nbsp;&nbsp;&nbsp;&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&lt;body&gt; <br \/>&nbsp;&nbsp;&nbsp;&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp; &lt;p&gt;Simple Control&lt;\/p&gt; <br \/>&nbsp;&nbsp;&nbsp;&nbsp; &lt;br&gt; <br \/>&nbsp;&nbsp;&nbsp;&nbsp; &lt;br&gt; <br \/>&nbsp;&nbsp;&nbsp;&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp; &lt;object id=\"simpleControl1\" <br \/>&nbsp;&nbsp;&nbsp;&nbsp; classid=\"http:SimpleControl.dll#Microsoft.Samples.WinForms.Cs.SimpleControl.SimpleControl\" <br \/>&nbsp;&nbsp;&nbsp;&nbsp; height=\"300\" <br \/>&nbsp;&nbsp;&nbsp;&nbsp; width=\"300\"&gt; <br \/>&nbsp;&nbsp;&nbsp;&nbsp; &lt;param name=\"Text\" value=\"Simple Control\"&gt; <br \/>&nbsp;&nbsp;&nbsp;&nbsp; &lt;\/object&gt; <br \/>&nbsp;&nbsp;&nbsp;&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp; &lt;br&gt; <br \/>&nbsp;&nbsp;&nbsp;&nbsp; &lt;br&gt; <br \/>&nbsp;&nbsp;&nbsp;&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp; &lt;input type=\"text\" id=\"text1\"&gt; <br \/>&nbsp;&nbsp;&nbsp;&nbsp; &lt;input type=\"button\" value=\"Change Text\" onclick=\"ChangeText()\"&gt; <br \/>&nbsp;&nbsp;&nbsp;&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&lt;\/body&gt; <br \/>&nbsp;&nbsp;&nbsp;&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&lt;\/html&gt; <br \/><\/code><br \/>&nbsp;&nbsp;&nbsp;&nbsp;3. \u865a\u62df\u76ee\u5f55\uff1a <br \/>&nbsp;&nbsp;&nbsp;&nbsp;\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u865a\u62df\u76ee\u5f55\uff0c\u5e76\u5c06\u63a7\u4ef6\uff08SimpleControl.dll\uff09\u548cHTML\u6587\u6863\uff08SimpleControl.html\uff09\u653e\u5230\u8fd9\u4e2a\u76ee\u5f55\u91cc\u3002 <br \/>&nbsp;&nbsp;&nbsp;&nbsp;\u6ce8\u610f\uff1a\u5c06\u8be5\u865a\u62df\u76ee\u5f55\u7684\u6267\u884c\u6743\u9650\u8bbe\u7f6e\u4e3a\u201c\u811a\u672c\u201d\uff0c\u5982\u679c\u5c06\u6267\u884c\u6743\u9650\u8bbe\u7f6e\u4e3a\u201c\u811a\u672c&#038; \u6267\u884c\u201d\u7684\u8bdd\uff0c\u63a7\u4ef6\u5c06\u4e0d\u80fd\u6b63\u5e38\u6fc0\u6d3b\u3002 <br \/>&nbsp;&nbsp;&nbsp;&nbsp;4 \u914d\u7f6e\u4ee3\u7801\u8bbf\u95ee\u6743\u9650 <br \/>&nbsp;&nbsp;&nbsp;&nbsp;\u5982\u679c\u4f60\u662f\u5728intranet\u8fd0\u884c\u8fd9\u4e2a\u4f8b\u5b50\uff0c\u5e76\u4e14\u6ca1\u6709\u6539\u53d8.Net Framework\u7684\u5b89\u5168\u7b56\u7565\uff0c\u8fd9\u4e2a\u4f8b\u5b50\u53ef\u4ee5\u6b63\u786e\u8fd0\u884c\u4e86\u3002\u5982\u679c\u4f60\u6539\u53d8\u4e86\u5b89\u5168\u7b56\u7565\uff0c\u6216\u8005\u4f60\u6253\u7b97\u4eceInternet\u7f51\u7ad9\u8fd0\u884c\uff0c\u4f60\u9700\u8981\u914d\u7f6eInternet Explorer\u6216\u8005\u6539\u53d8\u5b89\u5168\u7b56\u7565\u3002\u4e00\u4e2a\u529e\u6cd5\u5c06\u63a7\u4ef6\u8fd0\u884c\u548c\u4e0b\u8f7d\u7684\u9875\u9762\u52a0\u5165\u4fe1\u4efb\u57df\u3002\u53ef\u4ee5\u5728Internet Explorer\u4f7f\u7528\u4ee5\u4e0b\u6b65\u9aa4\u5b8c\u6210\uff1a <br \/>&nbsp;&nbsp;&nbsp;&nbsp;1. \u9009\u62e9\u201c\u5de5\u5177|\u9009\u9879\u201d <br \/>&nbsp;&nbsp;&nbsp;&nbsp;2. \u9009\u62e9&#8221;\u5b89\u5168&#8221;\u9879 <br \/>&nbsp;&nbsp;&nbsp;&nbsp;3. \u9009\u62e9&#8221;\u53d7\u4fe1\u4efb\u7684\u7ad9\u70b9&#8221; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;4. \u70b9\u51fb\u201c\u7ad9\u70b9\u201d\u6309\u94ae\u3002 <br \/>&nbsp;&nbsp;&nbsp;&nbsp;5. \u6dfb\u52a0\u4f60\u7684\u7ad9\u70b9 <br \/>&nbsp;&nbsp;&nbsp;&nbsp;6. \u70b9\u51fb\u201c\u786e\u5b9a\u201d <br \/>&nbsp;&nbsp;&nbsp;&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;\u4f60\u4e5f\u53ef\u4ee5\u914d\u7f6e.net framework\u5b89\u5168\u7b56\u7565\u3002SDK\u6587\u6863\u4e2d\u5305\u62ec\u4e86\u5982\u4f55\u914d\u7f6e\u5b89\u5168\u7b56\u7565\u7684\u5185\u5bb9\u3002 <br \/>&nbsp;&nbsp;&nbsp;&nbsp;5. \u8fd0\u884c\u63a7\u4ef6\uff1a <br \/>&nbsp;&nbsp;&nbsp;&nbsp;\u7528IE\u6d4f\u89c8\u5668\u91cc\u6307\u660e\u865a\u62df\u76ee\u5f55\u548cSimpleControl.html\u6587\u4ef6\uff0c\u5373\u8fd0\u884c\u8be5\u63a7\u4ef6\u3002\u5982\u679c\u63a7\u4ef6\u6ca1\u6709\u88ab\u6b63\u5e38\u6fc0\u6d3b\uff0c\u5219\u53ef\u80fd\u9700\u8981\u91cd\u542f\u4e00\u4e0bIE\u6216\u6e05\u7a7aassembly\u4e0b\u8f7d\u7f13\u5b58\uff08assembly download cache\uff09\u3002 <br \/>&nbsp;&nbsp;&nbsp;&nbsp;\u6ce8\u610f: \u60a8\u53ef\u4ee5\u4f7f\u7528gacutil \/ldl\u67e5\u770b\u60a8\u7684assembly\u4e0b\u8f7d\u7f13\u5b58\u7684\u5185\u5bb9\u3002\u53ef\u4ee5\u4f7f\u7528gacutil \/cdl\u6e05\u9664\u7f13\u5b58\u5185\u5bb9\u3002 <br \/>&nbsp;&nbsp;&nbsp;&nbsp;\u5efa\u8bae\u53c2\u8003\u6587\u7ae0Using Windows Forms Controls in Internet Explorer\uff08<a href=\"http:\/\/windowsforms.net\/articles\/iesourcing.aspx\" target=\"_blank\" rel=\"external\">http:\/\/windowsforms.net\/articles\/iesourcing.aspx<\/a>\uff09\u3002 <br \/>&nbsp;&nbsp;&nbsp;&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;cat: \u8c22\u8c22\u4f60\u7684\u56de\u7b54\uff0c\u5982\u4f55\u80fd\u5f97\u5230\u5168\u540d(fully qualified name)\uff1fc#\u5efa\u7acb\u7684\u63a7\u4ef6\u90fd\u80fd\u7528\u5417\uff1f\u8ddf\u666e\u901a\u63a7\u4ef6\u6709\u533a\u522b\u5417\uff1f\u6211\u5e0c\u671b\u63a7\u4ef6\u4e0b\u8f7d\u5230\u5ba2\u6237\u7aef\u8fd0\u884c\u7684\uff08\u51fa\u73b0\u5b89\u5168\u8b66\u544a\u6ca1\u5173\u7cfb\uff09\uff0c\u80fd\u884c\u5417\uff1f <br \/>&nbsp;&nbsp;&nbsp;&nbsp;\u7b54\uff1a\u4e0a\u9762\u7684Microsoft.Samples.WinForms.Cs.SimpleControl.SimpleControl\u5c31\u662f\u5168\u540d\uff0c\u4f60\u53ef\u4ee5\u5728\u9879\u76ee\u7684\u5c5e\u6027\u5bf9\u8bdd\u6846\u4e2d\u8bbe\u7f6e\u6839\u547d\u540d\u7a7a\u95f4\u3002\u4e00\u822c\u5efa\u7acb\u7684C#\u63a7\u4ef6\u90fd\u53ef\u4ee5\u4f7f\u7528\uff0c\u4e0d\u8fc7\u8fd9\u65b9\u9762\u8fd8\u6ca1\u6709\u786e\u5207\u7684\u8d44\u6599\u3002\u4e00\u822c\u63a7\u4ef6\u4e0b\u8f7d\u4e0d\u662f\u5927\u95ee\u9898\uff0c\u53ea\u8981\u5b89\u5168\u9009\u9879\u8bbe\u597d\u4e86\u5c31\u53ef\u4ee5\u3002\u4f46\u662f\u4e00\u4e2a\u5927\u95ee\u9898\u662f\u5728\u6ca1\u6709\u5b89\u88c5\u8fc7.NET\u5e73\u53f0\u7684\u673a\u5668\u4e0a\u9700\u8981\u5b89\u88c5\u5927\u7ea620M\u7684.NET\u5e73\u53f0\u6587\u4ef6\uff0c\u6709\u70b9\u9ebb\u70e6\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>C# &#8211; ActiveX\u6280\u672f \uff31 cat: &nbsp;&#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[13],"tags":[],"class_list":["post-40","post","type-post","status-publish","format-standard","hentry","category-NET"],"_links":{"self":[{"href":"https:\/\/www.poloo.org\/index.php?rest_route=\/wp\/v2\/posts\/40","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.poloo.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.poloo.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.poloo.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.poloo.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=40"}],"version-history":[{"count":0,"href":"https:\/\/www.poloo.org\/index.php?rest_route=\/wp\/v2\/posts\/40\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.poloo.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=40"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.poloo.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=40"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.poloo.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=40"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}