VS2010 C++MFC Create and publish ActiveX controls __c++

Source: Internet
Author: User
1 new MFC ActiveX control project. Control Settings section, the created control is based on the item selection static, the "active when visible" item is checked, the "No Flicker Activation" item is selected, and the remaining items are actually checked as needed.
2) By default, the wizard creates a project that uses a shared MFC DLL, and you must ensure that the target machine has an MFC DLL installed, or the ActiveX control fails to run.
Workaround: Modify the project properties. Project---> Properties---> Configuration Properties---> General---> The use of MFC item Select Use MFC in a static library.
Three class files that the wizard automatically generates:
Cxxxapp-derived from the COleControlModule class, this class allows you to get to an OLE control object.
Cxxxctrl-derived from the COleControl class to implement the control's functionality based on this class.
Cxxxproppage-derived from the COlePropertyPage class, which manages the properties dialog box for the control.
3 Resource View property page to add a resource, you can right-click to select the Insert dialog item, add the control's interface frame, edit the controls within the interface frame, and set properties.
After you have finished editing the message for the interface frame and its controls, create the corresponding class Cmaindialog for the interface frame.
4 Add the type variable m_maindialog of the class corresponding to the interface frame for the Cmyactivexctrl class.
5 The Resource View property page Right-click the Cmyactivexctrl class select Properties and select the Message property page to add the wm_create message.
6 Add the following code to the OnCreate function and the OnDraw function of the CMyActiveXCtrl.cpp file:
M_maindialog.create (Idd_maindialog, this);


M_maindialog.movewindow (Rcbounds, TRUE);
CBrush Brbackgnd (TranslateColor (Ambientbackcolor ()));
Pdc->fillrect (Rcbounds, &BRBACKGND);
7) Build the solution.
8 use ActiveX Control Pad software to create Web test.htm for ActiveX controls.
9 The test machine installs the IIS server as a Web server.
10 Place the Test.htm file under the Web site root directory wwwroot of the IIS server.
11 Use IE to open test.htm file, at this time need to set Web site security properties. Setting the ActiveX control as a security control requires additional settings.

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.