ActiveX development experience

Source: Internet
Author: User

 

If you want to use C # And VB.net for ActiveX, I advise you to get rid of this idea as soon as possible .. Net thinks ActiveX technology is outdated, So C # And VB.net cannot do ActiveX. C # And VB.net can do similar things, but it is not called ActiveX but Windows Control, provided that the client machine must have installed. NET Framework to run. However, at present, many machines do not have. NET Framework installed. At least, ActiveX technology may exit the stage when Vista is popularized.

So what technology should I use to develop ActiveX? You can use VB6, C ++, or C ++. net. Because I didn't understand C ++, I thought it would be similar to C #. I used vs to create an MFC ActiveX project and opened it. I couldn't understand the code like tianshu, so I decided to use VB6. Even though VB does not, VB is relatively simpler and more information is required.

How to use VB ActiveX development here not detailed, can refer to this article: ASP and ActiveX controls interactive practice (http://blog.csdn.net/online/archive/2004/08/09/68872.aspx), very detailed.

Here we will only introduce the following difficulties:
1. How to submit the form of the webpage in ActiveX?

You can use js to pass form to acitvex. To use VB to operate HTML elements (DOM), you must add a reference by choosing project> reference> check Microsoft HTML Object Library> OK.

In the code, add a method to accept the form from the client:
Public htmlform as htmlformelement 'record htmlform Value
Public sub Init (byref form as htmlformelement)
Set htmlform = form
End sub

The client HTML transmits form to ActiveX:
<HTML xmlns = "http://www.w3.org/1999/xhtml">
<Head>
<SCRIPT type = "text/JavaScript">
Window. onload = function (){
Document. getelementbyid ("kellilogin"). INIT (form1); // pass form to ActiveX.
}
</SCRIPT>
</Head>
<Body>
<Form ID = "form1">
<Div>
<Object classid = "CLSID: {1179091e-1f78-4d09-b876-b7c1abea4bf3}" id = "kellilogin" width = "198" Height = "88"> </Object>
</Div>
</Form>
</Body>
</Html>

After passing the form to ActiveX, ActiveX can operate on this form. If you click a button in ActiveX, then submit the form:
Private sub submit_click ()
Htmlform. Action = "test. aspx? Username = 123"
... You can set the form methods and attributes as if in JavaScript.
Htmlform. Submit
End sub

The second question is as follows:
2. How do I mark ActiveX controls as secure scripts?

This problem is actually caused by the first problem. After ActiveX control is developed and registered, once it runs on a webpage, ie does not think this is a script safe, an IE prompt is displayed, indicating that the site has been blocked from using ActiveX controls in an insecure manner. Therefore, this page may be incorrect.

If we do not solve this problem, our previous work would be white-handed. What should we do? You need to modify the client registry,

Add an item similar to the following (replaced by the control class ID){06889605-B8D0-101A-91F1-00608CEAD5B3}) To associate your keys with the following class IDs:

HKEY_CLASSES_ROOT/CLSID/{06889605-B8D0-101A-91F1-00608CEAD5B3}/Implemented Categories/{7DD95801-9882-11CF-9FA9-00AA006C42C4} HKEY_CLASSES_ROOT/CLSID/{06889605-B8D0-101A-91F1-00608CEAD5B3}/Implemented Categories/{7DD95802-9882-11CF-9FA9-00AA006C42C4}

But how can I modify the registry of the client machine? This requires the installation of ActiveX controls. Therefore, we need to create an ActiveX Installer. Here we use Visual Studio 2005 to create the installer.

1. Open Vs and create an installation project.
2. In the Solution Explorer window, right-click Project> Add File> select your generated ativex file, such as hello. ocx.
3. Right-click the project and choose View> registry.
1> Add the Registry in sequence according to the above registry Node
2> in the last section of the Registry, right-click> Properties window> set alwayscreate to true, which indicates that this registry entry is a branch of the installation project, even if it is empty. After this setting, the client registry is automatically modified during installation.
4. Generate the installer
5. Run the installer
6. Browse the page containing the ActiveX

You will find that the prompt is gone, and you do not need to add a trusted site in IE to use it directly! Is it really refreshing?

So far, the introduction is similar. There are several questions that need to be studied:
1. Do not create an installation package. Can this problem be solved?
2. How to store data in acivex, for example, a user name. After the first input, remember it for the second time.

If you are interested, you can discuss with me or give me some advice. Thank you!

References:
Http://msdn.microsoft.com/library/chs/default.asp? Url =/library/CHS/vccore/html/_ core_upgrading_an_existing_activex_control_to_be_used_on_the_internet.asp

Http://wenhaobing.spaces.live.com/blog/cns! 9d6443eb4bff9145! 143. Entry

Reprinted: http://hi.baidu.com/%B7%E7%D6%D0%C1%E9%D2%A9/blog/item/9fb6cdc8d320e3137e3e6f42.html

Thank you !!!

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.