Introduction

In developing applications for embedded devices using the Microsoft® eMbedded Visual Tools, you may wish to create your own ActiveX® controls.

To do so, you must have Microsoft eMbedded Visual C++® 3.0 development system, the desktop version of Visual C++, and Microsoft eMbedded Visual Basic® 3.0 development system installed on your development machine.

To use your own ActiveX controls, create the desktop version of the control in Visual C++ and the run-time version in eMbedded Visual C++ 3.0, making sure to use the same CoClass UUID for the controls in the .idl files.

Note Both the desktop and CE device versions of the custom control must have the same UUID. To ensure the UUIDs are the same, follow the procedure described in the section, Standardizing the .Idl Files.

Standardizing the .Idl Files

To ensure that your custom control is usable in eMbedded Visual Basic, you must manually update the .idl file of the embedded control so that the UUIDs match that of the desktop control you have created.

To manually update the .idl file

Open the desktop project in Visual C++, and set the workspace to File View, as shown in Figure 1.

Figure 1. File View

Open the eMbedded Visual C++ project and set the workspace to File View. Open the same .idl file as the desktop control.

Set the open files side by side and copy the UUIDs from the desktop project into the embedded project.

Note Figure 2 shows only three UUIDs from each project, because that is what appears in a single screen. There are actually four UUIDs that need to be updated for this example. When working with your own custom controls, scroll through the .idl files to make sure you have updated all of the UUIDs.

Figure 2. Updating UUIDs

How to Mark a Control as Usable for eMbedded Visual Basic

Adding an ActiveX Control Component

The way an ActiveX control is used determines how it is added to a project in eMbedded Visual Basic. Some controls are added as components that can be dropped onto a form at design time. These ActiveX controls are first added to the Components dialog box, and then added to the Toolbox. Then they can be placed directly on a form. Others, such as the ADOCE and Finance controls, are added as objects via code; adding control objects is discussed in the section, Adding an ActiveX Control Object by Reference.

To add an ActiveX control component

Make sure the desktop design control is registered.

In eMbedded Visual Basic, to open the Components dialog box, click Project and then click Components, as shown in Figure 3.

Figure 3. Components dialog box

Click Browse, and navigate to the desktop control, as shown in Figure 4.

Figure 4. Navigating to the desktop ActiveX control

Select the dynamic link library (DLL) that contains the control, and then click Open, as shown in Figure 5.

Figure 5. Opening the DLL

At this point, you will receive a message informing you that the control will be marked as usable for the current platform, and will be added to the toolbox.

Click OK to finish.

The control, while now available at design time, will not be automatically downloaded to the device when the project is built, so you will need to use the Control Manager or eMbedded Visual C++ to add the control to the device, as described in the section, Adding a Control to an Embedded Device.

Adding an ActiveX Control Object by Reference

If a control is added as an object via code, rather than dropped onto the form, you must add a reference to the control in the References dialog box. If you wish to create an object for which you can write event handlers, use the CreateObjectWithEvents function to instantiate the object. If you wish to create an object that does not fire events, or for which you do not need to catch the events fired, use the CreateObject function. Both of these functions create invisible ActiveX controls only; they cannot create graphical ActiveX controls.

To add an ActiveX control object by reference

Make sure the desktop design control is registered.

Note Both the desktop and CE device versions of the custom control must have the same UUID.

In eMbedded Visual Basic, click Project and then click References to bring up the References dialog box, as shown in Figure 6.

Figure 6. References dialog box

Select Browse, and navigate to the desktop control.

Select the dynamic link library (.dll) that contains the control, and then click Open.

At this point, you will receive a message informing you that the selected library will be marked as usable for the current platform. In the References dialog box, click Yes to add a reference, which is then marked as usable.

Click OK to finish.

Adding a Control to an Embedded Device

To add a control to an embedded device

Click Tools, point to Remote Tools, and then click Control Manager to activate the Control Manager in eMbedded Visual Basic.

In the left pane of the Control Manager window, shown in Figure 7, select the target device to which you wish to add a control. You can choose an emulator or a Windows CE device.

In the right pane, a list of controls appears. As shown below, a Yes or a No in the right pane indicates whether the installed devices are available in the design or device/emulation environments.

Figure 7. Control Manager window

Highlight the control that you wish to install, and then select Install to Target from the Control menu. The control is installed and registered to the target device or emulation environment. The device/emulation column in the right pane confirms that the installation is successful.

To install a control not listed in Control Manager

From the left pane of the Control Manager window, select a device.

From the Control menu, select Add New Control.

Select the dynamic link library (DLL) that contains the control.

The .dll file will be copied and then registered on the device or in the emulation environment.

Show:
Inherited
Protected

Was this page helpful?

Your feedback about this content is important.Let us know what you think.