Solution to failure to respond to ATL events in web scripts

Source: Internet
Author: User

Tip: It took me nearly two days to solve a purely technical article. I found that I hope I could solve this problem for anyone who encountered this kind of problem. For details, please indicate the source (asnowwolf.blog.hexun.com)

It was not long before I learned VC and encountered a problem: the ATL component I wrote triggers an event, but cannot be responded by the script. To solve the problem, follow these steps:

1. Write a test page to simplify the problem and prevent interference from other factors.

2. If there is still a problem using the problematic ATL component for testing, it means it is not a script error.

3. Create an ActiveX component of MFC to respond normally, which indicates that the problem may occur in ATL.

4. note that there are several types of ATL when creating the ATL object, which may apply to simple object, full control, and lite control. The problematic one is simple object, so try the other two types, lite control is also found to have problems, but full control is normal.

5. The difference between the three is that different interfaces are implemented. Full control is the most, lite control is the second, and simple object is the least.

6. Create a full control and remove the Implemented interfaces one by one. test when the event cannot be responded normally, which indicates that the interface should be a key interface.

7. After iprovideclassinfo and iprovideclassinfo2 are removed, the event cannot be responded, indicating that these two interfaces are probably the key interfaces found.

8. added the implementation of these two interfaces for simple object:
Add a sentence in the inheritance section:
Public iprovideclassinfo2impl <& clsid_testctrl, & diid _ itestctrlevents, & libid_test4lib>,
Add two sentences to begin_com_map:
Com_interface_entry (iprovideclassinfo)
Com_interface_entry (iprovideclassinfo2)
Then, the system can respond to events normally.

Now the problem is solved.

Analysis:

According to msdn, The iprovideclassinfo interface is used to provide the type information interface itypeinfo. So what role does it play in the script?

We know that because VB and scripts cannot build vtables, they all work in post-binding mode. That is to say, they temporarily find the code to be called Based on the name during the call. How can it find this code? The only interface that can provide sufficient information is itypeinfo. Therefore, the object must implement this interface.

From: http://hi.baidu.com/nowgame/blog/item/c806ad3eed4f49fd838b1304.html#0

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.