ActiveX controls with interfaces and webpage calls

Source: Internet
Author: User

Recently, a lower-level student in the lab asked me questions about ActiveX controls, saying that an interface ActiveX control should be compiled and placed on a webpage. This aims to make use of the convenience of Internet Web, replaces the common client.

When I checked the information, I found that many people asked similar questions, but the answers were generally not detailed enough. So I shared some of my recent experiences and hoped to help later users.

After an ActiveX control is created using the MFC wizard, several classes are generated. The parent class of colecontrol (cyouprojectnamectrl) is cwnd, And we can create the Child Window on it.

First, create a dialog box resource, select idd_formview, and create an association class for it. It is named cactxinterface Based on cdailog.

Properties of the select dialog box:

English version VC: style-child, border-dialog frame, visible, control, static edge

Chinese version VC: "style" is set to "Lower Layer", "more visible" selected "visible", "control ".

Step 2: add the cactxinterface dialog variable to the cyouprojectnamectrl header file: (remember to add the header file)

Cactxinterface actxinterface;

Step 3: add the message wm_creat for cyouprojectnamectrl, corresponding to the oncreat () function; create a dialog box in it

Actxinterface. Create (idd_formview, this); // idd_formview is the resource ID

Step 4: Display your dialog box in the ondraw () message of cyouprojectnamectrl.

Actxinterface. movewindow (rcbounds, true );

Compile, OK. Use the VC container tool to test. tool --> ActiveX control test...

 

Step 5: register the control. VC automatically registers the control during compilation. If the control is moved, remember to register it again.

Step 6: compile an HTML file: Add the following section.

<Object ID = docxtest1 classid = CLSID: 706b4509-d5f8-438f-b391-fe7d620c946c </Object>

CLSID is the registration ID of the control and needs to be changed to the registration ID of the runtime environment. For details, see the section below in the odl file in the VC project directory (the section is at the end of the file and do not make a mistake in the ID)

// Class information for caxtivex_interfacectrl

[UUID (706b3169-d5f8-438f-b391-fe7d620c946c ),
Helpstring ("axtivex_interface control"), control]

Step 7: use IE to open the HTML file and find that the ActiveX control interface is very small. This can be set in the container (html file:

For example:

<Object ID = docxtest1 classid = CLSID: 706b4509-d5f8-438f-b391-fe7d620c946c width = "532" Height = "356">
<Param name = "_ version" value = "65536">
<Param name = "_ extentx" value = "2646">
<Param name = "_ extenty" value = "1323">
<Param name = "_ stockprops" value = "0">
</Object>

Now, all are OK. You can easily create the desired controls, such as buttons and edit, In this dialog box.

Download original code

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.