Skip to main content Skip to complementary content

Using QlikView OCX component from Visual C++

Including the control in a VC++ project

This step-by-step instruction is based on adding the QlikView OCX to a Visual C++ dialog application. It is intended as a complement to the fuller tutorials targeting C# and Office integration, so it only describes the special steps necessary to make a working solution in Visual C++.

  1. In Visual Studio, select New Project and MFC Application.

  2. Under Application type, select Dialog based.

  3. In the Advanced Features menu, ensure you enable support for ActiveX controls.

  4. Open the application dialog in C++ resource view and add QlikOCX control into the toolbox by right clicking and selecting Choose Items...

  5. Select QlikOCX Control from the Choose Toolbox Items dialog.

    Choose Toolbox Items dialog, COM Components tab, with QlikOCX Control enabled

  6. Click OK and then select QlikOCX control in the toolbox.

  7. Drag it to the dialog and resize it appropriately.

    OCX Host dialog with QlikOCX Control placed

  8. Compile the application and then ctrl-double click on the OCX control in the resource view of the dialog.

    Add Member Variable Wizard, with the Variable Name field highlighted

  9. Name the variable and click Finish.

  10. Try to compile. You will get many compilation errors due to the following lines in the Wizard-generated code that was added.

    
    Global * GetApplication()
    {
    	Global * result;
    	GetProperty(0x1, VT_DISPATCH, (void*)&amp;result);</div>
    	return result;
    }
    void SetApplication(Global * propVal)
    {
    	SetProperty(0x1, VT_DISPATCH, propVal);
    }
    Doc * GetActiveDocument()
    {
    	Doc * result;
    	GetProperty(0x2, VT_DISPATCH, (void*)&amp;result);
    	return result;
    }
    void SetActiveDocument(Doc * propVal)
    {
    	SetProperty(0x2, VT_DISPATCH, propVal);
    }			
    	

    The reason for the compilation errors is that Global and Doc are definitions that belong to the QlikView API. These definitions reside in a different type library and Visual C++ does not handle the situation very well. In order to avoid the problem and also to be able to use the API more efficiently, we recommend that you #import the type libraries into the C++ project.

  11. Copy the appropriate type libraries to your project, add a filter to hold them and add them to the project using the following sequence of actions:

    1. Right-click on the Project name in the Solution Explorer. Select Add > New Filter. This will create a new folder in the Solution.
    2. Right-click on the new filter folder, and select Add > Existing Item.
    3. Select the QlikView OCX type libraries QlikOCX.tlb and QVForQVX.tlb from the solution folder, and select Add.
  12. When you have added the type libraries, edit stdafx.h and add the following lines at the end:

    
    #import "QvForQVX.tlb" no_namespace rename("GetLocaleInfo","
    QvGetLocaleInfo")
    
              
     #import "QlikOCX.tlb" no_namespace
            

    The second import is not necessary, but being able to access code in both type libraries in the same way is convenient. The rename directive for the first import removes a warning.

    The compilation should now succeed.

Did this page help you?

If you find any issues with this page or its content – a typo, a missing step, or a technical error – let us know how we can improve!

Join the Analytics Modernization Program

Remove banner from view

Modernize without compromising your valuable QlikView apps with the Analytics Modernization Program. Click here for more information or reach out: ampquestions@qlik.com