Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

How to: Host an ActiveX Control in a Dialog Resource

When you use Visual Studio to design ActiveX Controls for devices, you have to add some extra steps. The Resource Editor relies on the control being registered on the desktop computer to manipulate it at design time. In addition, you cannot register device controls on the desktop computer. The following steps provide an alternative design time experience. The following procedures assume that you already have your ActiveX Control project and host project, and you are hosting the ActiveX Control in a dialog box.

NoteNote:

Your computer might show different names or locations for some of the Visual Studio user interface elements in the following instructions. The Visual Studio edition that you have and the settings that you use determine these elements. For more information, see Visual Studio Settings.

To add ActiveX controls by using the Dialog editor

  1. In the Dialog editor, open the dialog box of the host project.

  2. From the Toolbox, drag a custom control onto the dialog box.

  3. Position and size the custom control in the dialog box to reflect how you want your ActiveX control to appear.

  4. Right-click the custom control, and then click Properties.

  5. In the Class property, paste the GUID of the ActiveX control. Remember to include the braces "{…}".

  6. In Solution Explorer, right-click the Project Name.RC2 file, and then click View Code.

  7. In the Add manually edited resources here section, add the following code. The custom control requires a dialog init section to display correctly. The contents of the actual dialog init section are not used. Remember to replace <project name> with the name of your project.

    IDD_<project name>_DIALOG DLGINIT BEGIN IDC_CUSTOM1, 0x376, 22, 0 0x0000, 0x0000, 0x0800, 0x0000, 0x094d, 0x0000, 0x043d, 0x0000, 0x0013, 0xcdcd, 0xcdcd, 0
    
  8. Build and run your host project. Remember to deploy and register the ActiveX control on the target device.

To use an alternative method for hosting ActiveX Controls

  1. Register the AtlAxWin80 window class by calling AtlAxWinInit at some point in the application.

    ATL applications do this in the module initialization code. Win32 applications should call this function in the WinMain function. For MFC applications, follow these steps:

    1. Right-click the project node in Solution Explorer, point to Add,and then click Class.

    2. Click Add ATL support to MFC (under the Smart Device heading).

    3. Add the AtlAxWinInit call to the top of the InitInstance method of the host application class.

  2. In a dialog resource (such as an ATL dialog or composite control, or MFC dialog):

    1. Drag a custom control from the Toolbox.

    2. Set the window class property to AtlAxWin80.

    3. Set the caption to the GUID in braces, or the progid.

  3. For MFC, add atl.lib as additional link input.

  4. For MFC, add these lines to the Deployment | Additional Files option. Although the lines already there for dynamic link libraries, they have to be added for MFC statically linked libraries.

    msvcr80.dll|$(BINDIR)\$(INSTRUCTIONSET)\|%CSIDL_PROGRAM_FILES%\$(ProjectName)|0
    atl80.dll|$(BINDIR)\$(INSTRUCTIONSET)\|%CSIDL_PROGRAM_FILES%\$(ProjectName)|0
    msvcr80d.dll|$(BINDIR)\$(INSTRUCTIONSET)\|%CSIDL_PROGRAM_FILES%\$(ProjectName)|0
    

Community Additions

ADD
Show:
© 2015 Microsoft