ActiveX (i) the first simple demo

Source: Internet
Author: User

Speaking of ActiveX, my first instinct is flash, using ActiveX, we can create rich, interactive applications. At the same time, using ActiveX features, we can achieve a seamless connection between JS and ActiveX (including data sharing, and interface calls), with the help of ActiveX to break the browser restrictions, and then achieve more powerful features.

Gossip less, get to the point, and see how to quickly develop a simple password login box:

  1. Create a new Windows Application project
  2. Modify the project Properties--the application-to-output type to class library.


  3. Modify the project Properties--application-to-assembly information--tick ' make assembly COM visible '.
  4. For ease of debugging (official release, this step can be skipped), tick ' project Properties--Generate COM Interop registration '.
  5. Delete the default generated Form1 and Program.cs for the project, and create a new control of type UserControl, called Passwordcontrol.
  6. Adds a Guid for Passwordcontrol.
  7. Add a Password entry box for Passwordcontrol, with the name Txtpwd.
  8. Add Getpwd public methods for Passwordcontrol, such as:
    usingSystem;usingSystem.Collections.Generic;usingSystem.ComponentModel;usingSystem.Drawing;usingSystem.Data;usingSystem.Linq;usingSystem.Text;usingSystem.Windows.Forms;usingSystem.IO;usingSystem.Runtime.InteropServices;namespacetestactivex{[Guid ("30a3c1b8-9a9a-417a-9e87-80d0ee827658")]     Public Partial classPasswordcontrol:usercontrol { PublicPasswordcontrol () {InitializeComponent (); }         Public stringgetpwd () {return  This. Txtpwd.text; }    }}

  9. JS calls ActiveX.
    <!DOCTYPE HTML><HTMLLang= "en"xmlns= "http://www.w3.org/1999/xhtml"><Head>    <MetaCharSet= "Utf-8" />    <title></title>    <Scriptlanguage= "JavaScript"type= "Text/javascript">        functionLogin () {Console.info ("Password:" +activiex.getpwd ()); }    </Script></Head><Body>    <Div>        <Objectwidth= " the"Height= "+"ID= "Activiex"ClassID= "clsid:30a3c1b8-9a9a-417a-9e87-80d0ee827658">        </Object>    </Div>    <inputtype= "button"onclick= "Javascript:login ();"value= "Login" /></Body></HTML>
  10. At this point, a simple ActiveX is complete.

Test Project Source: Http://files.cnblogs.com/files/08shiyan/TestActiveX.zip

(not to be continued ...)

ActiveX (i) the first simple demo

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.