Using QlikView OCX component from Visual Basic
Including the control in a VB.NET project
The QlikView OCX control must first be included in the Visual Basic project. This is done as follows:
- Right-click on the toolbox in Visual Basic.
- Select Components on the Context menu.
- Scroll down the list until you find QlikView OCX ActiveX control module. If it does not appear in the list, the QlikView OCX control has not been properly registered
- Select that component by checking the check box to the left of it.
- Click OK. A QlikView icon should now appear in the toolbox.
Copying and registering the QlikView OCX component
Placing a QlikView OCX control on a VB form
You may now include the QlikView OCX control on a form in your VB project.
- Click the QlikView icon in the toolbox.
- Use the mouse to mark the size and position of the QlikView OCX control on the form.
Accessing the QlikView OCXcontrol from VB code
Once the component has been included and placed on a form it may be referenced as an object by the name QlikOCX1.
The active QlikView document can be referenced as QlikOCX1.ActiveDocument.
In addition to the QlikView OCX specific Automation members, almost all members of the standard QlikView Automation interface may be used for control of the OCX component. See the QlikView Automation Reference manual for details.
Note that in cases where member names are shared between the general QlikView Automation interface and the QlikView OCX specific Automation interface, the latter will have preference. The actual difference is however negligible.
Examples:
Private Sub Command1_Click()
QlikOCX1.OpenDocument "C:\MyDoc", "", ""
End Sub
Private Sub Command2_Click()
QlikOCX1.ActiveDocument.Reload
End Sub
Useful VB support modules
If you need to use QlikViewinternal constant definitions, include the module file qvmenu.bas to your project. The file which can be found in the \Runtime library\Resources\Vb directory installed by the QlikView OCX SDK Package contains QlikViewinternal menu constant definitions. This file will be updated together with the OCX control.
If you plan to manipulate the QlikViewobject menus the module file MenuDef.bas may be quite useful. It contains declarations of system calls for manipulating menus.
Rem MenuDef.bas
Public Const MF_SEPARATOR = 2048
Public Const MF_STRING = 0
Declare Sub AppendMenu Lib "user32" Alias
"AppendMenuA" (ByVal _
hMenu As Long, ByVal uFlags As Long, ByVal uIDNewItem
As Long, _
ByVal lpNewItem As String)
Public Const MF_BYCOMMAND = 0
Public Const MF_BYPOSITION = 1024
Declare Sub DeleteMenu Lib "user32" (ByVal hMenu As
Long, _
ByVal uPosition As Long, ByVal uFlags As Long)
Declare Function GetMenuItemCount Lib "user32" _
(ByVal hMenu As Long) As Integer