Webcam32 FAQs       User's Guide       Java Support       Help Wizard
Webcam32 - Automation Client with Visual C++


This section describes creating a simple automation client applications with Microsoft Visual C++ V5.  It assumes that you are somewhat familiar with that environment.  The target application will be a dialog based application with a button to cause Webcam32 to start an immediate FTP session.

Step 1 - Create a plain dialog based app

You should now have a default Dialog based application.  Compile and run and the following dialog should appear

dialog_plain.gif (2666 bytes)

Step 2 - Modify the dialog to have an FTP now button

Change the dialog using the Resource editor within Visual Studio to include a button (IDC_FTP) and remove the Cancel button.  The resulting dialog should look like:

dialog_modified.gif (2435 bytes)

Step 3 - Assign a handler for the FTP Now!! button

Using the ClassWizard, add a handler for the FTP button to call OnFtp when pressed

cw_ftp.gif (10820 bytes)

Step 4 - Add the IWebcam32API client Interface class

This is the magic part.  Webcam32 supplies a file called the Type Library.  This file contains an interface description of the methods exported and usable from Webcam32 itself.  To utilize this Type Library, we create a new class using the class wizard.

This will create a new class and can be seen in theWorkspace pane as follows:

ide1.gif (9609 bytes)

Step 5 - Add OLE support to your application

In the stdafx.h header file, add the following to include MFC OLE definitions:

#include 
		

In the CWinApp::InitInstance() method, add the following line which will load and activate OLE support

    if (!AfxOleInit())
    {
        AfxMessageBox("Failed to initialize OLE");
        return FALSE;
    }

In dialog class, include the IWebcam32API header file and add a member variable which is public to access Webcam32

	#include "webcam32_2.h"
	...
	public:
		IWebcam32API m_Webcam32;

Step 6 - Call Webcam32 from your handler functions

In the handler for the dialog FTP Now!! button press, invoke the Webcam32 interface method FtpNow()

	void CWc32testDlg::OnFtp()
	{
	    m_Webcam32.FtpNow();
	}

Step 7 - Test

You are now all done.  Compile the program, start Webcam32 and run the new application.  Press the Ftp Now!! button and Webcam32 will perform an immediate FTP upload.