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++.
- 
                        
In Visual Studio, select New Project and MFC Application.
 - 
                        
Under Application type, select Dialog based.
 - 
                        
In the Advanced Features menu, ensure you enable support for ActiveX controls.
 - 
                        
Open the application dialog in C++ resource view and add QlikOCX control into the toolbox by right clicking and selecting Choose Items...
 - 
                        
Select QlikOCX Control from the Choose Toolbox Items dialog.
                         - 
                        
Click OK and then select QlikOCX control in the toolbox.
 - 
                        
Drag it to the dialog and resize it appropriately.
                         - 
                        
Compile the application and then ctrl-double click on the OCX control in the resource view of the dialog.
                         - 
                        
Name the variable and click Finish.
 - 
                        
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*)&result);</div> return result; } void SetApplication(Global * propVal) { SetProperty(0x1, VT_DISPATCH, propVal); } Doc * GetActiveDocument() { Doc * result; GetProperty(0x2, VT_DISPATCH, (void*)&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.
 - 
                        
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:
- Right-click on the Project name in the Solution Explorer. Select Add > New Filter. This will create a new folder in the Solution.
 - Right-click on the new filter folder, and select Add > Existing Item.
 - Select the QlikView OCX type libraries QlikOCX.tlb and QVForQVX.tlb from the solution folder, and select Add.
 
 - 
                        
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_namespaceThe 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.