VS2019 VC++ - How to use VideoCap Pro SDK ActiveX
Step 1: Install the VideoCap Pro SDK ActiveX, begin by launching the setup file (https://www.viscomsoft.com/demo/videocapprosetup.exe). Select the desired installation folder for the VideoCap Pro SDK ActiveX and continue with the installation on your development computer.
Step 2: Create New C++ MFC App, select Next button.
![](http://www.viscomsoft.com/doc/videocappro/createproject-mfc.jpg)
Step 3: Enter your project name and select project location, select Next button.
![](http://www.viscomsoft.com/doc/videocappro/createproject-mfc2.jpg)
Step 4: Select Dialog based in Application type , select Next button.
![](http://www.viscomsoft.com/doc/videocappro/dialogtype.jpg)
Step 5: Select Solution Explorer, double click MFCApplication1.rc
![](http://www.viscomsoft.com/doc/videocappro/resource2.jpg)
Step 6: double click IDD_MFCAPPLICATION1_DIALOG in Dialog, then open the UI. In Toolbox, Right Click Mouse and select Choose Item...
Step 7: Select COM Components Tab, select VideoCap Pro Control, click OK button to confirm.
![](http://www.viscomsoft.com/doc/videocappro/addcomp4.JPG)
Step 8: Now you will see the VideoCap Pro's icon on toolbox, drag it to form.
![](http://www.viscomsoft.com/doc/videocappro/addcomp5.JPG)
![](http://www.viscomsoft.com/doc/videocappro/addcomp6.JPG)
Step 9: In Windows explorer, copy all files from C:Program Files (x86)VideoCap Pro ActiveX ControlVS2019VC-VideoCapProClass folder to your project folder.
![](http://www.viscomsoft.com/doc/videocappro/addcomp6-a.JPG)
Step 10: In Solution Explorer, select Header Files folder, then add videocap.h
![](http://www.viscomsoft.com/doc/videocappro/addcomp7.JPG)
Step 11: In Solution Explorer, select Source Files folder, then add videocap.cpp
![](http://www.viscomsoft.com/doc/videocappro/addcomp8.JPG)
![](http://www.viscomsoft.com/doc/videocappro/addcomp9.JPG)
Step 12: add #include "videocap.h" and CVideoCap m_VideoCap in MFCApplication1Dlg.h
Step 13: add DDX_Control(pDX, IDC_VIDEOCAPCTRL1,m_VideoCap);
to DoDataExchange method in MFCApplication1Dlg.cpp
![](http://www.viscomsoft.com/doc/videocappro/addcomp11.JPG)
Step 14: add button on form and remove another button
![](http://www.viscomsoft.com/doc/videocappro/addcomp12.JPG)
Step 15: double click the Preview button and add the following code in this handler. It will preview the first video device
m_VideoCap.Start();
![](http://www.viscomsoft.com/doc/videocappro/addcomp13.JPG)
Step 16: double click IDD_MFCAPPLICATION1_DIALOG in Dialog, add two combo box on form.
set Combo Box Type property to Drop List and set Sort property to False
Step 17: In Solution Explorer, select Header Files folder, then add devices.h, videoformats.h
![](http://www.viscomsoft.com/doc/videocappro/addcomp46-add-videoformat-deviceh.JPG)
Step 18: In Solution Explorer, select Source Files folder, then add devices.cpp, videoformats.cpp
![](http://www.viscomsoft.com/doc/videocappro/addcomp47-add-videoformat-devicecpp.JPG)
Step 19: In MFCApplication1Dlg.h, add the following code
#include "devices.h"
#include "videoformats.h"
![](http://www.viscomsoft.com/doc/videocappro/addcomp48-include-videoformat-deviceheader.JPG)
Step 20: double click IDD_MFCAPPLICATION1_DIALOG in Resource View, select Video Device combo box, right click mouse, select Class Wizard...
![](http://www.viscomsoft.com/doc/videocappro/addcomp49-selclasswizard.JPG)
Step 21: select Member Variables tab, make sure selected IDC_CBOVIDEODEVICE, click Add Variable..., enter m_CboVideoDevice in Name field, then click Finish button.
Step 22: make sure selected IDC_CBOVIDEOFORMAT, click Add Variable...
![](http://www.viscomsoft.com/doc/videocappro/addcomp52-selvideoformatclasswizard.JPG)
Step 23: enter m_CboVideoFormat in Name field, then click Finish button.
![](http://www.viscomsoft.com/doc/videocappro/addcomp53-addvariablevideoformat.JPG)
Step 24: In Class Wizard, select Virutal Functions tab, select OnInitDialog, click Add Function, then click Edit code.
![](http://www.viscomsoft.com/doc/videocappro/addcomp54-addinitdialog.JPG)
Step 25: add the following code in OnInitDialog()
int iDeviceCount = m_VideoCap.GetDevices().GetCount();
CString strDeviceName;
for (int i = 0; i < iDeviceCount; i )
{
strDeviceName = m_VideoCap.GetDevices().FindDeviceName(i);
m_CboVideoDevice.AddString(strDeviceName);
}
if (m_CboVideoDevice.GetCount() > 0)
m_CboVideoDevice.SetCurSel(0);
Step 26: add the following code in OnInitDialog()
////////////////////video format
int iVideoFormatCount = m_VideoCap.GetVideoFormats().GetCount();
CString strVideoFormat;
for (int i = 0; i < iVideoFormatCount; i )
{
strVideoFormat = m_VideoCap.GetVideoFormats().FindVideoFormatName(i);
m_CboVideoFormat.AddString(strVideoFormat);
}
if (m_CboVideoFormat.GetCount() > 0)
m_CboVideoFormat.SetCurSel(0);
![](http://www.viscomsoft.com/doc/videocappro/addcomp56-addvideoformatcode.JPG)
Step 27: update the following code of Preview button click handler
int iDeviceIndex = m_CboVideoDevice.GetCurSel();
int iVideoFormatIndex = m_CboVideoFormat.GetCurSel();
if (iDeviceIndex != -1)
m_VideoCap.SetDevice(iDeviceIndex);
if (iVideoFormatIndex != -1)
m_VideoCap.SetVideoFormat(iVideoFormatIndex);
m_VideoCap.Start();
![](http://www.viscomsoft.com/doc/videocappro/addcomp57-updatepreviewcode.JPG)
Step 28: In Class Wizard, selected IDC_VIDEODEVICE, selected CBN_SELCHANGE, click Add Handler... , then click Edit Code, add the followint code , it can refresh the video format combo box when you changed the video device combo box item.
int iVideoFormatCount = m_CboVideoFormat.GetCount();
for (int i = 0; i < iVideoFormatCount; i )
m_CboVideoFormat.DeleteString(0);
m_VideoCap.RefreshVideoDevice(m_CboDevice.GetCurSel());
iVideoFormatCount = m_VideoCap.GetVideoFormats().GetCount();
CString strVideoFormat;
for (int i = 0; i < iVideoFormatCount; i )
{
strVideoFormat = m_VideoCap.GetVideoFormats().FindVideoFormatName(i);
m_CboVideoFormat.AddString(strVideoFormat);
}
if (m_CboVideoFormat.GetCount() > 0)
m_CboVideoFormat.SetCurSel(0);
![](http://www.viscomsoft.com/doc/videocappro/addcomp59-selvideodeviceupdatecode.JPG)
Step 29: Finally you can run the project. Preview the video from video device.
![](http://www.viscomsoft.com/doc/videocappro/addcomp60-runproject.JPG)
Step 30:
Download this project sample source code. Select compile in X86.