MFC Programmer WTL Guide (7) Containment ActiveX control

Source: Internet
Author: User

Introduced

In the sixth chapter, I'll introduce ATL's support for using ActiveX controls in dialog boxes, because ActiveX controls are the specialty of ATL, so WTL doesn't add other helper classes. However, using ActiveX controls in ATL is very different from MFC, so you need to focus on this. I'll explain how to containment a control and handle the control's events, and it's a little inconvenient to develop an ATL application's Class Wizard relative to MFC. ATL's support for containment ActiveX controls can naturally be used in WTL programs.

Example project demonstrates how to use IE's browser controls, and I have two advantages in choosing a Browser Control:

    1. Each computer has this control, and
    2. It has a lot of methods and events and is a good example of how to do the demo.

I certainly can't compare to people who spend a lot of time writing custom browsers based on IE browser Controls, but when you finish reading this article, you know how to start writing your own custom browsers!

To create a project from using the wizard

WTL Wizards can create a program that supports containment ActiveX controls, and I'll start a new project called Iehoster. We used the modeless dialog as we did in the previous chapter, but this time we're going to choose to support ActiveX containment (Enable ActiveX control Hosting), as shown in the following figure:

Selecting this check box will enable our dialog box to derive from CAxDialogImpl so that ActiveX controls can be contained. On the second page of the wizard There is also a check box called Containment ActiveX control, but choosing this seems to have no effect on the final result, so you can click Finish to finish the wizard on the first page.

Wizard-Generated code

In this section I'll introduce some new code (generated by the wizard) that I haven't seen before, and the next section describes the details of the ActiveX containment class.

The first file to look at is stdafx.h, which contains the files:

#include <atlbase.h>
#include <atlapp.h>
extern CAppModule _Module;
#include <atlcom.h>
#include <atlhost.h>
#include <atlwin.h>
#include <atlctl.h>
// .. other WTL headers ...

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.