MFC - Activex Control


Advertisements


An ActiveX control container is a parent program that supplies the environment for an ActiveX (formerly OLE) control to run.

  • ActiveX control is a control using Microsoft ActiveX technologies.

  • ActiveX is not a programming language, but rather a set of rules for how applications should share information.

  • Programmers can develop ActiveX controls in a variety of languages, including C, C++, Visual Basic, and Java.

  • You can create an application capable of containing ActiveX controls with or without MFC, but it is much easier to do with MFC.

Let us look into simple example of add ActiveX controls in your MFC dialog based application.

Step 1 − Right-click on the dialog in the designer window and select Insert ActiveX Control.

Insert Activex Control

Step 2 − Select the Microsoft Picture Clip Control and click OK.

Microsoft Picture Control

Step 3 − Resize the Picture control and in the Properties window, click the Picture field.

Step 4 − Browse the folder that contains Pictures. Select any picture.

Step 5 − When you run this application, you will see the following output.

Insert Activex

Let us have a look into another simple example.

Step 1 − Right-click on the dialog in the designer window.

Designer Window

Step 2 − Select Insert ActiveX Control.

Designer Window

Step 3 − Select the Microsoft ProgressBar Control 6.0, click OK.

Step 4 − Select the progress bar and set its Orientation in the Properties Window to 1 – ccOrientationVertical.

Step 5 − Add control variable for Progress bar.

Designer Window

Step 6 − Add the following code in the OnInitDialog()

m_progBarCtrl.SetScrollRange(0,100,TRUE);
m_progBarCtrl.put_Value(53);

Step 7 − When you run this application again, you will see the progress bar in Vertical direction as well.

Designer Window

Advertisements